Completed
Push — master ( 04a827...87ad6d )
by Kiran
32s queued 28s
created
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   +2687 added lines, -2687 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.17' );
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.17' );
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();
330
+            $html = ob_get_clean();
331 331
 
332
-			if ( wp_doing_ajax() ) {
333
-				echo $html;
334
-				$should_die = true;
332
+            if ( wp_doing_ajax() ) {
333
+                echo $html;
334
+                $should_die = true;
335 335
 
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
-				);
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 341
 
342
-				foreach ( $dont_die as $request ) {
343
-					if ( isset( $_REQUEST[ $request ] ) ) {
344
-						$should_die = false;
345
-					}
346
-				}
342
+                foreach ( $dont_die as $request ) {
343
+                    if ( isset( $_REQUEST[ $request ] ) ) {
344
+                        $should_die = false;
345
+                    }
346
+                }
347 347
 
348
-				if ( $should_die ) {
349
-					wp_die();
350
-				}
348
+                if ( $should_die ) {
349
+                    wp_die();
350
+                }
351 351
 
352
-			} else {
353
-				return $html;
354
-			}
352
+            } else {
353
+                return $html;
354
+            }
355 355
 
356
-			return '';
356
+            return '';
357 357
 
358
-		}
358
+        }
359 359
 
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
-			}
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
+            }
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] ) . '"' : '' ) . ' />';
380
-		}
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
+        }
381 381
 
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
-			}
382
+        /**
383
+         * Get widget settings.
384
+         *
385
+         * @since 1.0.0
386
+         */
387
+        public static function get_widget_settings() {
388
+            global $sd_widgets;
402 389
 
403
-			// invoke an instance method
404
-			$widget = new $class_name;
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 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
-			?>
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
-		}
414
+            wp_die();
415
+        }
416 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();
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 432
 
433 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
-			}
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 441
 
442
-			echo self::shortcode_button( 'this', 'true' );
442
+            echo self::shortcode_button( 'this', 'true' );
443 443
 
444
-			// see opening note
445
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
446
-				echo '</span>'; // end #insert-media-button
447
-			}
444
+            // see opening note
445
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
446
+                echo '</span>'; // end #insert-media-button
447
+            }
448 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
-			}
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 454
 
455
-			$shortcode_insert_button_once = true;
456
-		}
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 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
-			}
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 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
-						}
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
+                }
1361 1373
 
1362
-						if ( ! empty( $value ) ) {
1363
-							$value = wp_unslash( $value );
1374
+                $shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]";
1364 1375
 
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
-				}
1376
+                $content = do_shortcode( $shortcode );
1373 1377
 
1374
-				$shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]";
1378
+                // Decode [ and ].
1379
+                if ( ! empty( $content ) && $is_preview ) {
1380
+                    $content = $this->decode_shortcodes( $content );
1381
+                }
1375 1382
 
1376
-				$content = do_shortcode( $shortcode );
1383
+                echo $content;
1384
+            }
1385
+            wp_die();
1386
+        }
1377 1387
 
1378
-				// Decode [ and ].
1379
-				if ( ! empty( $content ) && $is_preview ) {
1380
-					$content = $this->decode_shortcodes( $content );
1381
-				}
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;
1382 1398
 
1383
-				echo $content;
1384
-			}
1385
-			wp_die();
1386
-		}
1399
+            $args = $this->argument_values( $args );
1387 1400
 
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
-			}
1401
+            // add extra argument so we know its a output to gutenberg
1402
+            //$args
1403
+            $args = $this->string_to_bool( $args );
1409 1404
 
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 );
1405
+            // if we have a enclosed shortcode we add it to the special `html` argument
1406
+            if ( ! empty( $content ) ) {
1407
+                $args['html'] = $content;
1408
+            }
1422 1409
 
1423
-				if ( ! is_array( $args ) ) {
1424
-					return $args;
1425
-				}
1426
-			}
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 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
-			$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
-			}
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 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
-			}
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 1474
 
1475
-			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1476
-		}
1475
+            return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1476
+        }
1477 1477
 
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
-		}
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
+        }
1488 1488
 
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
-			}
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
+            }
1505 1505
 
1506
-			return $options;
1507
-		}
1506
+            return $options;
1507
+        }
1508 1508
 
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
-			}
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();
1527 1520
 
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
-			}
1521
+            // set widget instance
1522
+            $this->instance = $instance;
1541 1523
 
1542
-			return $argument_values;
1543
-		}
1524
+            if ( empty( $this->arguments ) ) {
1525
+                $this->arguments = $this->get_arguments();
1526
+            }
1544 1527
 
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
-		}
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
+            }
1555 1541
 
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
-			}
1542
+            return $argument_values;
1543
+        }
1567 1544
 
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 );
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
+        }
1570 1555
 
1571
-			return $this->arguments;
1572
-		}
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
+            }
1573 1567
 
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 = '' ) {
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 );
1582 1570
 
1583
-		}
1571
+            return $this->arguments;
1572
+        }
1584 1573
 
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
-		}
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 = '' ) {
1594 1582
 
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
-			}
1583
+        }
1613 1584
 
1614
-			return $show;
1615
-		}
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
+        }
1616 1594
 
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
-				}
1595
+        /**
1596
+         * Check if we need to show advanced options.
1597
+         *
1598
+         * @return bool
1599
+         */
1600
+        public function block_show_advanced() {
1633 1601
 
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
-			}
1602
+            $show      = false;
1603
+            $arguments = $this->get_arguments();
1640 1604
 
1641
-			return $url;
1642
-		}
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
+            }
1643 1613
 
1644
-		/**
1645
-		 * Get the url path to the current folder.
1646
-		 *
1647
-		 * @return string
1648
-		 */
1649
-		public function get_url_old() {
1614
+            return $show;
1615
+        }
1650 1616
 
1651
-			$url = $this->url;
1617
+        /**
1618
+         * Get the url path to the current folder.
1619
+         *
1620
+         * @return string
1621
+         */
1622
+        public function get_url() {
1623
+            $url = $this->url;
1652 1624
 
1653
-			if ( ! $url ) {
1654
-				// check if we are inside a plugin
1655
-				$file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1625
+            if ( ! $url ) {
1626
+                $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1627
+                $content_url = untrailingslashit( WP_CONTENT_URL );
1656 1628
 
1657
-				$dir_parts = explode( "/wp-content/", $file_dir );
1658
-				$url_parts = explode( "/wp-content/", plugins_url() );
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
+                }
1659 1633
 
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
-			}
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
+            }
1665 1640
 
1641
+            return $url;
1642
+        }
1666 1643
 
1667
-			return $url;
1668
-		}
1644
+        /**
1645
+         * Get the url path to the current folder.
1646
+         *
1647
+         * @return string
1648
+         */
1649
+        public function get_url_old() {
1669 1650
 
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
-			}
1651
+            $url = $this->url;
1695 1652
 
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
-			}
1653
+            if ( ! $url ) {
1654
+                // check if we are inside a plugin
1655
+                $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1701 1656
 
1702
-			return $icon;
1703
-		}
1657
+                $dir_parts = explode( "/wp-content/", $file_dir );
1658
+                $url_parts = explode( "/wp-content/", plugins_url() );
1704 1659
 
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
-				}
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
+            }
1718 1665
 
1719
-				// only add sections if more than one
1720
-				if ( $add_sections ) {
1721
-					$arguments = $temp_arguments;
1722
-				}
1723
-			}
1724 1666
 
1725
-			return $arguments;
1726
-		}
1667
+            return $url;
1668
+        }
1727 1669
 
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
-				}
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
+            }
1743 1695
 
1744
-				if ( ! $has_sections ) {
1745
-					return $tabs;
1746
-				}
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
+            }
1747 1701
 
1748
-				$new_tabs = array();
1702
+            return $icon;
1703
+        }
1749 1704
 
1750
-				foreach ( $tabs as $tab_key => $tab ) {
1751
-					$new_groups = array();
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
+                }
1752 1718
 
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
-					}
1719
+                // only add sections if more than one
1720
+                if ( $add_sections ) {
1721
+                    $arguments = $temp_arguments;
1722
+                }
1723
+            }
1760 1724
 
1761
-					if ( ! empty( $new_groups ) ) {
1762
-						$tab['groups'] = $new_groups;
1725
+            return $arguments;
1726
+        }
1763 1727
 
1764
-						$new_tabs[ $tab_key ] = $tab;
1765
-					}
1766
-				}
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
+                }
1767 1743
 
1768
-				$tabs = $new_tabs;
1769
-			}
1744
+                if ( ! $has_sections ) {
1745
+                    return $tabs;
1746
+                }
1770 1747
 
1771
-			return $tabs;
1772
-		}
1748
+                $new_tabs = array();
1749
+
1750
+                foreach ( $tabs as $tab_key => $tab ) {
1751
+                    $new_groups = array();
1752
+
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
+                    }
1760
+
1761
+                    if ( ! empty( $new_groups ) ) {
1762
+                        $tab['groups'] = $new_groups;
1773 1763
 
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
-			?>
1764
+                        $new_tabs[ $tab_key ] = $tab;
1765
+                    }
1766
+                }
1767
+
1768
+                $tabs = $new_tabs;
1769
+            }
1770
+
1771
+            return $tabs;
1772
+        }
1773
+
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
+            ?>
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('');
@@ -2290,8 +2290,8 @@  discard block
 block discarded – undo
2290 2290
 				$classes = [];
2291 2291
 
2292 2292
 				<?php
2293
-				if($aui_bs5){
2294
-					?>
2293
+                if($aui_bs5){
2294
+                    ?>
2295 2295
 				$aui_bs5 = true;
2296 2296
 				$p_ml = 'ms-';
2297 2297
 				$p_mr = 'me-';
@@ -2299,8 +2299,8 @@  discard block
 block discarded – undo
2299 2299
 				$p_pl = 'ps-';
2300 2300
 				$p_pr = 'pe-';
2301 2301
 					<?php
2302
-				}else{
2303
-						?>
2302
+                }else{
2303
+                        ?>
2304 2304
 				$aui_bs5 = false;
2305 2305
 				$p_ml = 'ml-';
2306 2306
 				$p_mr = 'mr-';
@@ -2308,8 +2308,8 @@  discard block
 block discarded – undo
2308 2308
 				$p_pl = 'pl-';
2309 2309
 				$p_pr = 'pr-';
2310 2310
 					<?php
2311
-				}
2312
-				?>
2311
+                }
2312
+                ?>
2313 2313
 
2314 2314
 				// margins
2315 2315
 				if ( $args['mt'] !== undefined && $args['mt'] !== '' ) { $classes.push( "mt-" + $args['mt'] );  $mt = $args['mt']; }else{$mt = null;}
@@ -2493,12 +2493,12 @@  discard block
 block discarded – undo
2493 2493
 			<?php
2494 2494
 
2495 2495
 
2496
-			}
2496
+            }
2497 2497
 
2498
-			if(method_exists($this,'block_global_js')){
2499
-					echo $this->block_global_js();
2500
-			}
2501
-			?>
2498
+            if(method_exists($this,'block_global_js')){
2499
+                    echo $this->block_global_js();
2500
+            }
2501
+            ?>
2502 2502
 
2503 2503
 jQuery(function() {
2504 2504
 
@@ -2551,13 +2551,13 @@  discard block
 block discarded – undo
2551 2551
 						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/.
2552 2552
 						supports: {
2553 2553
 							<?php
2554
-							if(!isset($this->options['block-supports']['renaming'])){
2555
-								$this->options['block-supports']['renaming'] = false;
2556
-							}
2557
-							if ( isset( $this->options['block-supports'] ) ) {
2558
-								echo $this->array_to_attributes( $this->options['block-supports'] );
2559
-							}
2560
-							?>
2554
+                            if(!isset($this->options['block-supports']['renaming'])){
2555
+                                $this->options['block-supports']['renaming'] = false;
2556
+                            }
2557
+                            if ( isset( $this->options['block-supports'] ) ) {
2558
+                                echo $this->array_to_attributes( $this->options['block-supports'] );
2559
+                            }
2560
+                            ?>
2561 2561
 						},
2562 2562
 						__experimentalLabel( attributes, { context } ) {
2563 2563
 							var visibility_html = attributes && attributes.visibility_conditions ? ' &#128065;' : '';
@@ -2567,174 +2567,174 @@  discard block
 block discarded – undo
2567 2567
 						},
2568 2568
 						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.
2569 2569
 						<?php if ( isset( $this->options['block-keywords'] ) ) {
2570
-						echo "keywords : " . $this->options['block-keywords'] . ",";
2571
-						}
2572
-
2573
-
2574
-						// block hover preview.
2575
-						$example_args = array();
2576
-						if(!empty($this->arguments)){
2577
-							foreach($this->arguments as $key => $a_args){
2578
-								if(isset($a_args['example'])){
2579
-									$example_args[$key] = $a_args['example'];
2580
-								}
2581
-							}
2582
-						}
2583
-						$viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : '';
2584
-						$example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2585
-						if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2586
-							// no preview if set to false
2587
-						}elseif( !empty( $example_args ) ){
2588
-							echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2589
-						}elseif( !empty( $this->options['example'] ) ){
2590
-							unset($this->options['example']['viewportWidth']);
2591
-							unset($this->options['example']['innerBlocks']);
2592
-							$example_atts = $this->array_to_attributes( $this->options['example'] );
2593
-							$example_parts = array();
2594
-							if($example_atts){
2595
-								$example_parts[] = rtrim($example_atts,",");
2596
-							}
2597
-							if($viewport_width){
2598
-								$example_parts[] = $viewport_width;
2599
-							}
2600
-							if($example_inner_blocks){
2601
-								$example_parts[] = $example_inner_blocks;
2602
-							}
2603
-							if(!empty($example_parts)){
2604
-								echo "example : {".implode(',', $example_parts)."},";
2605
-							}
2606
-						}else{
2607
-							echo 'example : {viewportWidth: 500},';
2608
-						}
2609
-
2610
-
2611
-
2612
-						// limit to parent
2613
-						if( !empty( $this->options['parent'] ) ){
2614
-							echo "parent : " . wp_json_encode( $this->options['parent'] ) . ",";
2615
-						}
2616
-
2617
-						// limit allowed blocks
2618
-						if( !empty( $this->options['allowed-blocks'] ) ){
2619
-							echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ",";
2620
-						}
2621
-
2622
-						// maybe set no_wrap
2623
-						$no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2624
-						if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2625
-							$no_wrap = true;
2626
-						}
2627
-						if ( $no_wrap ) {
2628
-							$this->options['block-wrap'] = '';
2629
-						}
2630
-
2631
-						// maybe load the drag/drop functions.
2632
-						$img_drag_drop = false;
2633
-
2634
-						$show_alignment = false;
2635
-						// align feature
2636
-						/*echo "supports: {";
2570
+                        echo "keywords : " . $this->options['block-keywords'] . ",";
2571
+                        }
2572
+
2573
+
2574
+                        // block hover preview.
2575
+                        $example_args = array();
2576
+                        if(!empty($this->arguments)){
2577
+                            foreach($this->arguments as $key => $a_args){
2578
+                                if(isset($a_args['example'])){
2579
+                                    $example_args[$key] = $a_args['example'];
2580
+                                }
2581
+                            }
2582
+                        }
2583
+                        $viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : '';
2584
+                        $example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2585
+                        if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2586
+                            // no preview if set to false
2587
+                        }elseif( !empty( $example_args ) ){
2588
+                            echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2589
+                        }elseif( !empty( $this->options['example'] ) ){
2590
+                            unset($this->options['example']['viewportWidth']);
2591
+                            unset($this->options['example']['innerBlocks']);
2592
+                            $example_atts = $this->array_to_attributes( $this->options['example'] );
2593
+                            $example_parts = array();
2594
+                            if($example_atts){
2595
+                                $example_parts[] = rtrim($example_atts,",");
2596
+                            }
2597
+                            if($viewport_width){
2598
+                                $example_parts[] = $viewport_width;
2599
+                            }
2600
+                            if($example_inner_blocks){
2601
+                                $example_parts[] = $example_inner_blocks;
2602
+                            }
2603
+                            if(!empty($example_parts)){
2604
+                                echo "example : {".implode(',', $example_parts)."},";
2605
+                            }
2606
+                        }else{
2607
+                            echo 'example : {viewportWidth: 500},';
2608
+                        }
2609
+
2610
+
2611
+
2612
+                        // limit to parent
2613
+                        if( !empty( $this->options['parent'] ) ){
2614
+                            echo "parent : " . wp_json_encode( $this->options['parent'] ) . ",";
2615
+                        }
2616
+
2617
+                        // limit allowed blocks
2618
+                        if( !empty( $this->options['allowed-blocks'] ) ){
2619
+                            echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ",";
2620
+                        }
2621
+
2622
+                        // maybe set no_wrap
2623
+                        $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2624
+                        if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2625
+                            $no_wrap = true;
2626
+                        }
2627
+                        if ( $no_wrap ) {
2628
+                            $this->options['block-wrap'] = '';
2629
+                        }
2630
+
2631
+                        // maybe load the drag/drop functions.
2632
+                        $img_drag_drop = false;
2633
+
2634
+                        $show_alignment = false;
2635
+                        // align feature
2636
+                        /*echo "supports: {";
2637 2637
 						echo "	align: true,";
2638 2638
 						echo "  html: false";
2639 2639
 						echo "},";*/
2640 2640
 
2641 2641
 
2642
-							echo "attributes : {";
2643
-
2644
-							if ( $show_advanced ) {
2645
-								echo "show_advanced: {";
2646
-								echo "	type: 'boolean',";
2647
-								echo "  default: false,";
2648
-								echo "},";
2649
-							}
2650
-
2651
-							// block wrap element
2652
-							if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2653
-								echo "block_wrap: {";
2654
-								echo "	type: 'string',";
2655
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2656
-								echo "},";
2657
-							}
2658
-
2659
-
2660
-							if ( ! empty( $this->arguments ) ) {
2661
-
2662
-								foreach ( $this->arguments as $key => $args ) {
2663
-
2664
-									if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2665
-										$img_drag_drop = true;
2666
-									}
2667
-
2668
-									// set if we should show alignment
2669
-									if ( $key == 'alignment' ) {
2670
-										$show_alignment = true;
2671
-									}
2672
-
2673
-									$extra = '';
2674
-
2675
-									if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2676
-										continue;
2677
-									}
2678
-									elseif ( $args['type'] == 'checkbox' ) {
2679
-										$type    = 'boolean';
2680
-										$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2681
-									} elseif ( $args['type'] == 'number' ) {
2682
-										$type    = 'number';
2683
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2684
-									} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2685
-										$type = 'array';
2686
-										if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2687
-											$default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2688
-										} else {
2689
-											$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2690
-										}
2691
-									} elseif ( $args['type'] == 'tagselect' ) {
2692
-										$type    = 'array';
2693
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2694
-									} elseif ( $args['type'] == 'multiselect' ) {
2695
-										$type    = 'array';
2696
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2697
-									} elseif ( $args['type'] == 'image_xy' ) {
2698
-										$type    = 'object';
2699
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2700
-									} elseif ( $args['type'] == 'image' ) {
2701
-										$type    = 'string';
2702
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2703
-
2704
-										// add a field for ID
2705
-	//                                    echo $key . "_id : {";
2706
-	//                                    echo "type : 'number',";
2707
-	//                                    echo "},";
2708
-	//                                    echo $key . "_xy : {";
2709
-	//                                    echo "type : 'object',";
2710
-	//                                    echo "},";
2711
-
2712
-									} else {
2713
-										$type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2714
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2715
-
2716
-									}
2717
-									echo $key . " : {";
2718
-									echo "type : '$type',";
2719
-									echo "default : $default,";
2720
-									echo "},";
2721
-								}
2722
-							}
2723
-
2724
-							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2725
-							echo "sd_shortcode : {type : 'string',default: ''},";
2726
-
2727
-							if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
2728
-								echo "sd_shortcode_close : {type : 'string',default: ''},";
2729
-							}
2730
-
2731
-							echo "className: { type: 'string', default: '' },";
2732
-
2733
-							echo "},";
2734
-
2735
-
2736
-
2737
-						?>
2642
+                            echo "attributes : {";
2643
+
2644
+                            if ( $show_advanced ) {
2645
+                                echo "show_advanced: {";
2646
+                                echo "	type: 'boolean',";
2647
+                                echo "  default: false,";
2648
+                                echo "},";
2649
+                            }
2650
+
2651
+                            // block wrap element
2652
+                            if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2653
+                                echo "block_wrap: {";
2654
+                                echo "	type: 'string',";
2655
+                                echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2656
+                                echo "},";
2657
+                            }
2658
+
2659
+
2660
+                            if ( ! empty( $this->arguments ) ) {
2661
+
2662
+                                foreach ( $this->arguments as $key => $args ) {
2663
+
2664
+                                    if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2665
+                                        $img_drag_drop = true;
2666
+                                    }
2667
+
2668
+                                    // set if we should show alignment
2669
+                                    if ( $key == 'alignment' ) {
2670
+                                        $show_alignment = true;
2671
+                                    }
2672
+
2673
+                                    $extra = '';
2674
+
2675
+                                    if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2676
+                                        continue;
2677
+                                    }
2678
+                                    elseif ( $args['type'] == 'checkbox' ) {
2679
+                                        $type    = 'boolean';
2680
+                                        $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2681
+                                    } elseif ( $args['type'] == 'number' ) {
2682
+                                        $type    = 'number';
2683
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2684
+                                    } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2685
+                                        $type = 'array';
2686
+                                        if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2687
+                                            $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2688
+                                        } else {
2689
+                                            $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2690
+                                        }
2691
+                                    } elseif ( $args['type'] == 'tagselect' ) {
2692
+                                        $type    = 'array';
2693
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2694
+                                    } elseif ( $args['type'] == 'multiselect' ) {
2695
+                                        $type    = 'array';
2696
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2697
+                                    } elseif ( $args['type'] == 'image_xy' ) {
2698
+                                        $type    = 'object';
2699
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2700
+                                    } elseif ( $args['type'] == 'image' ) {
2701
+                                        $type    = 'string';
2702
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2703
+
2704
+                                        // add a field for ID
2705
+    //                                    echo $key . "_id : {";
2706
+    //                                    echo "type : 'number',";
2707
+    //                                    echo "},";
2708
+    //                                    echo $key . "_xy : {";
2709
+    //                                    echo "type : 'object',";
2710
+    //                                    echo "},";
2711
+
2712
+                                    } else {
2713
+                                        $type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2714
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2715
+
2716
+                                    }
2717
+                                    echo $key . " : {";
2718
+                                    echo "type : '$type',";
2719
+                                    echo "default : $default,";
2720
+                                    echo "},";
2721
+                                }
2722
+                            }
2723
+
2724
+                            echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2725
+                            echo "sd_shortcode : {type : 'string',default: ''},";
2726
+
2727
+                            if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
2728
+                                echo "sd_shortcode_close : {type : 'string',default: ''},";
2729
+                            }
2730
+
2731
+                            echo "className: { type: 'string', default: '' },";
2732
+
2733
+                            echo "},";
2734
+
2735
+
2736
+
2737
+                        ?>
2738 2738
 
2739 2739
 						// The "edit" property must be a valid function.
2740 2740
 						edit: function (props) {
@@ -2809,10 +2809,10 @@  discard block
 block discarded – undo
2809 2809
 							}
2810 2810
 
2811 2811
 							<?php
2812
-							if(!empty($this->options['block-edit-raw'])) {
2813
-								echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2814
-							}else{
2815
-							?>
2812
+                            if(!empty($this->options['block-edit-raw'])) {
2813
+                                echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2814
+                            }else{
2815
+                            ?>
2816 2816
 
2817 2817
 function hasSelectedInnerBlock(props) {
2818 2818
 	const select = wp.data.select('core/editor');
@@ -2834,9 +2834,9 @@  discard block
 block discarded – undo
2834 2834
 
2835 2835
 	var $value = '';
2836 2836
 	<?php
2837
-	// if we have a post_type and a category then link them
2838
-	if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2839
-	?>
2837
+    // if we have a post_type and a category then link them
2838
+    if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2839
+    ?>
2840 2840
 	if(typeof(prev_attributes[props.clientId]) != 'undefined' && selectedBlock && selectedBlock.clientId === props.clientId){
2841 2841
 		$pt = props.attributes.post_type;
2842 2842
 		if(post_type_rest_slugs.length){
@@ -2849,11 +2849,11 @@  discard block
 block discarded – undo
2849 2849
 			term_query_type = $pt;
2850 2850
 		}
2851 2851
 <?php
2852
-	$cat_path = '';
2853
-	if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) {
2854
-		$cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) );
2855
-		$cat_path = str_replace( array( '&quot;', '&#039;' ), array( '"', "'" ), $cat_path );
2856
-	}
2852
+    $cat_path = '';
2853
+    if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) {
2854
+        $cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) );
2855
+        $cat_path = str_replace( array( '&quot;', '&#039;' ), array( '"', "'" ), $cat_path );
2856
+    }
2857 2857
 ?>
2858 2858
 		/* taxonomies */
2859 2859
 		if($value && 'post_type' in prev_attributes[props.clientId] && 'category' in prev_attributes[props.clientId] && run){
@@ -2945,7 +2945,7 @@  discard block
 block discarded – undo
2945 2945
 <?php
2946 2946
 $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2947 2947
 if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2948
-	echo 'const { deviceType } = "";';
2948
+    echo 'const { deviceType } = "";';
2949 2949
 }else{
2950 2950
 ?>
2951 2951
 /** Get device type const. */
@@ -3009,8 +3009,8 @@  discard block
 block discarded – undo
3009 3009
 										'attributes': props.attributes,
3010 3010
 										'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '',
3011 3011
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
3012
-										echo $post->ID;
3013
-									}else{echo '0';}?>,
3012
+                                        echo $post->ID;
3013
+                                    }else{echo '0';}?>,
3014 3014
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
3015 3015
 									};
3016 3016
 
@@ -3024,20 +3024,20 @@  discard block
 block discarded – undo
3024 3024
 										}
3025 3025
 
3026 3026
 										 <?php
3027
-										if(!empty($this->options['nested-block'])){
3028
-											?>
3027
+                                        if(!empty($this->options['nested-block'])){
3028
+                                            ?>
3029 3029
 											// props.setAttributes({content: env});
3030 3030
 										is_fetching = false;
3031 3031
 										prev_attributes[props.clientId] = props.attributes;
3032 3032
 											 <?php
3033
-										}else{
3034
-										?>
3033
+                                        }else{
3034
+                                        ?>
3035 3035
 										props.setAttributes({content: env});
3036 3036
 										is_fetching = false;
3037 3037
 										prev_attributes[props.clientId] = props.attributes;
3038 3038
 										<?php
3039
-										}
3040
-										?>
3039
+                                        }
3040
+                                        ?>
3041 3041
 
3042 3042
 
3043 3043
 										// if AUI is active call the js init function
@@ -3056,31 +3056,31 @@  discard block
 block discarded – undo
3056 3056
 							}
3057 3057
 
3058 3058
 							<?php
3059
-							if(!empty($this->options['block-edit-js'])) {
3060
-								echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
3061
-							}
3059
+                            if(!empty($this->options['block-edit-js'])) {
3060
+                                echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
3061
+                            }
3062 3062
 
3063 3063
 
3064 3064
 
3065 3065
 
3066
-							if(empty($this->options['block-save-return'])){
3067
-							?>
3066
+                            if(empty($this->options['block-save-return'])){
3067
+                            ?>
3068 3068
 								///////////////////////////////////////////////////////////////////////
3069 3069
 
3070 3070
 									 // build the shortcode.
3071 3071
 								shortcode = "[<?php echo $this->options['base_id'];?>";
3072 3072
 								<?php
3073 3073
 
3074
-								if(! empty( $this->arguments )){
3074
+                                if(! empty( $this->arguments )){
3075 3075
 
3076
-								foreach($this->arguments as $key => $args){
3077
-								   // if($args['type']=='tabs'){continue;}
3076
+                                foreach($this->arguments as $key => $args){
3077
+                                    // if($args['type']=='tabs'){continue;}
3078 3078
 
3079
-								   // don't add metadata arguments
3080
-								   if (substr($key, 0, 9 ) === 'metadata_') {
3081
-									   continue;
3082
-								   }
3083
-								?>
3079
+                                    // don't add metadata arguments
3080
+                                    if (substr($key, 0, 9 ) === 'metadata_') {
3081
+                                        continue;
3082
+                                    }
3083
+                                ?>
3084 3084
 								if (props.attributes.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3085 3085
 									if ('<?php echo esc_attr( $key );?>' == 'html') {
3086 3086
 									} else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') {
@@ -3091,10 +3091,10 @@  discard block
 block discarded – undo
3091 3091
 									}
3092 3092
 								}
3093 3093
 								<?php
3094
-								}
3095
-								}
3094
+                                }
3095
+                                }
3096 3096
 
3097
-								?>
3097
+                                ?>
3098 3098
 								shortcode += "]";
3099 3099
 
3100 3100
 								if(shortcode){
@@ -3106,17 +3106,17 @@  discard block
 block discarded – undo
3106 3106
 
3107 3107
 
3108 3108
 									<?php
3109
-									if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
3110
-										echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});";
3111
-									}
3112
-									?>
3109
+                                    if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
3110
+                                        echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});";
3111
+                                    }
3112
+                                    ?>
3113 3113
 								}
3114 3114
 
3115 3115
 
3116 3116
 							///////////////////////////////////////////////////////////////////////
3117 3117
 							<?php
3118
-							} // end nested block check
3119
-							?>
3118
+                            } // end nested block check
3119
+                            ?>
3120 3120
 
3121 3121
 							return [
3122 3122
 
@@ -3140,10 +3140,10 @@  discard block
 block discarded – undo
3140 3140
 
3141 3141
 									<?php
3142 3142
 
3143
-									if(! empty( $this->arguments )){
3143
+                                    if(! empty( $this->arguments )){
3144 3144
 
3145
-									if ( $show_advanced ) {
3146
-									?>
3145
+                                    if ( $show_advanced ) {
3146
+                                    ?>
3147 3147
 									el('div', {
3148 3148
 											style: {'padding-left': '16px','padding-right': '16px'}
3149 3149
 										},
@@ -3160,119 +3160,119 @@  discard block
 block discarded – undo
3160 3160
 									)
3161 3161
 									,
3162 3162
 									<?php
3163
-									}
3164
-
3165
-									$arguments = $this->group_arguments( $this->arguments );
3166
-									$block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array();
3167
-
3168
-									// Do we have sections?
3169
-									$has_sections = $arguments == $this->arguments ? false : true;
3170
-
3171
-									if($has_sections){
3172
-									$panel_count = 0;
3173
-									$open_tab = '';
3174
-
3175
-									$open_tab_groups = array();
3176
-									$used_tabs = array();
3177
-
3178
-									foreach ( $arguments as $key => $args ) {
3179
-										$close_tab = false;
3180
-										$close_tabs = false;
3181
-
3182
-										 if ( ! empty( $block_group_tabs ) ) {
3183
-											foreach ( $block_group_tabs as $tab_name => $tab_args ) {
3184
-												if ( in_array( $key, $tab_args['groups'] ) ) {
3185
-													$open_tab_groups[] = $key;
3186
-
3187
-													if ( $open_tab != $tab_name ) {
3188
-														$tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
3189
-														$tab_args['tab']['open'] = true;
3190
-
3191
-														$this->block_tab_start( '', $tab_args );
3192
-														$open_tab = $tab_name;
3193
-														$used_tabs[] = $tab_name;
3194
-													}
3195
-
3196
-													if ( $open_tab_groups == $tab_args['groups'] ) {
3197
-														$close_tab = true;
3198
-														$open_tab_groups = array();
3199
-
3200
-														if ( $used_tabs == array_keys( $block_group_tabs ) ) {
3201
-															$close_tabs = true;
3202
-														}
3203
-													}
3204
-												}
3205
-											}
3206
-										}
3207
-										?>
3163
+                                    }
3164
+
3165
+                                    $arguments = $this->group_arguments( $this->arguments );
3166
+                                    $block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array();
3167
+
3168
+                                    // Do we have sections?
3169
+                                    $has_sections = $arguments == $this->arguments ? false : true;
3170
+
3171
+                                    if($has_sections){
3172
+                                    $panel_count = 0;
3173
+                                    $open_tab = '';
3174
+
3175
+                                    $open_tab_groups = array();
3176
+                                    $used_tabs = array();
3177
+
3178
+                                    foreach ( $arguments as $key => $args ) {
3179
+                                        $close_tab = false;
3180
+                                        $close_tabs = false;
3181
+
3182
+                                            if ( ! empty( $block_group_tabs ) ) {
3183
+                                            foreach ( $block_group_tabs as $tab_name => $tab_args ) {
3184
+                                                if ( in_array( $key, $tab_args['groups'] ) ) {
3185
+                                                    $open_tab_groups[] = $key;
3186
+
3187
+                                                    if ( $open_tab != $tab_name ) {
3188
+                                                        $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
3189
+                                                        $tab_args['tab']['open'] = true;
3190
+
3191
+                                                        $this->block_tab_start( '', $tab_args );
3192
+                                                        $open_tab = $tab_name;
3193
+                                                        $used_tabs[] = $tab_name;
3194
+                                                    }
3195
+
3196
+                                                    if ( $open_tab_groups == $tab_args['groups'] ) {
3197
+                                                        $close_tab = true;
3198
+                                                        $open_tab_groups = array();
3199
+
3200
+                                                        if ( $used_tabs == array_keys( $block_group_tabs ) ) {
3201
+                                                            $close_tabs = true;
3202
+                                                        }
3203
+                                                    }
3204
+                                                }
3205
+                                            }
3206
+                                        }
3207
+                                        ?>
3208 3208
 										el(wp.components.PanelBody, {
3209 3209
 												title: '<?php esc_attr_e( $key ); ?>',
3210 3210
 												initialOpen: <?php if ( $panel_count ) {
3211
-												echo "false";
3212
-											} else {
3213
-												echo "true";
3214
-											}?>
3211
+                                                echo "false";
3212
+                                            } else {
3213
+                                                echo "true";
3214
+                                            }?>
3215 3215
 											},
3216 3216
 											<?php
3217
-											foreach ( $args as $k => $a ) {
3218
-												$this->block_tab_start( $k, $a );
3219
-												$this->block_row_start( $k, $a );
3220
-												$this->build_block_arguments( $k, $a );
3221
-												$this->block_row_end( $k, $a );
3222
-												$this->block_tab_end( $k, $a );
3223
-											}
3224
-											?>
3217
+                                            foreach ( $args as $k => $a ) {
3218
+                                                $this->block_tab_start( $k, $a );
3219
+                                                $this->block_row_start( $k, $a );
3220
+                                                $this->build_block_arguments( $k, $a );
3221
+                                                $this->block_row_end( $k, $a );
3222
+                                                $this->block_tab_end( $k, $a );
3223
+                                            }
3224
+                                            ?>
3225 3225
 										),
3226 3226
 										<?php
3227
-										$panel_count ++;
3227
+                                        $panel_count ++;
3228 3228
 
3229
-										if($close_tab || $close_tabs){
3230
-											$tab_args = array(
3231
-												'tab'	=> array(
3232
-													'tabs_close' => $close_tabs,
3233
-												'close' => true,
3234
-												)
3229
+                                        if($close_tab || $close_tabs){
3230
+                                            $tab_args = array(
3231
+                                                'tab'	=> array(
3232
+                                                    'tabs_close' => $close_tabs,
3233
+                                                'close' => true,
3234
+                                                )
3235 3235
 
3236
-											);
3237
-											$this->block_tab_end( '', $tab_args );
3236
+                                            );
3237
+                                            $this->block_tab_end( '', $tab_args );
3238 3238
 //											echo '###close'; print_r($tab_args);
3239
-											$panel_count = 0;
3240
-										}
3239
+                                            $panel_count = 0;
3240
+                                        }
3241 3241
 //
3242 3242
 
3243
-									}
3244
-									}else {
3245
-									?>
3243
+                                    }
3244
+                                    }else {
3245
+                                    ?>
3246 3246
 									el(wp.components.PanelBody, {
3247 3247
 											title: '<?php esc_attr_e( "Settings", 'ayecode-connect' ); ?>',
3248 3248
 											initialOpen: true
3249 3249
 										},
3250 3250
 										<?php
3251
-										foreach ( $this->arguments as $key => $args ) {
3252
-											$this->block_row_start( $key, $args );
3253
-											$this->build_block_arguments( $key, $args );
3254
-											$this->block_row_end( $key, $args );
3255
-										}
3256
-										?>
3251
+                                        foreach ( $this->arguments as $key => $args ) {
3252
+                                            $this->block_row_start( $key, $args );
3253
+                                            $this->build_block_arguments( $key, $args );
3254
+                                            $this->block_row_end( $key, $args );
3255
+                                        }
3256
+                                        ?>
3257 3257
 									),
3258 3258
 									<?php
3259
-									}
3259
+                                    }
3260 3260
 
3261
-									}
3262
-									?>
3261
+                                    }
3262
+                                    ?>
3263 3263
 
3264 3264
 								),
3265 3265
 
3266 3266
 								<?php
3267
-								// If the user sets block-output array then build it
3268
-								if ( ! empty( $this->options['block-output'] ) ) {
3269
-								$this->block_element( $this->options['block-output'] );
3270
-							}elseif(!empty($this->options['block-edit-return'])){
3271
-								   echo $this->options['block-edit-return'];
3272
-							}else{
3273
-								// if no block-output is set then we try and get the shortcode html output via ajax.
3274
-								$block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3275
-								?>
3267
+                                // If the user sets block-output array then build it
3268
+                                if ( ! empty( $this->options['block-output'] ) ) {
3269
+                                $this->block_element( $this->options['block-output'] );
3270
+                            }elseif(!empty($this->options['block-edit-return'])){
3271
+                                    echo $this->options['block-edit-return'];
3272
+                            }else{
3273
+                                // if no block-output is set then we try and get the shortcode html output via ajax.
3274
+                                $block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3275
+                                ?>
3276 3276
 								el('<?php echo esc_attr($block_edit_wrap_tag); ?>', wp.blockEditor.useBlockProps({
3277 3277
 									dangerouslySetInnerHTML: {__html: onChangeContent()},
3278 3278
 									className: props.className,
@@ -3280,13 +3280,13 @@  discard block
 block discarded – undo
3280 3280
 									style: {'minHeight': '30px'}
3281 3281
 								}))
3282 3282
 								<?php
3283
-								}
3284
-								?>
3283
+                                }
3284
+                                ?>
3285 3285
 							]; // end return
3286 3286
 
3287 3287
 							<?php
3288
-							} // end block-edit-raw else
3289
-							?>
3288
+                            } // end block-edit-raw else
3289
+                            ?>
3290 3290
 						},
3291 3291
 
3292 3292
 						// The "save" property must be specified and must be a valid function.
@@ -3300,16 +3300,16 @@  discard block
 block discarded – undo
3300 3300
 							$html = '';
3301 3301
 							<?php
3302 3302
 
3303
-							if(! empty( $this->arguments )){
3303
+                            if(! empty( $this->arguments )){
3304 3304
 
3305
-							foreach($this->arguments as $key => $args){
3306
-							   // if($args['type']=='tabs'){continue;}
3305
+                            foreach($this->arguments as $key => $args){
3306
+                                // if($args['type']=='tabs'){continue;}
3307 3307
 
3308
-							   // don't add metadata arguments
3309
-							   if (substr($key, 0, 9 ) === 'metadata_') {
3310
-								   continue;
3311
-							   }
3312
-							?>
3308
+                                // don't add metadata arguments
3309
+                                if (substr($key, 0, 9 ) === 'metadata_') {
3310
+                                    continue;
3311
+                                }
3312
+                            ?>
3313 3313
 							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3314 3314
 								if ('<?php echo esc_attr( $key );?>' == 'html') {
3315 3315
 									$html = attr.<?php echo esc_attr( $key );?>;
@@ -3320,10 +3320,10 @@  discard block
 block discarded – undo
3320 3320
 								}
3321 3321
 							}
3322 3322
 							<?php
3323
-							}
3324
-							}
3323
+                            }
3324
+                            }
3325 3325
 
3326
-							?>
3326
+                            ?>
3327 3327
 							content += "]";
3328 3328
 							 content = '';
3329 3329
 
@@ -3333,7 +3333,7 @@  discard block
 block discarded – undo
3333 3333
 //                                $html = 'el( InnerBlocks.Content )';
3334 3334
 //                                <?php
3335 3335
 //                            }
3336
-							?>
3336
+                            ?>
3337 3337
 							// if has html element
3338 3338
 							if ($html) {
3339 3339
 								//content += $html + "[/<?php echo $this->options['base_id'];?>]";
@@ -3366,12 +3366,12 @@  discard block
 block discarded – undo
3366 3366
 //                                <x?php
3367 3367
 //							}else
3368 3368
 
3369
-							if(!empty($this->options['block-output'])){
3369
+                            if(!empty($this->options['block-output'])){
3370 3370
 //                               echo "return";
3371 3371
 //                               $this->block_element( $this->options['block-output'], true );
3372 3372
 //                               echo ";";
3373 3373
 
3374
-							   ?>
3374
+                                ?>
3375 3375
 							  return el(
3376 3376
 								   '',
3377 3377
 								   {},
@@ -3381,10 +3381,10 @@  discard block
 block discarded – undo
3381 3381
 							   );
3382 3382
 								<?php
3383 3383
 
3384
-							}elseif(!empty($this->options['block-save-return'])){
3385
-								   echo 'return ' . $this->options['block-save-return'];
3386
-							}elseif(!empty($this->options['nested-block'])){
3387
-								?>
3384
+                            }elseif(!empty($this->options['block-save-return'])){
3385
+                                    echo 'return ' . $this->options['block-save-return'];
3386
+                            }elseif(!empty($this->options['nested-block'])){
3387
+                                ?>
3388 3388
 							  return el(
3389 3389
 								   '',
3390 3390
 								   {},
@@ -3393,22 +3393,22 @@  discard block
 block discarded – undo
3393 3393
 								 //  el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3394 3394
 							   );
3395 3395
 								<?php
3396
-							}elseif(!empty( $this->options['block-save-return'] ) ){
3397
-								echo "return ". $this->options['block-edit-return'].";";
3398
-							}elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3399
-							?>
3396
+                            }elseif(!empty( $this->options['block-save-return'] ) ){
3397
+                                echo "return ". $this->options['block-edit-return'].";";
3398
+                            }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3399
+                            ?>
3400 3400
 							return content;
3401 3401
 							<?php
3402
-							}else{
3403
-							?>
3402
+                            }else{
3403
+                            ?>
3404 3404
 							var block_wrap = 'div';
3405 3405
 							if (attr.hasOwnProperty("block_wrap")) {
3406 3406
 								block_wrap = attr.block_wrap;
3407 3407
 							}
3408 3408
 							return el(block_wrap, wp.blockEditor.useBlockProps.save( {dangerouslySetInnerHTML: {__html: content}, className: align} ));
3409 3409
 							<?php
3410
-							}
3411
-							?>
3410
+                            }
3411
+                            ?>
3412 3412
 
3413 3413
 
3414 3414
 						}
@@ -3422,43 +3422,43 @@  discard block
 block discarded – undo
3422 3422
 				});
3423 3423
 			</script>
3424 3424
 			<?php
3425
-			$output = ob_get_clean();
3425
+            $output = ob_get_clean();
3426 3426
 
3427
-			/*
3427
+            /*
3428 3428
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
3429 3429
 			 */
3430 3430
 
3431
-			return str_replace( array(
3432
-				'<script>',
3433
-				'</script>'
3434
-			), '', $output );
3435
-		}
3431
+            return str_replace( array(
3432
+                '<script>',
3433
+                '</script>'
3434
+            ), '', $output );
3435
+        }
3436 3436
 
3437 3437
 
3438 3438
 
3439
-		public function block_row_start($key, $args){
3439
+        public function block_row_start($key, $args){
3440 3440
 
3441
-			// check for row
3442
-			if(!empty($args['row'])){
3441
+            // check for row
3442
+            if(!empty($args['row'])){
3443 3443
 
3444
-				if(!empty($args['row']['open'])){
3444
+                if(!empty($args['row']['open'])){
3445 3445
 
3446
-				// element require
3447
-				$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3448
-				$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3449
-				$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3450
-				$device_type_icon = '';
3451
-				if($device_type=='Desktop'){
3452
-					$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3453
-				}elseif($device_type=='Tablet'){
3454
-					$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3455
-				}elseif($device_type=='Mobile'){
3456
-					$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3457
-				}
3458
-				echo $element_require;
3459
-				echo $device_type_require;
3446
+                // element require
3447
+                $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3448
+                $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3449
+                $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3450
+                $device_type_icon = '';
3451
+                if($device_type=='Desktop'){
3452
+                    $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3453
+                }elseif($device_type=='Tablet'){
3454
+                    $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3455
+                }elseif($device_type=='Mobile'){
3456
+                    $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3457
+                }
3458
+                echo $element_require;
3459
+                echo $device_type_require;
3460 3460
 
3461
-					if(false){?><script><?php }?>
3461
+                    if(false){?><script><?php }?>
3462 3462
 						el('div', {
3463 3463
 								className: 'bsui components-base-control',
3464 3464
 							},
@@ -3471,8 +3471,8 @@  discard block
 block discarded – undo
3471 3471
 								<?php if($device_type_icon){ ?>
3472 3472
 									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)"}})
3473 3473
 								<?php
3474
-								}
3475
-								?>
3474
+                                }
3475
+                                ?>
3476 3476
 
3477 3477
 
3478 3478
 							),
@@ -3496,51 +3496,51 @@  discard block
 block discarded – undo
3496 3496
 									},
3497 3497
 
3498 3498
 					<?php
3499
-					if(false){?></script><?php }
3500
-				}elseif(!empty($args['row']['close'])){
3501
-					if(false){?><script><?php }?>
3499
+                    if(false){?></script><?php }
3500
+                }elseif(!empty($args['row']['close'])){
3501
+                    if(false){?><script><?php }?>
3502 3502
 						el(
3503 3503
 							'div',
3504 3504
 							{
3505 3505
 								className: 'col pl-0 ps-0',
3506 3506
 							},
3507 3507
 					<?php
3508
-					if(false){?></script><?php }
3509
-				}else{
3510
-					if(false){?><script><?php }?>
3508
+                    if(false){?></script><?php }
3509
+                }else{
3510
+                    if(false){?><script><?php }?>
3511 3511
 						el(
3512 3512
 							'div',
3513 3513
 							{
3514 3514
 								className: 'col pl-0 ps-0 pr-2 pe-2',
3515 3515
 							},
3516 3516
 					<?php
3517
-					if(false){?></script><?php }
3518
-				}
3517
+                    if(false){?></script><?php }
3518
+                }
3519 3519
 
3520
-			}
3520
+            }
3521 3521
 
3522
-		}
3522
+        }
3523 3523
 
3524
-		public function block_row_end($key, $args){
3524
+        public function block_row_end($key, $args){
3525 3525
 
3526
-			if(!empty($args['row'])){
3527
-				// maybe close
3528
-				if(!empty($args['row']['close'])){
3529
-					echo "))";
3530
-				}
3526
+            if(!empty($args['row'])){
3527
+                // maybe close
3528
+                if(!empty($args['row']['close'])){
3529
+                    echo "))";
3530
+                }
3531 3531
 
3532
-				echo "),";
3533
-			}
3534
-		}
3532
+                echo "),";
3533
+            }
3534
+        }
3535 3535
 
3536
-		public function block_tab_start($key, $args){
3536
+        public function block_tab_start($key, $args){
3537 3537
 
3538
-			// check for row
3539
-			if(!empty($args['tab'])){
3538
+            // check for row
3539
+            if(!empty($args['tab'])){
3540 3540
 
3541
-				if(!empty($args['tab']['tabs_open'])){
3541
+                if(!empty($args['tab']['tabs_open'])){
3542 3542
 
3543
-					if(false){?><script><?php }?>
3543
+                    if(false){?><script><?php }?>
3544 3544
 
3545 3545
 el('div',{className: 'bsui'},
3546 3546
 
@@ -3553,12 +3553,12 @@  discard block
 block discarded – undo
3553 3553
 										tabs: [
3554 3554
 
3555 3555
 					<?php
3556
-					if(false){?></script><?php }
3557
-				}
3556
+                    if(false){?></script><?php }
3557
+                }
3558 3558
 
3559
-				if(!empty($args['tab']['open'])){
3559
+                if(!empty($args['tab']['open'])){
3560 3560
 
3561
-					if(false){?><script><?php }?>
3561
+                    if(false){?><script><?php }?>
3562 3562
 							{
3563 3563
 												name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3564 3564
 												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}),
@@ -3567,93 +3567,93 @@  discard block
 block discarded – undo
3567 3567
 									className: 'components-base-control__help mb-0',
3568 3568
 									dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'}
3569 3569
 								}),<?php }
3570
-					if(false){?></script><?php }
3571
-				}
3570
+                    if(false){?></script><?php }
3571
+                }
3572 3572
 
3573
-			}
3573
+            }
3574 3574
 
3575
-		}
3575
+        }
3576 3576
 
3577
-		public function block_tab_end($key, $args){
3577
+        public function block_tab_end($key, $args){
3578 3578
 
3579
-			if(!empty($args['tab'])){
3580
-				// maybe close
3581
-				if(!empty($args['tab']['close'])){
3582
-					echo ")}, /* tab close */";
3583
-				}
3579
+            if(!empty($args['tab'])){
3580
+                // maybe close
3581
+                if(!empty($args['tab']['close'])){
3582
+                    echo ")}, /* tab close */";
3583
+                }
3584 3584
 
3585
-				if(!empty($args['tab']['tabs_close'])){
3586
-					if(false){?><script><?php }?>
3585
+                if(!empty($args['tab']['tabs_close'])){
3586
+                    if(false){?><script><?php }?>
3587 3587
 						]}, ( tab ) => {
3588 3588
 								return tab.content;
3589 3589
 							}
3590 3590
 						)), /* tabs close */
3591 3591
 					<?php if(false){ ?></script><?php }
3592
-				}
3593
-			}
3594
-		}
3592
+                }
3593
+            }
3594
+        }
3595 3595
 
3596
-		public function build_block_arguments( $key, $args ) {
3597
-			$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3598
-			$options           = '';
3599
-			$extra             = '';
3600
-			$require           = '';
3601
-			$inside_elements   = '';
3602
-			$after_elements	   = '';
3603
-
3604
-			// `content` is a protected and special argument
3605
-			if ( $key == 'content' ) {
3606
-				return;
3607
-			}
3596
+        public function build_block_arguments( $key, $args ) {
3597
+            $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3598
+            $options           = '';
3599
+            $extra             = '';
3600
+            $require           = '';
3601
+            $inside_elements   = '';
3602
+            $after_elements	   = '';
3603
+
3604
+            // `content` is a protected and special argument
3605
+            if ( $key == 'content' ) {
3606
+                return;
3607
+            }
3608 3608
 
3609
-			$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3610
-			$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3611
-			$device_type_icon = '';
3612
-			if($device_type=='Desktop'){
3613
-				$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3614
-			}elseif($device_type=='Tablet'){
3615
-				$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3616
-			}elseif($device_type=='Mobile'){
3617
-				$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3618
-			}
3609
+            $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3610
+            $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3611
+            $device_type_icon = '';
3612
+            if($device_type=='Desktop'){
3613
+                $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3614
+            }elseif($device_type=='Tablet'){
3615
+                $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3616
+            }elseif($device_type=='Mobile'){
3617
+                $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3618
+            }
3619 3619
 
3620
-			// icon
3621
-			$icon = '';
3622
-			if( !empty( $args['icon'] ) ){
3623
-				$icon .= "el('div', {";
3624
-									$icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3625
-									$icon .= "className: 'text-center',";
3626
-									$icon .= "title: '".addslashes( $args['title'] )."',";
3627
-								$icon .= "}),";
3628
-
3629
-				// blank title as its added to the icon.
3630
-				$args['title'] = '';
3631
-			}
3620
+            // icon
3621
+            $icon = '';
3622
+            if( !empty( $args['icon'] ) ){
3623
+                $icon .= "el('div', {";
3624
+                                    $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3625
+                                    $icon .= "className: 'text-center',";
3626
+                                    $icon .= "title: '".addslashes( $args['title'] )."',";
3627
+                                $icon .= "}),";
3628
+
3629
+                // blank title as its added to the icon.
3630
+                $args['title'] = '';
3631
+            }
3632 3632
 
3633
-			// require advanced
3634
-			$require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3633
+            // require advanced
3634
+            $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3635 3635
 
3636
-			// element require
3637
-			$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3636
+            // element require
3637
+            $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3638 3638
 
3639 3639
 
3640
-			$onchange  = "props.setAttributes({ $key: $key } )";
3641
-			$onchangecomplete  = "";
3642
-			$value     = "props.attributes.$key";
3643
-			$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3644
-			if ( in_array( $args['type'], $text_type ) ) {
3645
-				$type = 'TextControl';
3646
-				// Save numbers as numbers and not strings
3647
-				if ( $args['type'] == 'number' ) {
3648
-					$onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3649
-				}
3640
+            $onchange  = "props.setAttributes({ $key: $key } )";
3641
+            $onchangecomplete  = "";
3642
+            $value     = "props.attributes.$key";
3643
+            $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3644
+            if ( in_array( $args['type'], $text_type ) ) {
3645
+                $type = 'TextControl';
3646
+                // Save numbers as numbers and not strings
3647
+                if ( $args['type'] == 'number' ) {
3648
+                    $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3649
+                }
3650 3650
 
3651
-				if (substr($key, 0, 9 ) === 'metadata_') {
3652
-					$real_key = str_replace('metadata_','', $key );
3653
-					$onchange = "props.setAttributes({ metadata: { $real_key: $key } } )";
3654
-					$value     = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3655
-				}
3656
-			}
3651
+                if (substr($key, 0, 9 ) === 'metadata_') {
3652
+                    $real_key = str_replace('metadata_','', $key );
3653
+                    $onchange = "props.setAttributes({ metadata: { $real_key: $key } } )";
3654
+                    $value     = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3655
+                }
3656
+            }
3657 3657
 //			else if ( $args['type'] == 'popup' ) {
3658 3658
 //				$type = 'TextControl';
3659 3659
 //				$args['type'] == 'text';
@@ -3671,21 +3671,21 @@  discard block
 block discarded – undo
3671 3671
 //
3672 3672
 //				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3673 3673
 //			}
3674
-			else if ( $args['type'] == 'styleid' ) {
3675
-				$type = 'TextControl';
3676
-				$args['type'] == 'text';
3677
-				// Save numbers as numbers and not strings
3678
-				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3679
-			}else if ( $args['type'] == 'notice' ) {
3680
-
3681
-				$notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3682
-				$notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
3683
-
3684
-				$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'}}))),";
3685
-				echo $notice_message ? $element_require . $notice : '';
3686
-				return;
3687
-			}
3688
-			/*
3674
+            else if ( $args['type'] == 'styleid' ) {
3675
+                $type = 'TextControl';
3676
+                $args['type'] == 'text';
3677
+                // Save numbers as numbers and not strings
3678
+                $value     = "props.attributes.$key ? props.attributes.$key : ''";
3679
+            }else if ( $args['type'] == 'notice' ) {
3680
+
3681
+                $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3682
+                $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
3683
+
3684
+                $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'}}))),";
3685
+                echo $notice_message ? $element_require . $notice : '';
3686
+                return;
3687
+            }
3688
+            /*
3689 3689
 			 * https://www.wptricks.com/question/set-current-tab-on-a-gutenberg-tabpanel-component-from-outside-that-component/ es5 layout
3690 3690
 						elseif($args['type']=='tabs'){
3691 3691
 							?>
@@ -3738,22 +3738,22 @@  discard block
 block discarded – undo
3738 3738
 							return;
3739 3739
 						}
3740 3740
 */
3741
-			elseif ( $args['type'] == 'color' ) {
3742
-				$type = 'ColorPicker';
3743
-				$onchange = "";
3744
-				$extra = "color: $value,";
3745
-				if(!empty($args['disable_alpha'])){
3746
-					$extra .= "disableAlpha: true,";
3747
-				}
3748
-				$onchangecomplete = "onChangeComplete: function($key) {
3741
+            elseif ( $args['type'] == 'color' ) {
3742
+                $type = 'ColorPicker';
3743
+                $onchange = "";
3744
+                $extra = "color: $value,";
3745
+                if(!empty($args['disable_alpha'])){
3746
+                    $extra .= "disableAlpha: true,";
3747
+                }
3748
+                $onchangecomplete = "onChangeComplete: function($key) {
3749 3749
 				value =  $key.rgb.a && $key.rgb.a < 1 ? \"rgba(\"+$key.rgb.r+\",\"+$key.rgb.g+\",\"+$key.rgb.b+\",\"+$key.rgb.a+\")\" : $key.hex;
3750 3750
 						props.setAttributes({
3751 3751
 							$key: value
3752 3752
 						});
3753 3753
 					},";
3754
-			}elseif ( $args['type'] == 'gradient' ) {
3755
-				$type = 'GradientPicker';
3756
-				$extra .= "gradients: [{
3754
+            }elseif ( $args['type'] == 'gradient' ) {
3755
+                $type = 'GradientPicker';
3756
+                $extra .= "gradients: [{
3757 3757
 			name: 'Vivid cyan blue to vivid purple',
3758 3758
 			gradient:
3759 3759
 				'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
@@ -3790,10 +3790,10 @@  discard block
 block discarded – undo
3790 3790
 			slug: 'cool-to-warm-spectrum',
3791 3791
 		}],";
3792 3792
 
3793
-			}elseif ( $args['type'] == 'image' ) {
3793
+            }elseif ( $args['type'] == 'image' ) {
3794 3794
 //                print_r($args);
3795 3795
 
3796
-				$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,{
3796
+                $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,{
3797 3797
 							url:  props.attributes.{$key}_use_featured === true ? 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8+CjxzdmcgYmFzZVByb2ZpbGU9InRpbnkiIGhlaWdodD0iNDAwIiB2ZXJzaW9uPSIxLjIiIHdpZHRoPSI0MDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6ZXY9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEveG1sLWV2ZW50cyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxkZWZzIC8+PHJlY3QgZmlsbD0iI2QzZDNkMyIgaGVpZ2h0PSI0MDAiIHdpZHRoPSI0MDAiIHg9IjAiIHk9IjAiIC8+PGxpbmUgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxMCIgeDE9IjAiIHgyPSI0MDAiIHkxPSIwIiB5Mj0iNDAwIiAvPjxsaW5lIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMTAiIHgxPSIwIiB4Mj0iNDAwIiB5MT0iNDAwIiB5Mj0iMCIgLz48cmVjdCBmaWxsPSIjZDNkM2QzIiBoZWlnaHQ9IjUwIiB3aWR0aD0iMjE4LjAiIHg9IjkxLjAiIHk9IjE3NS4wIiAvPjx0ZXh0IGZpbGw9IndoaXRlIiBmb250LXNpemU9IjMwIiBmb250LXdlaWdodD0iYm9sZCIgdGV4dC1hbmNob3I9Im1pZGRsZSIgeD0iMjAwLjAiIHk9IjIwNy41Ij5QTEFDRUhPTERFUjwvdGV4dD48L3N2Zz4='  : props.attributes.$key,
3798 3798
 							value: props.attributes.{$key}_xy.x !== undefined && props.attributes.{$key}_xy.x >= 0 ? props.attributes.{$key}_xy  : {x: 0.5,y: 0.5,},
3799 3799
 //                            value: props.attributes.{$key}_xy,
@@ -3814,16 +3814,16 @@  discard block
 block discarded – undo
3814 3814
 						}), ";
3815 3815
 
3816 3816
 
3817
-				$value = '""';
3818
-				$type = 'MediaUpload';
3819
-				$extra .= "onSelect: function(media){
3817
+                $value = '""';
3818
+                $type = 'MediaUpload';
3819
+                $extra .= "onSelect: function(media){
3820 3820
 					  return props.setAttributes({
3821 3821
 						  $key: media.url,
3822 3822
 						  {$key}_id: media.id
3823 3823
 						});
3824 3824
 					  },";
3825
-				   $extra .= "type: 'image',";
3826
-				   $extra .= "render: function (obj) {
3825
+                    $extra .= "type: 'image',";
3826
+                    $extra .= "render: function (obj) {
3827 3827
 						return el( 'div',{},
3828 3828
 						( !props.attributes.$key && !props.attributes.{$key}_use_featured ) && el( wp.components.Button, {
3829 3829
 						  className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
@@ -3849,11 +3849,11 @@  discard block
 block discarded – undo
3849 3849
 
3850 3850
 
3851 3851
 					  }";
3852
-				$onchange = "";
3852
+                $onchange = "";
3853 3853
 
3854
-				//$inside_elements = ",el('div',{},'file upload')";
3855
-			} else if ( $args['type'] == 'images' ) {
3856
-				$img_preview = "props.attributes.$key && (function() {
3854
+                //$inside_elements = ",el('div',{},'file upload')";
3855
+            } else if ( $args['type'] == 'images' ) {
3856
+                $img_preview = "props.attributes.$key && (function() {
3857 3857
 	let uploads = JSON.parse('['+props.attributes.$key+']');
3858 3858
 	let images = [];
3859 3859
 	uploads.map((upload, index) => (
@@ -3880,9 +3880,9 @@  discard block
 block discarded – undo
3880 3880
 })(),";
3881 3881
 
3882 3882
 
3883
-				$value = '""';
3884
-				$type = 'MediaUpload';
3885
-				$extra .= "onSelect: function(media){
3883
+                $value = '""';
3884
+                $type = 'MediaUpload';
3885
+                $extra .= "onSelect: function(media){
3886 3886
 	let slim_images = props.attributes.$key ? JSON.parse('['+props.attributes.$key+']') : [];
3887 3887
 	if(media.length){
3888 3888
 		for (var i=0; i < media.length; i++) {
@@ -3895,9 +3895,9 @@  discard block
 block discarded – undo
3895 3895
 	}
3896 3896
 	return props.setAttributes({ $key: slimImagesV});
3897 3897
 },";
3898
-				$extra .= "type: 'image',";
3899
-				$extra .= "multiple: true,";
3900
-				$extra .= "render: function (obj) {
3898
+                $extra .= "type: 'image',";
3899
+                $extra .= "multiple: true,";
3900
+                $extra .= "render: function (obj) {
3901 3901
 	/* Init the sort */
3902 3902
 	enableDragSort('sd-sortable');
3903 3903
 	return el( 'div',{},
@@ -3924,40 +3924,40 @@  discard block
 block discarded – undo
3924 3924
 		)
3925 3925
 	)
3926 3926
 }";
3927
-				$onchange = "";
3927
+                $onchange = "";
3928 3928
 
3929
-				//$inside_elements = ",el('div',{},'file upload')";
3930
-			}
3931
-			elseif ( $args['type'] == 'checkbox' ) {
3932
-				$type = 'CheckboxControl';
3933
-				$extra .= "checked: props.attributes.$key,";
3934
-				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3935
-			} elseif ( $args['type'] == 'textarea' ) {
3936
-				$type = 'TextareaControl';
3937
-
3938
-			} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3939
-				$type = 'SelectControl';
3940
-
3941
-				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3942
-					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3943
-				}elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3944
-					$options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3945
-				}else {
3946
-
3947
-					if ( ! empty( $args['options'] ) ) {
3948
-						$options .= "options: [";
3949
-						foreach ( $args['options'] as $option_val => $option_label ) {
3950
-							$options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },";
3951
-						}
3952
-						$options .= "],";
3953
-					}
3954
-				}
3955
-				if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3956
-					$extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3957
-				}
3929
+                //$inside_elements = ",el('div',{},'file upload')";
3930
+            }
3931
+            elseif ( $args['type'] == 'checkbox' ) {
3932
+                $type = 'CheckboxControl';
3933
+                $extra .= "checked: props.attributes.$key,";
3934
+                $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3935
+            } elseif ( $args['type'] == 'textarea' ) {
3936
+                $type = 'TextareaControl';
3937
+
3938
+            } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3939
+                $type = 'SelectControl';
3940
+
3941
+                if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3942
+                    $options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3943
+                }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3944
+                    $options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3945
+                }else {
3946
+
3947
+                    if ( ! empty( $args['options'] ) ) {
3948
+                        $options .= "options: [";
3949
+                        foreach ( $args['options'] as $option_val => $option_label ) {
3950
+                            $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },";
3951
+                        }
3952
+                        $options .= "],";
3953
+                    }
3954
+                }
3955
+                if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3956
+                    $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3957
+                }
3958 3958
 
3959
-				if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3960
-					$after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3959
+                if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3960
+                    $after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3961 3961
 									  className: 'components-button components-circular-option-picker__clear is-secondary is-small',
3962 3962
 									  style: {margin:'-8px 0 8px 0',display: 'block'},
3963 3963
 									  onClick: function(){
@@ -3968,8 +3968,8 @@  discard block
 block discarded – undo
3968 3968
 									},
3969 3969
 									'Clear'
3970 3970
 							),";
3971
-				}
3972
-			} elseif ( $args['type'] == 'tagselect' ) {
3971
+                }
3972
+            } elseif ( $args['type'] == 'tagselect' ) {
3973 3973
 //				$type = 'FormTokenField';
3974 3974
 //
3975 3975
 //				if ( ! empty( $args['options'] ) ) {
@@ -4004,20 +4004,20 @@  discard block
 block discarded – undo
4004 4004
 //				$value     = "[]";
4005 4005
 //				$extra .= ' __experimentalExpandOnFocus: true,';
4006 4006
 
4007
-			} else if ( $args['type'] == 'alignment' ) {
4008
-				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
4009
-			} else if ( $args['type'] == 'margins' ) {
4010
-
4011
-			} else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) {
4012
-				$type = 'TextControl';
4013
-				$value = "(props.attributes.$key ? props.attributes.$key : '')";
4014
-				$args['type'] = 'text';
4015
-				$options .= 'disabled:true,';
4016
-				$bsvc_title = esc_attr( addslashes( $args['title'] ) );
4017
-				$bsvc_body = $this->block_visibility_fields( $args );
4018
-				// @TODO reset button
4019
-				$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>';
4020
-				$after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, {
4007
+            } else if ( $args['type'] == 'alignment' ) {
4008
+                $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
4009
+            } else if ( $args['type'] == 'margins' ) {
4010
+
4011
+            } else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) {
4012
+                $type = 'TextControl';
4013
+                $value = "(props.attributes.$key ? props.attributes.$key : '')";
4014
+                $args['type'] = 'text';
4015
+                $options .= 'disabled:true,';
4016
+                $bsvc_title = esc_attr( addslashes( $args['title'] ) );
4017
+                $bsvc_body = $this->block_visibility_fields( $args );
4018
+                // @TODO reset button
4019
+                $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>';
4020
+                $after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, {
4021 4021
 						className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
4022 4022
 						onClick: function() {
4023 4023
 							var sValue = props.attributes." . $key . ";
@@ -4043,39 +4043,39 @@  discard block
 block discarded – undo
4043 4043
 					},
4044 4044
 					'" . addslashes( ! empty( $args['button_title'] ) ? $args['button_title'] : $args['title'] ) . "'
4045 4045
 				) ),";
4046
-			} else {
4047
-				return;// if we have not implemented the control then don't break the JS.
4048
-			}
4046
+            } else {
4047
+                return;// if we have not implemented the control then don't break the JS.
4048
+            }
4049 4049
 
4050
-			// color input does not show the labels so we add them
4051
-			if($args['type']=='color'){
4052
-				// add show only if advanced
4053
-				echo $require_advanced;
4054
-				// add setting require if defined
4055
-				echo $element_require;
4056
-				echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
4057
-			}
4050
+            // color input does not show the labels so we add them
4051
+            if($args['type']=='color'){
4052
+                // add show only if advanced
4053
+                echo $require_advanced;
4054
+                // add setting require if defined
4055
+                echo $element_require;
4056
+                echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
4057
+            }
4058 4058
 
4059
-			// add show only if advanced
4060
-			echo $require_advanced;
4061
-			// add setting require if defined
4062
-			echo $element_require;
4063
-			echo $device_type_require;
4059
+            // add show only if advanced
4060
+            echo $require_advanced;
4061
+            // add setting require if defined
4062
+            echo $element_require;
4063
+            echo $device_type_require;
4064 4064
 
4065
-			// icon
4066
-			echo $icon;
4067
-			?>
4065
+            // icon
4066
+            echo $icon;
4067
+            ?>
4068 4068
 			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type  : "wp.components.".$type; ?>, {
4069 4069
 			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
4070
-			} else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>,
4070
+            } else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>,
4071 4071
 			help: <?php echo ( isset( $args['desc'] ) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim( wp_kses_post( addslashes( $args['desc'] ) ) ) . "'}})" : "''" ); ?>,
4072 4072
 			value: <?php echo $value; ?>,
4073 4073
 			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
4074
-				echo "type: '" . addslashes( $args['type'] ) . "',";
4075
-			} ?>
4074
+                echo "type: '" . addslashes( $args['type'] ) . "',";
4075
+            } ?>
4076 4076
 			<?php if ( ! empty( $args['placeholder'] ) ) {
4077
-				echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',";
4078
-			} ?>
4077
+                echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',";
4078
+            } ?>
4079 4079
 			<?php echo $options; ?>
4080 4080
 			<?php echo $extra; ?>
4081 4081
 			<?php echo $custom_attributes; ?>
@@ -4087,1361 +4087,1361 @@  discard block
 block discarded – undo
4087 4087
 			<?php } ?>
4088 4088
 		} <?php echo $inside_elements; ?> ),
4089 4089
 			<?php
4090
-			echo $after_elements;
4091
-		}
4090
+            echo $after_elements;
4091
+        }
4092 4092
 
4093
-		/**
4094
-		 * Convert an array of attributes to block string.
4095
-		 *
4096
-		 * @param $custom_attributes
4097
-		 *
4098
-		 * @return string
4099
-		 *@todo there is prob a faster way to do this, also we could add some validation here.
4100
-		 *
4101
-		 */
4102
-		public function array_to_attributes( $custom_attributes, $html = false ) {
4103
-			$attributes = '';
4104
-			if ( ! empty( $custom_attributes ) ) {
4105
-
4106
-				foreach ( $custom_attributes as $key => $val ) {
4107
-					if(is_array($val)){
4108
-						$attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4109
-					}else{
4110
-						$attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4111
-					}
4112
-				}
4093
+        /**
4094
+         * Convert an array of attributes to block string.
4095
+         *
4096
+         * @param $custom_attributes
4097
+         *
4098
+         * @return string
4099
+         *@todo there is prob a faster way to do this, also we could add some validation here.
4100
+         *
4101
+         */
4102
+        public function array_to_attributes( $custom_attributes, $html = false ) {
4103
+            $attributes = '';
4104
+            if ( ! empty( $custom_attributes ) ) {
4105
+
4106
+                foreach ( $custom_attributes as $key => $val ) {
4107
+                    if(is_array($val)){
4108
+                        $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4109
+                    }else{
4110
+                        $attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4111
+                    }
4112
+                }
4113 4113
 
4114
-			}
4114
+            }
4115 4115
 
4116
-			return $attributes;
4117
-		}
4116
+            return $attributes;
4117
+        }
4118 4118
 
4119 4119
 
4120 4120
 
4121
-		/**
4122
-		 * A self looping function to create the output for JS block elements.
4123
-		 *
4124
-		 * This is what is output in the WP Editor visual view.
4125
-		 *
4126
-		 * @param $args
4127
-		 */
4128
-		public function block_element( $args, $save = false ) {
4121
+        /**
4122
+         * A self looping function to create the output for JS block elements.
4123
+         *
4124
+         * This is what is output in the WP Editor visual view.
4125
+         *
4126
+         * @param $args
4127
+         */
4128
+        public function block_element( $args, $save = false ) {
4129 4129
 
4130 4130
 //            print_r($args);echo '###';exit;
4131 4131
 
4132
-			if ( ! empty( $args ) ) {
4133
-				foreach ( $args as $element => $new_args ) {
4132
+            if ( ! empty( $args ) ) {
4133
+                foreach ( $args as $element => $new_args ) {
4134 4134
 
4135
-					if ( is_array( $new_args ) ) { // its an element
4135
+                    if ( is_array( $new_args ) ) { // its an element
4136 4136
 
4137 4137
 
4138
-						if ( isset( $new_args['element'] ) ) {
4138
+                        if ( isset( $new_args['element'] ) ) {
4139 4139
 
4140
-							if ( isset( $new_args['element_require'] ) ) {
4141
-								echo str_replace( array(
4142
-										"'+",
4143
-										"+'"
4144
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
4145
-								unset( $new_args['element_require'] );
4146
-							}
4140
+                            if ( isset( $new_args['element_require'] ) ) {
4141
+                                echo str_replace( array(
4142
+                                        "'+",
4143
+                                        "+'"
4144
+                                    ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
4145
+                                unset( $new_args['element_require'] );
4146
+                            }
4147 4147
 
4148
-							if($new_args['element']=='InnerBlocks'){
4149
-								echo "\n el( InnerBlocks, {";
4150
-							}elseif($new_args['element']=='innerBlocksProps'){
4151
-								$element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4152
-							  //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4148
+                            if($new_args['element']=='InnerBlocks'){
4149
+                                echo "\n el( InnerBlocks, {";
4150
+                            }elseif($new_args['element']=='innerBlocksProps'){
4151
+                                $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4152
+                                //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4153 4153
 //                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4154
-								echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4155
-								echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
4156
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4157
-
4158
-								echo "} ), {";
4159
-								echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
4160
-							//    echo '###';
4161
-
4162
-							  //  echo '###';
4163
-							}elseif($new_args['element']=='BlocksProps'){
4164
-
4165
-								if ( isset($new_args['if_inner_element']) ) {
4166
-									$element = $new_args['if_inner_element'];
4167
-								}else {
4168
-									$element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4169
-								}
4170
-
4171
-								unset($new_args['inner_element']);
4172
-								echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
4173
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4174
-
4175
-
4176
-							   // echo "} ),";
4177
-
4178
-							}else{
4179
-								echo "\n el( '" . $new_args['element'] . "', {";
4180
-							}
4181
-
4182
-
4183
-							// get the attributes
4184
-							foreach ( $new_args as $new_key => $new_value ) {
4185
-
4186
-
4187
-								if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
4188
-									// do nothing
4189
-								} else {
4190
-									echo $this->block_element( array( $new_key => $new_value ),$save );
4191
-								}
4192
-							}
4193
-
4194
-							echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
4195
-
4196
-							// get the content
4197
-							$first_item = 0;
4198
-							foreach ( $new_args as $new_key => $new_value ) {
4199
-								if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
4200
-
4201
-									if ( $new_key === 'content' ) {
4202
-										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4203
-									}else if ( $new_key === 'if_content' ) {
4204
-										echo  $this->block_props_replace(  $new_value  );
4205
-									}
4206
-
4207
-									if ( is_array( $new_value ) ) {
4208
-
4209
-										if ( isset( $new_value['element_require'] ) ) {
4210
-											echo str_replace( array(
4211
-													"'+",
4212
-													"+'"
4213
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
4214
-											unset( $new_value['element_require'] );
4215
-										}
4216
-
4217
-										if ( isset( $new_value['element_repeat'] ) ) {
4218
-											$x = 1;
4219
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
4220
-												$this->block_element( array( '' => $new_value ),$save );
4221
-												$x ++;
4222
-											}
4223
-										} else {
4224
-											$this->block_element( array( '' => $new_value ),$save );
4225
-										}
4226
-									}
4227
-									$first_item ++;
4228
-								}
4229
-							}
4230
-
4231
-							if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4232
-								echo "))";// end content
4233
-							}else{
4234
-								echo ")";// end content
4235
-							}
4236
-
4237
-
4238
-							echo ", \n";
4239
-
4240
-						}
4241
-					} else {
4242
-
4243
-						if ( substr( $element, 0, 3 ) === "if_" ) {
4244
-							$extra = '';
4245
-							if( strpos($new_args, '[%WrapClass%]') !== false ){
4246
-								$new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
4247
-								$new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
4248
-							}
4249
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
4250
-						} elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
4251
-							$new_args = str_replace('[%WrapStyle%]','',$new_args);
4252
-							echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
4154
+                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4155
+                                echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
4156
+                                echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4157
+
4158
+                                echo "} ), {";
4159
+                                echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
4160
+                            //    echo '###';
4161
+
4162
+                                //  echo '###';
4163
+                            }elseif($new_args['element']=='BlocksProps'){
4164
+
4165
+                                if ( isset($new_args['if_inner_element']) ) {
4166
+                                    $element = $new_args['if_inner_element'];
4167
+                                }else {
4168
+                                    $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4169
+                                }
4170
+
4171
+                                unset($new_args['inner_element']);
4172
+                                echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
4173
+                                echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4174
+
4175
+
4176
+                                // echo "} ),";
4177
+
4178
+                            }else{
4179
+                                echo "\n el( '" . $new_args['element'] . "', {";
4180
+                            }
4181
+
4182
+
4183
+                            // get the attributes
4184
+                            foreach ( $new_args as $new_key => $new_value ) {
4185
+
4186
+
4187
+                                if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
4188
+                                    // do nothing
4189
+                                } else {
4190
+                                    echo $this->block_element( array( $new_key => $new_value ),$save );
4191
+                                }
4192
+                            }
4193
+
4194
+                            echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
4195
+
4196
+                            // get the content
4197
+                            $first_item = 0;
4198
+                            foreach ( $new_args as $new_key => $new_value ) {
4199
+                                if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
4200
+
4201
+                                    if ( $new_key === 'content' ) {
4202
+                                        echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4203
+                                    }else if ( $new_key === 'if_content' ) {
4204
+                                        echo  $this->block_props_replace(  $new_value  );
4205
+                                    }
4206
+
4207
+                                    if ( is_array( $new_value ) ) {
4208
+
4209
+                                        if ( isset( $new_value['element_require'] ) ) {
4210
+                                            echo str_replace( array(
4211
+                                                    "'+",
4212
+                                                    "+'"
4213
+                                                ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
4214
+                                            unset( $new_value['element_require'] );
4215
+                                        }
4216
+
4217
+                                        if ( isset( $new_value['element_repeat'] ) ) {
4218
+                                            $x = 1;
4219
+                                            while ( $x <= absint( $new_value['element_repeat'] ) ) {
4220
+                                                $this->block_element( array( '' => $new_value ),$save );
4221
+                                                $x ++;
4222
+                                            }
4223
+                                        } else {
4224
+                                            $this->block_element( array( '' => $new_value ),$save );
4225
+                                        }
4226
+                                    }
4227
+                                    $first_item ++;
4228
+                                }
4229
+                            }
4230
+
4231
+                            if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4232
+                                echo "))";// end content
4233
+                            }else{
4234
+                                echo ")";// end content
4235
+                            }
4236
+
4237
+
4238
+                            echo ", \n";
4239
+
4240
+                        }
4241
+                    } else {
4242
+
4243
+                        if ( substr( $element, 0, 3 ) === "if_" ) {
4244
+                            $extra = '';
4245
+                            if( strpos($new_args, '[%WrapClass%]') !== false ){
4246
+                                $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
4247
+                                $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
4248
+                            }
4249
+                            echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
4250
+                        } elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
4251
+                            $new_args = str_replace('[%WrapStyle%]','',$new_args);
4252
+                            echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
4253 4253
 //                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4254
-						} elseif ( $element == 'style' ) {
4255
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4256
-						} elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
4257
-							$new_args = str_replace('[%WrapClass%]','',$new_args);
4258
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
4259
-						} elseif ( $element == 'template' && $new_args ) {
4260
-							echo $element . ": $new_args,";
4261
-						} else {
4262
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
4263
-						}
4264
-
4265
-					}
4266
-				}
4267
-			}
4268
-		}
4254
+                        } elseif ( $element == 'style' ) {
4255
+                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4256
+                        } elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
4257
+                            $new_args = str_replace('[%WrapClass%]','',$new_args);
4258
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
4259
+                        } elseif ( $element == 'template' && $new_args ) {
4260
+                            echo $element . ": $new_args,";
4261
+                        } else {
4262
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
4263
+                        }
4264
+
4265
+                    }
4266
+                }
4267
+            }
4268
+        }
4269 4269
 
4270
-		/**
4271
-		 * Replace block attributes placeholders with the proper naming.
4272
-		 *
4273
-		 * @param $string
4274
-		 *
4275
-		 * @return mixed
4276
-		 */
4277
-		public function block_props_replace( $string, $no_wrap = false ) {
4278
-			if ( $no_wrap ) {
4279
-				$string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string );
4280
-			} else {
4281
-				$string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string );
4282
-			}
4270
+        /**
4271
+         * Replace block attributes placeholders with the proper naming.
4272
+         *
4273
+         * @param $string
4274
+         *
4275
+         * @return mixed
4276
+         */
4277
+        public function block_props_replace( $string, $no_wrap = false ) {
4278
+            if ( $no_wrap ) {
4279
+                $string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string );
4280
+            } else {
4281
+                $string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string );
4282
+            }
4283 4283
 
4284
-			return $string;
4285
-		}
4284
+            return $string;
4285
+        }
4286 4286
 
4287
-		/**
4288
-		 * Outputs the content of the widget
4289
-		 *
4290
-		 * @param array $args
4291
-		 * @param array $instance
4292
-		 */
4293
-		public function widget( $args, $instance ) {
4294
-			if ( ! is_array( $args ) ) {
4295
-				$args = array();
4296
-			}
4287
+        /**
4288
+         * Outputs the content of the widget
4289
+         *
4290
+         * @param array $args
4291
+         * @param array $instance
4292
+         */
4293
+        public function widget( $args, $instance ) {
4294
+            if ( ! is_array( $args ) ) {
4295
+                $args = array();
4296
+            }
4297 4297
 
4298
-			// Get the filtered values
4299
-			$argument_values = $this->argument_values( $instance );
4300
-			$argument_values = $this->string_to_bool( $argument_values );
4301
-			$output          = $this->output( $argument_values, $args );
4298
+            // Get the filtered values
4299
+            $argument_values = $this->argument_values( $instance );
4300
+            $argument_values = $this->string_to_bool( $argument_values );
4301
+            $output          = $this->output( $argument_values, $args );
4302 4302
 
4303
-			$no_wrap = false;
4304
-			if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
4305
-				$no_wrap = true;
4306
-			}
4303
+            $no_wrap = false;
4304
+            if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
4305
+                $no_wrap = true;
4306
+            }
4307 4307
 
4308
-			ob_start();
4309
-			if ( $output && ! $no_wrap ) {
4308
+            ob_start();
4309
+            if ( $output && ! $no_wrap ) {
4310 4310
 
4311
-				$class_original = $this->options['widget_ops']['classname'];
4312
-				$class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
4311
+                $class_original = $this->options['widget_ops']['classname'];
4312
+                $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
4313 4313
 
4314
-				// Before widget
4315
-				$before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : '';
4316
-				$before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget;
4317
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
4318
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
4314
+                // Before widget
4315
+                $before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : '';
4316
+                $before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget;
4317
+                $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
4318
+                $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
4319 4319
 
4320
-				// After widget
4321
-				$after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : '';
4322
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
4323
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
4320
+                // After widget
4321
+                $after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : '';
4322
+                $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
4323
+                $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
4324 4324
 
4325
-				echo $before_widget;
4326
-				// elementor strips the widget wrapping div so we check for and add it back if needed
4327
-				if ( $this->is_elementor_widget_output() ) {
4328
-					// Filter class & attrs for elementor widget output.
4329
-					$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
4330
-					$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
4325
+                echo $before_widget;
4326
+                // elementor strips the widget wrapping div so we check for and add it back if needed
4327
+                if ( $this->is_elementor_widget_output() ) {
4328
+                    // Filter class & attrs for elementor widget output.
4329
+                    $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
4330
+                    $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
4331 4331
 
4332
-					$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
4333
-					$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
4332
+                    $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
4333
+                    $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
4334 4334
 
4335
-					echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
4336
-				}
4337
-				echo $this->output_title( $args, $instance );
4338
-				echo $output;
4339
-				if ( $this->is_elementor_widget_output() ) {
4340
-					echo "</span>";
4341
-				}
4342
-				echo $after_widget;
4343
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
4344
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
4345
-				echo $output;
4346
-			} elseif ( $output && $no_wrap ) {
4347
-				echo $output;
4348
-			}
4349
-			$output = ob_get_clean();
4335
+                    echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
4336
+                }
4337
+                echo $this->output_title( $args, $instance );
4338
+                echo $output;
4339
+                if ( $this->is_elementor_widget_output() ) {
4340
+                    echo "</span>";
4341
+                }
4342
+                echo $after_widget;
4343
+            } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
4344
+                $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
4345
+                echo $output;
4346
+            } elseif ( $output && $no_wrap ) {
4347
+                echo $output;
4348
+            }
4349
+            $output = ob_get_clean();
4350 4350
 
4351
-			$output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
4351
+            $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
4352 4352
 
4353
-			echo $output;
4354
-		}
4353
+            echo $output;
4354
+        }
4355 4355
 
4356
-		/**
4357
-		 * Tests if the current output is inside a elementor container.
4358
-		 *
4359
-		 * @return bool
4360
-		 *@since 1.0.4
4361
-		 */
4362
-		public function is_elementor_widget_output() {
4363
-			$result = false;
4364
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
4365
-				$result = true;
4366
-			}
4356
+        /**
4357
+         * Tests if the current output is inside a elementor container.
4358
+         *
4359
+         * @return bool
4360
+         *@since 1.0.4
4361
+         */
4362
+        public function is_elementor_widget_output() {
4363
+            $result = false;
4364
+            if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
4365
+                $result = true;
4366
+            }
4367 4367
 
4368
-			return $result;
4369
-		}
4368
+            return $result;
4369
+        }
4370 4370
 
4371
-		/**
4372
-		 * Tests if the current output is inside a elementor preview.
4373
-		 *
4374
-		 * @return bool
4375
-		 *@since 1.0.4
4376
-		 */
4377
-		public function is_elementor_preview() {
4378
-			$result = false;
4379
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
4380
-				$result = true;
4381
-			}
4371
+        /**
4372
+         * Tests if the current output is inside a elementor preview.
4373
+         *
4374
+         * @return bool
4375
+         *@since 1.0.4
4376
+         */
4377
+        public function is_elementor_preview() {
4378
+            $result = false;
4379
+            if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
4380
+                $result = true;
4381
+            }
4382 4382
 
4383
-			return $result;
4384
-		}
4383
+            return $result;
4384
+        }
4385 4385
 
4386
-		/**
4387
-		 * Tests if the current output is inside a Divi preview.
4388
-		 *
4389
-		 * @return bool
4390
-		 *@since 1.0.6
4391
-		 */
4392
-		public function is_divi_preview() {
4393
-			$result = false;
4394
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
4395
-				$result = true;
4396
-			}
4386
+        /**
4387
+         * Tests if the current output is inside a Divi preview.
4388
+         *
4389
+         * @return bool
4390
+         *@since 1.0.6
4391
+         */
4392
+        public function is_divi_preview() {
4393
+            $result = false;
4394
+            if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
4395
+                $result = true;
4396
+            }
4397 4397
 
4398
-			return $result;
4399
-		}
4398
+            return $result;
4399
+        }
4400 4400
 
4401
-		/**
4402
-		 * Tests if the current output is inside a Beaver builder preview.
4403
-		 *
4404
-		 * @return bool
4405
-		 *@since 1.0.6
4406
-		 */
4407
-		public function is_beaver_preview() {
4408
-			$result = false;
4409
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
4410
-				$result = true;
4411
-			}
4401
+        /**
4402
+         * Tests if the current output is inside a Beaver builder preview.
4403
+         *
4404
+         * @return bool
4405
+         *@since 1.0.6
4406
+         */
4407
+        public function is_beaver_preview() {
4408
+            $result = false;
4409
+            if ( isset( $_REQUEST['fl_builder'] ) ) {
4410
+                $result = true;
4411
+            }
4412 4412
 
4413
-			return $result;
4414
-		}
4413
+            return $result;
4414
+        }
4415 4415
 
4416
-		/**
4417
-		 * Tests if the current output is inside a siteorigin builder preview.
4418
-		 *
4419
-		 * @return bool
4420
-		 *@since 1.0.6
4421
-		 */
4422
-		public function is_siteorigin_preview() {
4423
-			$result = false;
4424
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
4425
-				$result = true;
4426
-			}
4416
+        /**
4417
+         * Tests if the current output is inside a siteorigin builder preview.
4418
+         *
4419
+         * @return bool
4420
+         *@since 1.0.6
4421
+         */
4422
+        public function is_siteorigin_preview() {
4423
+            $result = false;
4424
+            if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
4425
+                $result = true;
4426
+            }
4427 4427
 
4428
-			return $result;
4429
-		}
4428
+            return $result;
4429
+        }
4430 4430
 
4431
-		/**
4432
-		 * Tests if the current output is inside a cornerstone builder preview.
4433
-		 *
4434
-		 * @return bool
4435
-		 *@since 1.0.8
4436
-		 */
4437
-		public function is_cornerstone_preview() {
4438
-			$result = false;
4439
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
4440
-				$result = true;
4441
-			}
4431
+        /**
4432
+         * Tests if the current output is inside a cornerstone builder preview.
4433
+         *
4434
+         * @return bool
4435
+         *@since 1.0.8
4436
+         */
4437
+        public function is_cornerstone_preview() {
4438
+            $result = false;
4439
+            if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
4440
+                $result = true;
4441
+            }
4442 4442
 
4443
-			return $result;
4444
-		}
4443
+            return $result;
4444
+        }
4445 4445
 
4446
-		/**
4447
-		 * Tests if the current output is inside a fusion builder preview.
4448
-		 *
4449
-		 * @return bool
4450
-		 *@since 1.1.0
4451
-		 */
4452
-		public function is_fusion_preview() {
4453
-			$result = false;
4454
-			if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
4455
-				$result = true;
4456
-			}
4446
+        /**
4447
+         * Tests if the current output is inside a fusion builder preview.
4448
+         *
4449
+         * @return bool
4450
+         *@since 1.1.0
4451
+         */
4452
+        public function is_fusion_preview() {
4453
+            $result = false;
4454
+            if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
4455
+                $result = true;
4456
+            }
4457 4457
 
4458
-			return $result;
4459
-		}
4458
+            return $result;
4459
+        }
4460 4460
 
4461
-		/**
4462
-		 * Tests if the current output is inside a Oxygen builder preview.
4463
-		 *
4464
-		 * @return bool
4465
-		 *@since 1.0.18
4466
-		 */
4467
-		public function is_oxygen_preview() {
4468
-			$result = false;
4469
-			if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
4470
-				$result = true;
4471
-			}
4461
+        /**
4462
+         * Tests if the current output is inside a Oxygen builder preview.
4463
+         *
4464
+         * @return bool
4465
+         *@since 1.0.18
4466
+         */
4467
+        public function is_oxygen_preview() {
4468
+            $result = false;
4469
+            if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
4470
+                $result = true;
4471
+            }
4472 4472
 
4473
-			return $result;
4474
-		}
4473
+            return $result;
4474
+        }
4475 4475
 
4476
-		/**
4477
-		 * Check for Kallyas theme Zion builder preview.
4478
-		 *
4479
-		 * @since 1.1.22
4480
-		 *
4481
-		 * @return bool True when preview page otherwise false.
4482
-		 */
4483
-		public function is_kallyas_zion_preview() {
4484
-			$result = false;
4485
-
4486
-			if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) {
4487
-				$result = true;
4488
-			}
4476
+        /**
4477
+         * Check for Kallyas theme Zion builder preview.
4478
+         *
4479
+         * @since 1.1.22
4480
+         *
4481
+         * @return bool True when preview page otherwise false.
4482
+         */
4483
+        public function is_kallyas_zion_preview() {
4484
+            $result = false;
4489 4485
 
4490
-			return $result;
4491
-		}
4486
+            if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) {
4487
+                $result = true;
4488
+            }
4492 4489
 
4493
-		/**
4494
-		 * Check for Bricks theme builder preview.
4495
-		 *
4496
-		 * @since 1.1.31
4497
-		 *
4498
-		 * @return bool True when preview page otherwise false.
4499
-		 */
4500
-		public function is_bricks_preview() {
4501
-			$result = false;
4502
-
4503
-			if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) {
4504
-				$result = true;
4505
-			}
4490
+            return $result;
4491
+        }
4506 4492
 
4507
-			return $result;
4508
-		}
4493
+        /**
4494
+         * Check for Bricks theme builder preview.
4495
+         *
4496
+         * @since 1.1.31
4497
+         *
4498
+         * @return bool True when preview page otherwise false.
4499
+         */
4500
+        public function is_bricks_preview() {
4501
+            $result = false;
4509 4502
 
4510
-		/**
4511
-		 * General function to check if we are in a preview situation.
4512
-		 *
4513
-		 * @return bool
4514
-		 *@since 1.0.6
4515
-		 */
4516
-		public function is_preview() {
4517
-			$preview = false;
4518
-			if ( $this->is_divi_preview() ) {
4519
-				$preview = true;
4520
-			} elseif ( $this->is_elementor_preview() ) {
4521
-				$preview = true;
4522
-			} elseif ( $this->is_beaver_preview() ) {
4523
-				$preview = true;
4524
-			} elseif ( $this->is_siteorigin_preview() ) {
4525
-				$preview = true;
4526
-			} elseif ( $this->is_cornerstone_preview() ) {
4527
-				$preview = true;
4528
-			} elseif ( $this->is_fusion_preview() ) {
4529
-				$preview = true;
4530
-			} elseif ( $this->is_oxygen_preview() ) {
4531
-				$preview = true;
4532
-			} elseif( $this->is_kallyas_zion_preview() ) {
4533
-				$preview = true;
4534
-			} elseif( $this->is_block_content_call() ) {
4535
-				$preview = true;
4536
-			} elseif( $this->is_bricks_preview() ) {
4537
-				$preview = true;
4538
-			}
4503
+            if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) {
4504
+                $result = true;
4505
+            }
4539 4506
 
4540
-			return $preview;
4541
-		}
4507
+            return $result;
4508
+        }
4542 4509
 
4543
-		/**
4544
-		 * Output the super title.
4545
-		 *
4546
-		 * @param $args
4547
-		 * @param array $instance
4548
-		 *
4549
-		 * @return string
4550
-		 */
4551
-		public function output_title( $args, $instance = array() ) {
4552
-			$output = '';
4553
-			if ( ! empty( $instance['title'] ) ) {
4554
-				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
4555
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
4556
-
4557
-				if ( empty( $instance['widget_title_tag'] ) ) {
4558
-					if ( ! isset( $args['before_title'] ) ) {
4559
-						$args['before_title'] = '';
4560
-					}
4510
+        /**
4511
+         * General function to check if we are in a preview situation.
4512
+         *
4513
+         * @return bool
4514
+         *@since 1.0.6
4515
+         */
4516
+        public function is_preview() {
4517
+            $preview = false;
4518
+            if ( $this->is_divi_preview() ) {
4519
+                $preview = true;
4520
+            } elseif ( $this->is_elementor_preview() ) {
4521
+                $preview = true;
4522
+            } elseif ( $this->is_beaver_preview() ) {
4523
+                $preview = true;
4524
+            } elseif ( $this->is_siteorigin_preview() ) {
4525
+                $preview = true;
4526
+            } elseif ( $this->is_cornerstone_preview() ) {
4527
+                $preview = true;
4528
+            } elseif ( $this->is_fusion_preview() ) {
4529
+                $preview = true;
4530
+            } elseif ( $this->is_oxygen_preview() ) {
4531
+                $preview = true;
4532
+            } elseif( $this->is_kallyas_zion_preview() ) {
4533
+                $preview = true;
4534
+            } elseif( $this->is_block_content_call() ) {
4535
+                $preview = true;
4536
+            } elseif( $this->is_bricks_preview() ) {
4537
+                $preview = true;
4538
+            }
4561 4539
 
4562
-					if ( ! isset( $args['after_title'] ) ) {
4563
-						$args['after_title'] = '';
4564
-					}
4540
+            return $preview;
4541
+        }
4565 4542
 
4566
-					$output = $args['before_title'] . $title . $args['after_title'];
4567
-				} else {
4568
-					$tag 			= esc_attr( $instance['widget_title_tag'] );
4569
-					$allowed_tags 	= array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' );
4570
-					$title_tag      = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2';
4571
-
4572
-					// classes
4573
-					$title_classes = array();
4574
-					$title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
4575
-					$title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
4576
-					$title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
4577
-					$title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
4578
-					$title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
4579
-					$title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
4580
-					$title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
4581
-					$title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
4582
-					$title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
4583
-					$title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
4584
-					$title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
4585
-					$title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
4586
-					$title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
4587
-
4588
-					$class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
4589
-					$output = "<$title_tag class='$class' >$title</$title_tag>";
4590
-				}
4543
+        /**
4544
+         * Output the super title.
4545
+         *
4546
+         * @param $args
4547
+         * @param array $instance
4548
+         *
4549
+         * @return string
4550
+         */
4551
+        public function output_title( $args, $instance = array() ) {
4552
+            $output = '';
4553
+            if ( ! empty( $instance['title'] ) ) {
4554
+                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
4555
+                $title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
4556
+
4557
+                if ( empty( $instance['widget_title_tag'] ) ) {
4558
+                    if ( ! isset( $args['before_title'] ) ) {
4559
+                        $args['before_title'] = '';
4560
+                    }
4561
+
4562
+                    if ( ! isset( $args['after_title'] ) ) {
4563
+                        $args['after_title'] = '';
4564
+                    }
4565
+
4566
+                    $output = $args['before_title'] . $title . $args['after_title'];
4567
+                } else {
4568
+                    $tag 			= esc_attr( $instance['widget_title_tag'] );
4569
+                    $allowed_tags 	= array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' );
4570
+                    $title_tag      = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2';
4571
+
4572
+                    // classes
4573
+                    $title_classes = array();
4574
+                    $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
4575
+                    $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
4576
+                    $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
4577
+                    $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
4578
+                    $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
4579
+                    $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
4580
+                    $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
4581
+                    $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
4582
+                    $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
4583
+                    $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
4584
+                    $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
4585
+                    $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
4586
+                    $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
4587
+
4588
+                    $class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
4589
+                    $output = "<$title_tag class='$class' >$title</$title_tag>";
4590
+                }
4591 4591
 
4592
-			}
4592
+            }
4593 4593
 
4594
-			return $output;
4595
-		}
4594
+            return $output;
4595
+        }
4596 4596
 
4597
-		/**
4598
-		 * Outputs the options form inputs for the widget.
4599
-		 *
4600
-		 * @param array $instance The widget options.
4601
-		 */
4602
-		public function form( $instance ) {
4597
+        /**
4598
+         * Outputs the options form inputs for the widget.
4599
+         *
4600
+         * @param array $instance The widget options.
4601
+         */
4602
+        public function form( $instance ) {
4603 4603
 
4604
-			// set widget instance
4605
-			$this->instance = $instance;
4604
+            // set widget instance
4605
+            $this->instance = $instance;
4606 4606
 
4607
-			// set it as a SD widget
4608
-			echo $this->widget_advanced_toggle();
4607
+            // set it as a SD widget
4608
+            echo $this->widget_advanced_toggle();
4609 4609
 
4610
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
4611
-			$arguments_raw = $this->get_arguments();
4610
+            echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
4611
+            $arguments_raw = $this->get_arguments();
4612 4612
 
4613
-			if ( is_array( $arguments_raw ) ) {
4613
+            if ( is_array( $arguments_raw ) ) {
4614 4614
 
4615
-				$arguments = $this->group_arguments( $arguments_raw );
4615
+                $arguments = $this->group_arguments( $arguments_raw );
4616 4616
 
4617
-				// Do we have sections?
4618
-				$has_sections = $arguments == $arguments_raw ? false : true;
4617
+                // Do we have sections?
4618
+                $has_sections = $arguments == $arguments_raw ? false : true;
4619 4619
 
4620 4620
 
4621
-				if ( $has_sections ) {
4622
-					$panel_count = 0;
4623
-					foreach ( $arguments as $key => $args ) {
4621
+                if ( $has_sections ) {
4622
+                    $panel_count = 0;
4623
+                    foreach ( $arguments as $key => $args ) {
4624 4624
 
4625
-						?>
4625
+                        ?>
4626 4626
 						<script>
4627 4627
 							//							jQuery(this).find("i").toggleClass("fas fa-chevron-up fas fa-chevron-down");jQuery(this).next().toggle();
4628 4628
 						</script>
4629 4629
 						<?php
4630 4630
 
4631
-						$hide       = $panel_count ? ' style="display:none;" ' : '';
4632
-						$icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
4633
-						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>";
4634
-						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
4631
+                        $hide       = $panel_count ? ' style="display:none;" ' : '';
4632
+                        $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
4633
+                        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>";
4634
+                        echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
4635 4635
 
4636
-						foreach ( $args as $k => $a ) {
4636
+                        foreach ( $args as $k => $a ) {
4637 4637
 
4638
-							$this->widget_inputs_row_start($k, $a);
4639
-							$this->widget_inputs( $a, $instance );
4640
-							$this->widget_inputs_row_end($k, $a);
4638
+                            $this->widget_inputs_row_start($k, $a);
4639
+                            $this->widget_inputs( $a, $instance );
4640
+                            $this->widget_inputs_row_end($k, $a);
4641 4641
 
4642
-						}
4642
+                        }
4643 4643
 
4644
-						echo "</div>";
4644
+                        echo "</div>";
4645 4645
 
4646
-						$panel_count ++;
4646
+                        $panel_count ++;
4647 4647
 
4648
-					}
4649
-				} else {
4650
-					foreach ( $arguments as $key => $args ) {
4651
-						$this->widget_inputs_row_start($key, $args);
4652
-						$this->widget_inputs( $args, $instance );
4653
-						$this->widget_inputs_row_end($key, $args);
4654
-					}
4655
-				}
4648
+                    }
4649
+                } else {
4650
+                    foreach ( $arguments as $key => $args ) {
4651
+                        $this->widget_inputs_row_start($key, $args);
4652
+                        $this->widget_inputs( $args, $instance );
4653
+                        $this->widget_inputs_row_end($key, $args);
4654
+                    }
4655
+                }
4656 4656
 
4657
-			}
4658
-		}
4657
+            }
4658
+        }
4659 4659
 
4660
-		public function widget_inputs_row_start( $key, $args ) {
4661
-			if ( ! empty( $args['row'] ) ) {
4662
-				// Maybe open
4663
-				if ( ! empty( $args['row']['open'] ) ) {
4664
-					?>
4660
+        public function widget_inputs_row_start( $key, $args ) {
4661
+            if ( ! empty( $args['row'] ) ) {
4662
+                // Maybe open
4663
+                if ( ! empty( $args['row']['open'] ) ) {
4664
+                    ?>
4665 4665
 					<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'] ) : '' ); ?>'>
4666 4666
 					<?php if ( ! empty( $args['row']['title'] ) ) { ?>
4667 4667
 					<?php
4668
-						if ( isset( $args['row']['icon'] ) ) {
4669
-							$args['row']['icon'] = '';
4670
-						}
4671
-
4672
-						if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) {
4673
-							$args['row']['device_type'] = $args['device_type'];
4674
-						}
4675
-					?>
4668
+                        if ( isset( $args['row']['icon'] ) ) {
4669
+                            $args['row']['icon'] = '';
4670
+                        }
4671
+
4672
+                        if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) {
4673
+                            $args['row']['device_type'] = $args['device_type'];
4674
+                        }
4675
+                    ?>
4676 4676
 					<label class="mb-0"><?php echo $this->widget_field_title( $args['row'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label>
4677 4677
 					<?php } ?>
4678 4678
 					<div class='row<?php echo ( ! empty( $args['row']['class'] ) ? ' ' . esc_attr( $args['row']['class'] ) : '' ); ?>'>
4679 4679
 					<div class='col pr-2'>
4680 4680
 					<?php
4681
-				} else if ( ! empty( $args['row']['close'] ) ) {
4682
-					echo "<div class='col pl-0 ps-0'>";
4683
-				} else {
4684
-					echo "<div class='col pl-0 ps-0 pr-2 pe-2'>";
4685
-				}
4686
-			}
4687
-		}
4681
+                } else if ( ! empty( $args['row']['close'] ) ) {
4682
+                    echo "<div class='col pl-0 ps-0'>";
4683
+                } else {
4684
+                    echo "<div class='col pl-0 ps-0 pr-2 pe-2'>";
4685
+                }
4686
+            }
4687
+        }
4688 4688
 
4689
-		public function widget_inputs_row_end( $key, $args ) {
4690
-			if ( ! empty( $args['row'] ) ) {
4691
-				// Maybe close
4692
-				if ( ! empty( $args['row']['close'] ) ) {
4693
-					echo "</div></div>";
4694
-				}
4695
-				echo "</div>";
4696
-			}
4697
-		}
4689
+        public function widget_inputs_row_end( $key, $args ) {
4690
+            if ( ! empty( $args['row'] ) ) {
4691
+                // Maybe close
4692
+                if ( ! empty( $args['row']['close'] ) ) {
4693
+                    echo "</div></div>";
4694
+                }
4695
+                echo "</div>";
4696
+            }
4697
+        }
4698 4698
 
4699
-		/**
4700
-		 * Get the hidden input that when added makes the advanced button show on widget settings.
4701
-		 *
4702
-		 * @return string
4703
-		 */
4704
-		public function widget_advanced_toggle() {
4699
+        /**
4700
+         * Get the hidden input that when added makes the advanced button show on widget settings.
4701
+         *
4702
+         * @return string
4703
+         */
4704
+        public function widget_advanced_toggle() {
4705 4705
 
4706
-			$output = '';
4707
-			if ( $this->block_show_advanced() ) {
4708
-				$val = 1;
4709
-			} else {
4710
-				$val = 0;
4711
-			}
4706
+            $output = '';
4707
+            if ( $this->block_show_advanced() ) {
4708
+                $val = 1;
4709
+            } else {
4710
+                $val = 0;
4711
+            }
4712 4712
 
4713
-			$output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
4713
+            $output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
4714 4714
 
4715
-			return $output;
4716
-		}
4715
+            return $output;
4716
+        }
4717 4717
 
4718
-		/**
4719
-		 * Convert require element.
4720
-		 *
4721
-		 * @param string $input Input element.
4722
-		 *
4723
-		 * @return string $output
4724
-		 *@since 1.0.0
4725
-		 *
4726
-		 */
4727
-		public function convert_element_require( $input ) {
4728
-			$input = str_replace( "'", '"', $input );// we only want double quotes
4729
-
4730
-			$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
4731
-				"jQuery(form).find('[data-argument=\"",
4732
-				"\"]').find('input,select,textarea').val()",
4733
-				"\"]').find('input:checked').val()"
4734
-			), $input ) );
4735
-
4736
-			return $output;
4737
-		}
4718
+        /**
4719
+         * Convert require element.
4720
+         *
4721
+         * @param string $input Input element.
4722
+         *
4723
+         * @return string $output
4724
+         *@since 1.0.0
4725
+         *
4726
+         */
4727
+        public function convert_element_require( $input ) {
4728
+            $input = str_replace( "'", '"', $input );// we only want double quotes
4738 4729
 
4739
-		/**
4740
-		 * Builds the inputs for the widget options.
4741
-		 *
4742
-		 * @param $args
4743
-		 * @param $instance
4744
-		 */
4745
-		public function widget_inputs( $args, $instance ) {
4746
-
4747
-			$class             = "";
4748
-			$element_require   = "";
4749
-			$custom_attributes = "";
4750
-
4751
-			// get value
4752
-			if ( isset( $instance[ $args['name'] ] ) ) {
4753
-				$value = $instance[ $args['name'] ];
4754
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4755
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4756
-			} else {
4757
-				$value = '';
4758
-			}
4730
+            $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
4731
+                "jQuery(form).find('[data-argument=\"",
4732
+                "\"]').find('input,select,textarea').val()",
4733
+                "\"]').find('input:checked').val()"
4734
+            ), $input ) );
4759 4735
 
4760
-			// get placeholder
4761
-			if ( ! empty( $args['placeholder'] ) ) {
4762
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4763
-			} else {
4764
-				$placeholder = '';
4765
-			}
4736
+            return $output;
4737
+        }
4766 4738
 
4767
-			// get if advanced
4768
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4769
-				$class .= " sd-advanced-setting ";
4770
-			}
4739
+        /**
4740
+         * Builds the inputs for the widget options.
4741
+         *
4742
+         * @param $args
4743
+         * @param $instance
4744
+         */
4745
+        public function widget_inputs( $args, $instance ) {
4746
+
4747
+            $class             = "";
4748
+            $element_require   = "";
4749
+            $custom_attributes = "";
4750
+
4751
+            // get value
4752
+            if ( isset( $instance[ $args['name'] ] ) ) {
4753
+                $value = $instance[ $args['name'] ];
4754
+            } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4755
+                $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4756
+            } else {
4757
+                $value = '';
4758
+            }
4771 4759
 
4772
-			// element_require
4773
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4774
-				$element_require = $args['element_require'];
4775
-			}
4760
+            // get placeholder
4761
+            if ( ! empty( $args['placeholder'] ) ) {
4762
+                $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4763
+            } else {
4764
+                $placeholder = '';
4765
+            }
4776 4766
 
4777
-			// custom_attributes
4778
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4779
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4780
-			}
4767
+            // get if advanced
4768
+            if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4769
+                $class .= " sd-advanced-setting ";
4770
+            }
4781 4771
 
4782
-			// before wrapper
4783
-			?>
4772
+            // element_require
4773
+            if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4774
+                $element_require = $args['element_require'];
4775
+            }
4776
+
4777
+            // custom_attributes
4778
+            if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4779
+                $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4780
+            }
4781
+
4782
+            // before wrapper
4783
+            ?>
4784 4784
 			<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 );} ?>'>
4785 4785
 			<?php
4786
-			switch ( $args['type'] ) {
4787
-				//array('text','password','number','email','tel','url','color')
4788
-				case "text":
4789
-				case "password":
4790
-				case "number":
4791
-				case "email":
4792
-				case "tel":
4793
-				case "url":
4794
-				case "color":
4795
-					?>
4786
+            switch ( $args['type'] ) {
4787
+                //array('text','password','number','email','tel','url','color')
4788
+                case "text":
4789
+                case "password":
4790
+                case "number":
4791
+                case "email":
4792
+                case "tel":
4793
+                case "url":
4794
+                case "color":
4795
+                    ?>
4796 4796
 					<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>
4797 4797
 					<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 ); ?>">
4798 4798
 					<?php
4799 4799
 
4800
-					break;
4801
-				case "select":
4802
-					$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4803
-					if ( $multiple ) {
4804
-						if ( empty( $value ) ) {
4805
-							$value = array();
4806
-						}
4807
-					}
4808
-					?>
4800
+                    break;
4801
+                case "select":
4802
+                    $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4803
+                    if ( $multiple ) {
4804
+                        if ( empty( $value ) ) {
4805
+                            $value = array();
4806
+                        }
4807
+                    }
4808
+                    ?>
4809 4809
 					<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>
4810 4810
 					<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 "[]"; } ?>"
4811 4811
 						<?php if ( $multiple ) {
4812
-							echo "multiple";
4813
-						} //@todo not implemented yet due to gutenberg not supporting it
4814
-						?>>
4812
+                            echo "multiple";
4813
+                        } //@todo not implemented yet due to gutenberg not supporting it
4814
+                        ?>>
4815 4815
 						<?php
4816 4816
 
4817
-						if ( ! empty( $args['options'] ) ) {
4818
-							foreach ( $args['options'] as $val => $label ) {
4819
-								if ( $multiple ) {
4820
-									$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4821
-								} else {
4822
-									$selected = selected( $value, $val, false );
4823
-								}
4824
-								echo "<option value='$val' " . $selected . ">$label</option>";
4825
-							}
4826
-						}
4827
-						?>
4817
+                        if ( ! empty( $args['options'] ) ) {
4818
+                            foreach ( $args['options'] as $val => $label ) {
4819
+                                if ( $multiple ) {
4820
+                                    $selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4821
+                                } else {
4822
+                                    $selected = selected( $value, $val, false );
4823
+                                }
4824
+                                echo "<option value='$val' " . $selected . ">$label</option>";
4825
+                            }
4826
+                        }
4827
+                        ?>
4828 4828
 					</select>
4829 4829
 					<?php
4830
-					break;
4831
-				case "checkbox":
4832
-					?>
4830
+                    break;
4831
+                case "checkbox":
4832
+                    ?>
4833 4833
 					<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">
4834 4834
 					<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>
4835 4835
 					<?php
4836
-					break;
4837
-				case "textarea":
4838
-					?>
4836
+                    break;
4837
+                case "textarea":
4838
+                    ?>
4839 4839
 					<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>
4840 4840
 					<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>
4841 4841
 					<?php
4842 4842
 
4843
-					break;
4844
-				case "hidden":
4845
-					?>
4843
+                    break;
4844
+                case "hidden":
4845
+                    ?>
4846 4846
 					<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 ); ?>">
4847 4847
 					<?php
4848
-					break;
4849
-				default:
4850
-					echo "No input type found!"; // @todo we need to add more input types.
4851
-			}
4852
-			// after wrapper
4853
-			?></p><?php
4854
-		}
4848
+                    break;
4849
+                default:
4850
+                    echo "No input type found!"; // @todo we need to add more input types.
4851
+            }
4852
+            // after wrapper
4853
+            ?></p><?php
4854
+        }
4855 4855
 
4856
-		public function get_widget_icon($icon = 'box-top', $title = ''){
4857
-			if($icon=='box-top'){
4858
-				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>';
4859
-			}elseif($icon=='box-right'){
4860
-				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>';
4861
-			}elseif($icon=='box-bottom'){
4862
-				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>';
4863
-			}elseif($icon=='box-left'){
4864
-				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>';
4865
-			}
4866
-		}
4856
+        public function get_widget_icon($icon = 'box-top', $title = ''){
4857
+            if($icon=='box-top'){
4858
+                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>';
4859
+            }elseif($icon=='box-right'){
4860
+                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>';
4861
+            }elseif($icon=='box-bottom'){
4862
+                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>';
4863
+            }elseif($icon=='box-left'){
4864
+                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>';
4865
+            }
4866
+        }
4867 4867
 
4868
-		/**
4869
-		 * Get the widget input description html.
4870
-		 *
4871
-		 * @param $args
4872
-		 *
4873
-		 * @return string
4874
-		 * @todo, need to make its own tooltip script
4875
-		 */
4876
-		public function widget_field_desc( $args ) {
4877
-
4878
-			$description = '';
4879
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
4880
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4881
-					$description = $this->desc_tip( $args['desc'] );
4882
-				} else {
4883
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4884
-				}
4885
-			}
4868
+        /**
4869
+         * Get the widget input description html.
4870
+         *
4871
+         * @param $args
4872
+         *
4873
+         * @return string
4874
+         * @todo, need to make its own tooltip script
4875
+         */
4876
+        public function widget_field_desc( $args ) {
4877
+
4878
+            $description = '';
4879
+            if ( isset( $args['desc'] ) && $args['desc'] ) {
4880
+                if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4881
+                    $description = $this->desc_tip( $args['desc'] );
4882
+                } else {
4883
+                    $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4884
+                }
4885
+            }
4886 4886
 
4887
-			return $description;
4888
-		}
4887
+            return $description;
4888
+        }
4889 4889
 
4890
-		/**
4891
-		 * Get the widget input title html.
4892
-		 *
4893
-		 * @param $args
4894
-		 *
4895
-		 * @return string
4896
-		 */
4897
-		public function widget_field_title( $args ) {
4898
-			$title = '';
4899
-
4900
-			if ( isset( $args['title'] ) && $args['title'] ) {
4901
-				if ( ! empty( $args['device_type'] ) ) {
4902
-					$args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title.
4903
-				}
4890
+        /**
4891
+         * Get the widget input title html.
4892
+         *
4893
+         * @param $args
4894
+         *
4895
+         * @return string
4896
+         */
4897
+        public function widget_field_title( $args ) {
4898
+            $title = '';
4904 4899
 
4905
-				if ( isset( $args['icon'] ) && $args['icon'] ) {
4906
-					$title = self::get_widget_icon( $args['icon'], $args['title']  );
4907
-				} else {
4908
-					$title = esc_attr( $args['title'] );
4909
-				}
4910
-			}
4900
+            if ( isset( $args['title'] ) && $args['title'] ) {
4901
+                if ( ! empty( $args['device_type'] ) ) {
4902
+                    $args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title.
4903
+                }
4911 4904
 
4912
-			return $title;
4913
-		}
4905
+                if ( isset( $args['icon'] ) && $args['icon'] ) {
4906
+                    $title = self::get_widget_icon( $args['icon'], $args['title']  );
4907
+                } else {
4908
+                    $title = esc_attr( $args['title'] );
4909
+                }
4910
+            }
4914 4911
 
4915
-		/**
4916
-		 * Get the tool tip html.
4917
-		 *
4918
-		 * @param $tip
4919
-		 * @param bool $allow_html
4920
-		 *
4921
-		 * @return string
4922
-		 */
4923
-		function desc_tip( $tip, $allow_html = false ) {
4924
-			if ( $allow_html ) {
4925
-				$tip = $this->sanitize_tooltip( $tip );
4926
-			} else {
4927
-				$tip = esc_attr( $tip );
4928
-			}
4912
+            return $title;
4913
+        }
4929 4914
 
4930
-			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
4931
-		}
4915
+        /**
4916
+         * Get the tool tip html.
4917
+         *
4918
+         * @param $tip
4919
+         * @param bool $allow_html
4920
+         *
4921
+         * @return string
4922
+         */
4923
+        function desc_tip( $tip, $allow_html = false ) {
4924
+            if ( $allow_html ) {
4925
+                $tip = $this->sanitize_tooltip( $tip );
4926
+            } else {
4927
+                $tip = esc_attr( $tip );
4928
+            }
4932 4929
 
4933
-		/**
4934
-		 * Sanitize a string destined to be a tooltip.
4935
-		 *
4936
-		 * @param string $var
4937
-		 *
4938
-		 * @return string
4939
-		 */
4940
-		public function sanitize_tooltip( $var ) {
4941
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4942
-				'br'     => array(),
4943
-				'em'     => array(),
4944
-				'strong' => array(),
4945
-				'small'  => array(),
4946
-				'span'   => array(),
4947
-				'ul'     => array(),
4948
-				'li'     => array(),
4949
-				'ol'     => array(),
4950
-				'p'      => array(),
4951
-			) ) );
4952
-		}
4930
+            return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
4931
+        }
4953 4932
 
4954
-		/**
4955
-		 * Processing widget options on save
4956
-		 *
4957
-		 * @param array $new_instance The new options
4958
-		 * @param array $old_instance The previous options
4959
-		 *
4960
-		 * @return array
4961
-		 * @todo we should add some sanitation here.
4962
-		 */
4963
-		public function update( $new_instance, $old_instance ) {
4964
-
4965
-			//save the widget
4966
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
4967
-
4968
-			// set widget instance
4969
-			$this->instance = $instance;
4970
-
4971
-			if ( empty( $this->arguments ) ) {
4972
-				$this->get_arguments();
4973
-			}
4933
+        /**
4934
+         * Sanitize a string destined to be a tooltip.
4935
+         *
4936
+         * @param string $var
4937
+         *
4938
+         * @return string
4939
+         */
4940
+        public function sanitize_tooltip( $var ) {
4941
+            return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4942
+                'br'     => array(),
4943
+                'em'     => array(),
4944
+                'strong' => array(),
4945
+                'small'  => array(),
4946
+                'span'   => array(),
4947
+                'ul'     => array(),
4948
+                'li'     => array(),
4949
+                'ol'     => array(),
4950
+                'p'      => array(),
4951
+            ) ) );
4952
+        }
4974 4953
 
4975
-			// check for checkboxes
4976
-			if ( ! empty( $this->arguments ) ) {
4977
-				foreach ( $this->arguments as $argument ) {
4978
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4979
-						$instance[ $argument['name'] ] = '0';
4980
-					}
4981
-				}
4982
-			}
4954
+        /**
4955
+         * Processing widget options on save
4956
+         *
4957
+         * @param array $new_instance The new options
4958
+         * @param array $old_instance The previous options
4959
+         *
4960
+         * @return array
4961
+         * @todo we should add some sanitation here.
4962
+         */
4963
+        public function update( $new_instance, $old_instance ) {
4983 4964
 
4984
-			return $instance;
4985
-		}
4965
+            //save the widget
4966
+            $instance = array_merge( (array) $old_instance, (array) $new_instance );
4986 4967
 
4987
-		/**
4988
-		 * Checks if the current call is a ajax call to get the block content.
4989
-		 *
4990
-		 * This can be used in your widget to return different content as the block content.
4991
-		 *
4992
-		 * @return bool
4993
-		 *@since 1.0.3
4994
-		 */
4995
-		public function is_block_content_call() {
4996
-			$result = false;
4997
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4998
-				$result = true;
4999
-			}
4968
+            // set widget instance
4969
+            $this->instance = $instance;
5000 4970
 
5001
-			return $result;
5002
-		}
4971
+            if ( empty( $this->arguments ) ) {
4972
+                $this->get_arguments();
4973
+            }
5003 4974
 
5004
-		/**
5005
-		 * Get an instance hash that will be unique to the type and settings.
5006
-		 *
5007
-		 * @return string
5008
-		 *@since 1.0.20
5009
-		 */
5010
-		public function get_instance_hash(){
5011
-			$instance_string = $this->base_id.serialize($this->instance);
5012
-			return hash('crc32b',$instance_string);
5013
-		}
4975
+            // check for checkboxes
4976
+            if ( ! empty( $this->arguments ) ) {
4977
+                foreach ( $this->arguments as $argument ) {
4978
+                    if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4979
+                        $instance[ $argument['name'] ] = '0';
4980
+                    }
4981
+                }
4982
+            }
5014 4983
 
5015
-		/**
5016
-		 * Generate and return inline styles from CSS rules that will match the unique class of the instance.
5017
-		 *
5018
-		 * @param array $rules
5019
-		 *
5020
-		 * @return string
5021
-		 *@since 1.0.20
5022
-		 */
5023
-		public function get_instance_style($rules = array()){
5024
-			$css = '';
5025
-
5026
-			if(!empty($rules)){
5027
-				$rules = array_unique($rules);
5028
-				$instance_hash = $this->get_instance_hash();
5029
-				$css .= "<style>";
5030
-				foreach($rules as $rule){
5031
-					$css .= ".sdel-$instance_hash $rule";
5032
-				}
5033
-				$css .= "</style>";
5034
-			}
4984
+            return $instance;
4985
+        }
5035 4986
 
5036
-			return $css;
5037
-		}
4987
+        /**
4988
+         * Checks if the current call is a ajax call to get the block content.
4989
+         *
4990
+         * This can be used in your widget to return different content as the block content.
4991
+         *
4992
+         * @return bool
4993
+         *@since 1.0.3
4994
+         */
4995
+        public function is_block_content_call() {
4996
+            $result = false;
4997
+            if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4998
+                $result = true;
4999
+            }
5000
+
5001
+            return $result;
5002
+        }
5038 5003
 
5039
-		/**
5040
-		 * Encode shortcodes tags.
5041
-		 *
5042
-		 * @param string $content Content to search for shortcode tags.
5043
-		 *
5004
+        /**
5005
+         * Get an instance hash that will be unique to the type and settings.
5006
+         *
5007
+         * @return string
5008
+         *@since 1.0.20
5009
+         */
5010
+        public function get_instance_hash(){
5011
+            $instance_string = $this->base_id.serialize($this->instance);
5012
+            return hash('crc32b',$instance_string);
5013
+        }
5014
+
5015
+        /**
5016
+         * Generate and return inline styles from CSS rules that will match the unique class of the instance.
5017
+         *
5018
+         * @param array $rules
5019
+         *
5020
+         * @return string
5021
+         *@since 1.0.20
5022
+         */
5023
+        public function get_instance_style($rules = array()){
5024
+            $css = '';
5025
+
5026
+            if(!empty($rules)){
5027
+                $rules = array_unique($rules);
5028
+                $instance_hash = $this->get_instance_hash();
5029
+                $css .= "<style>";
5030
+                foreach($rules as $rule){
5031
+                    $css .= ".sdel-$instance_hash $rule";
5032
+                }
5033
+                $css .= "</style>";
5034
+            }
5035
+
5036
+            return $css;
5037
+        }
5038
+
5039
+        /**
5040
+         * Encode shortcodes tags.
5041
+         *
5042
+         * @param string $content Content to search for shortcode tags.
5043
+         *
5044 5044
 *@return string Content with shortcode tags removed.
5045
-		 *@since 1.0.28
5046
-		 *
5047
-		 */
5048
-		public function encode_shortcodes( $content ) {
5049
-			// Avoids existing encoded tags.
5050
-			$trans   = array(
5051
-				'&#91;' => '&#091;',
5052
-				'&#93;' => '&#093;',
5053
-				'&amp;#91;' => '&#091;',
5054
-				'&amp;#93;' => '&#093;',
5055
-				'&lt;' => '&0lt;',
5056
-				'&gt;' => '&0gt;',
5057
-				'&amp;lt;' => '&0lt;',
5058
-				'&amp;gt;' => '&0gt;',
5059
-			);
5060
-
5061
-			$content = strtr( $content, $trans );
5062
-
5063
-			$trans   = array(
5064
-				'[' => '&#91;',
5065
-				']' => '&#93;',
5066
-				'<' => '&lt;',
5067
-				'>' => '&gt;',
5068
-				'"' => '&quot;',
5069
-				"'" => '&#39;',
5070
-			);
5071
-
5072
-			$content = strtr( $content, $trans );
5073
-
5074
-			return $content;
5075
-		}
5045
+         *@since 1.0.28
5046
+         *
5047
+         */
5048
+        public function encode_shortcodes( $content ) {
5049
+            // Avoids existing encoded tags.
5050
+            $trans   = array(
5051
+                '&#91;' => '&#091;',
5052
+                '&#93;' => '&#093;',
5053
+                '&amp;#91;' => '&#091;',
5054
+                '&amp;#93;' => '&#093;',
5055
+                '&lt;' => '&0lt;',
5056
+                '&gt;' => '&0gt;',
5057
+                '&amp;lt;' => '&0lt;',
5058
+                '&amp;gt;' => '&0gt;',
5059
+            );
5060
+
5061
+            $content = strtr( $content, $trans );
5062
+
5063
+            $trans   = array(
5064
+                '[' => '&#91;',
5065
+                ']' => '&#93;',
5066
+                '<' => '&lt;',
5067
+                '>' => '&gt;',
5068
+                '"' => '&quot;',
5069
+                "'" => '&#39;',
5070
+            );
5071
+
5072
+            $content = strtr( $content, $trans );
5073
+
5074
+            return $content;
5075
+        }
5076 5076
 
5077
-		/**
5078
-		 * Remove encoded shortcod tags.
5079
-		 *
5080
-		 * @param string $content Content to search for shortcode tags.
5081
-		 *
5077
+        /**
5078
+         * Remove encoded shortcod tags.
5079
+         *
5080
+         * @param string $content Content to search for shortcode tags.
5081
+         *
5082 5082
 *@return string Content with decoded shortcode tags.
5083
-		 *@since 1.0.28
5084
-		 *
5085
-		 */
5086
-		public function decode_shortcodes( $content ) {
5087
-			$trans   = array(
5088
-				'&#91;' => '[',
5089
-				'&#93;' => ']',
5090
-				'&amp;#91;' => '[',
5091
-				'&amp;#93;' => ']',
5092
-				'&lt;' => '<',
5093
-				'&gt;' => '>',
5094
-				'&amp;lt;' => '<',
5095
-				'&amp;gt;' => '>',
5096
-				'&quot;' => '"',
5097
-				'&apos;' => "'",
5098
-			);
5099
-
5100
-			$content = strtr( $content, $trans );
5101
-
5102
-			$trans   = array(
5103
-				'&#091;' => '&#91;',
5104
-				'&#093;' => '&#93;',
5105
-				'&amp;#091;' => '&#91;',
5106
-				'&amp;#093;' => '&#93;',
5107
-				'&0lt;' => '&lt;',
5108
-				'&0gt;' => '&gt;',
5109
-				'&amp;0lt;' => '&lt;',
5110
-				'&amp;0gt;' => '&gt;',
5111
-			);
5112
-
5113
-			$content = strtr( $content, $trans );
5114
-
5115
-			return $content;
5116
-		}
5117
-
5118
-		public function block_visibility_fields( $args ) {
5119
-			$value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : '';
5120
-			$content = '<div class="bs-vc-rule-template d-none">';
5121
-				$content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >';
5122
-					$content .= '<div class="row">';
5123
-						$content .= '<div class="col-sm-12">';
5124
-							$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>';
5125
-							$content .= aui()->select(
5126
-								array(
5127
-									'id'          => 'bsvc_rule_BSVCINDEX',
5128
-									'name'        => 'bsvc_rule_BSVCINDEX',
5129
-									'label'       => __( 'Rule', 'ayecode-connect' ),
5130
-									'placeholder' => __( 'Select Rule...', 'ayecode-connect' ),
5131
-									'class'       => 'bsvc_rule form-select-sm no-select2 mw-100',
5132
-									'options'     => sd_visibility_rules_options(),
5133
-									'default'     => '',
5134
-									'value'       => '',
5135
-									'label_type'  => '',
5136
-									'select2'     => false,
5137
-									'input_group_left' => __( 'Rule:', 'ayecode-connect' ),
5138
-									'extra_attributes' => array(
5139
-										'data-minimum-results-for-search' => '-1'
5140
-									)
5141
-								)
5142
-							);
5143
-
5144
-						$content .= '</div>';
5145
-
5146
-						if ( class_exists( 'GeoDirectory' ) ) {
5147
-							$content .= '<div class="col-md-7 col-sm-12">';
5148
-
5149
-								$content .= aui()->select(
5150
-									array(
5151
-										'id'          => 'bsvc_gd_field_BSVCINDEX',
5152
-										'name'        => 'bsvc_gd_field_BSVCINDEX',
5153
-										'label'       => __( 'FIELD', 'ayecode-connect' ),
5154
-										'placeholder' => __( 'FIELD', 'ayecode-connect' ),
5155
-										'class'       => 'bsvc_gd_field form-select-sm no-select2 mw-100',
5156
-										'options'     => sd_visibility_gd_field_options(),
5157
-										'default'     => '',
5158
-										'value'       => '',
5159
-										'label_type'  => '',
5160
-										'select2'     => false,
5161
-										'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5162
-										'extra_attributes' => array(
5163
-											'data-minimum-results-for-search' => '-1'
5164
-										)
5165
-									)
5166
-								);
5167
-
5168
-							$content .= '</div>';
5169
-							$content .= '<div class="col-md-5 col-sm-12">';
5170
-
5171
-								$content .= aui()->select(
5172
-									array(
5173
-										'id'          => 'bsvc_gd_field_condition_BSVCINDEX',
5174
-										'name'        => 'bsvc_gd_field_condition_BSVCINDEX',
5175
-										'label'       => __( 'CONDITION', 'ayecode-connect' ),
5176
-										'placeholder' => __( 'CONDITION', 'ayecode-connect' ),
5177
-										'class'       => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100',
5178
-										'options'     => sd_visibility_field_condition_options(),
5179
-										'default'     => '',
5180
-										'value'       => '',
5181
-										'label_type'  => '',
5182
-										'select2'     => false,
5183
-										'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5184
-										'extra_attributes' => array(
5185
-											'data-minimum-results-for-search' => '-1'
5186
-										)
5187
-									)
5188
-								);
5189
-
5190
-							$content .= '</div>';
5191
-							$content .= '<div class="col-sm-12">';
5192
-
5193
-								$content .= aui()->input(
5194
-									array(
5195
-										'type'            => 'text',
5196
-										'id'              => 'bsvc_gd_field_search_BSVCINDEX',
5197
-										'name'            => 'bsvc_gd_field_search_BSVCINDEX',
5198
-										'label'           => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5199
-										'class'           => 'bsvc_gd_field_search form-control-sm',
5200
-										'placeholder'     => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5201
-										'label_type'      => '',
5202
-										'value'           => '',
5203
-										'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")'
5204
-									)
5205
-								);
5083
+         *@since 1.0.28
5084
+         *
5085
+         */
5086
+        public function decode_shortcodes( $content ) {
5087
+            $trans   = array(
5088
+                '&#91;' => '[',
5089
+                '&#93;' => ']',
5090
+                '&amp;#91;' => '[',
5091
+                '&amp;#93;' => ']',
5092
+                '&lt;' => '<',
5093
+                '&gt;' => '>',
5094
+                '&amp;lt;' => '<',
5095
+                '&amp;gt;' => '>',
5096
+                '&quot;' => '"',
5097
+                '&apos;' => "'",
5098
+            );
5099
+
5100
+            $content = strtr( $content, $trans );
5101
+
5102
+            $trans   = array(
5103
+                '&#091;' => '&#91;',
5104
+                '&#093;' => '&#93;',
5105
+                '&amp;#091;' => '&#91;',
5106
+                '&amp;#093;' => '&#93;',
5107
+                '&0lt;' => '&lt;',
5108
+                '&0gt;' => '&gt;',
5109
+                '&amp;0lt;' => '&lt;',
5110
+                '&amp;0gt;' => '&gt;',
5111
+            );
5112
+
5113
+            $content = strtr( $content, $trans );
5114
+
5115
+            return $content;
5116
+        }
5206 5117
 
5207
-							$content .= '</div>';
5208
-						}
5118
+        public function block_visibility_fields( $args ) {
5119
+            $value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : '';
5120
+            $content = '<div class="bs-vc-rule-template d-none">';
5121
+                $content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >';
5122
+                    $content .= '<div class="row">';
5123
+                        $content .= '<div class="col-sm-12">';
5124
+                            $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>';
5125
+                            $content .= aui()->select(
5126
+                                array(
5127
+                                    'id'          => 'bsvc_rule_BSVCINDEX',
5128
+                                    'name'        => 'bsvc_rule_BSVCINDEX',
5129
+                                    'label'       => __( 'Rule', 'ayecode-connect' ),
5130
+                                    'placeholder' => __( 'Select Rule...', 'ayecode-connect' ),
5131
+                                    'class'       => 'bsvc_rule form-select-sm no-select2 mw-100',
5132
+                                    'options'     => sd_visibility_rules_options(),
5133
+                                    'default'     => '',
5134
+                                    'value'       => '',
5135
+                                    'label_type'  => '',
5136
+                                    'select2'     => false,
5137
+                                    'input_group_left' => __( 'Rule:', 'ayecode-connect' ),
5138
+                                    'extra_attributes' => array(
5139
+                                        'data-minimum-results-for-search' => '-1'
5140
+                                    )
5141
+                                )
5142
+                            );
5143
+
5144
+                        $content .= '</div>';
5145
+
5146
+                        if ( class_exists( 'GeoDirectory' ) ) {
5147
+                            $content .= '<div class="col-md-7 col-sm-12">';
5148
+
5149
+                                $content .= aui()->select(
5150
+                                    array(
5151
+                                        'id'          => 'bsvc_gd_field_BSVCINDEX',
5152
+                                        'name'        => 'bsvc_gd_field_BSVCINDEX',
5153
+                                        'label'       => __( 'FIELD', 'ayecode-connect' ),
5154
+                                        'placeholder' => __( 'FIELD', 'ayecode-connect' ),
5155
+                                        'class'       => 'bsvc_gd_field form-select-sm no-select2 mw-100',
5156
+                                        'options'     => sd_visibility_gd_field_options(),
5157
+                                        'default'     => '',
5158
+                                        'value'       => '',
5159
+                                        'label_type'  => '',
5160
+                                        'select2'     => false,
5161
+                                        'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5162
+                                        'extra_attributes' => array(
5163
+                                            'data-minimum-results-for-search' => '-1'
5164
+                                        )
5165
+                                    )
5166
+                                );
5167
+
5168
+                            $content .= '</div>';
5169
+                            $content .= '<div class="col-md-5 col-sm-12">';
5170
+
5171
+                                $content .= aui()->select(
5172
+                                    array(
5173
+                                        'id'          => 'bsvc_gd_field_condition_BSVCINDEX',
5174
+                                        'name'        => 'bsvc_gd_field_condition_BSVCINDEX',
5175
+                                        'label'       => __( 'CONDITION', 'ayecode-connect' ),
5176
+                                        'placeholder' => __( 'CONDITION', 'ayecode-connect' ),
5177
+                                        'class'       => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100',
5178
+                                        'options'     => sd_visibility_field_condition_options(),
5179
+                                        'default'     => '',
5180
+                                        'value'       => '',
5181
+                                        'label_type'  => '',
5182
+                                        'select2'     => false,
5183
+                                        'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5184
+                                        'extra_attributes' => array(
5185
+                                            'data-minimum-results-for-search' => '-1'
5186
+                                        )
5187
+                                    )
5188
+                                );
5189
+
5190
+                            $content .= '</div>';
5191
+                            $content .= '<div class="col-sm-12">';
5192
+
5193
+                                $content .= aui()->input(
5194
+                                    array(
5195
+                                        'type'            => 'text',
5196
+                                        'id'              => 'bsvc_gd_field_search_BSVCINDEX',
5197
+                                        'name'            => 'bsvc_gd_field_search_BSVCINDEX',
5198
+                                        'label'           => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5199
+                                        'class'           => 'bsvc_gd_field_search form-control-sm',
5200
+                                        'placeholder'     => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5201
+                                        'label_type'      => '',
5202
+                                        'value'           => '',
5203
+                                        '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")'
5204
+                                    )
5205
+                                );
5206
+
5207
+                            $content .= '</div>';
5208
+                        }
5209 5209
 
5210 5210
                         $content .= apply_filters( 'sd_block_visibility_fields', '', $args );
5211 5211
 
5212
-					$content .= '</div>';
5213
-
5214
-					$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>';
5215
-						$role_options = sd_user_roles_options();
5216
-
5217
-						$role_option_i = 0;
5218
-						foreach ( $role_options as $role_option_key => $role_option_name ) {
5219
-							$role_option_i++;
5220
-
5221
-							$content .= '<div class="col-sm-6">';
5222
-							$content .= aui()->input(
5223
-								array(
5224
-									'id'               => 'bsvc_user_roles_BSVCINDEX_' . $role_option_i,
5225
-									'name'             => 'bsvc_user_roles_BSVCINDEX[]',
5226
-									'type'             => 'checkbox',
5227
-									'label'            => $role_option_name,
5228
-									'label_type'       => 'hidden',
5229
-									'class'            => 'bsvc_user_roles',
5230
-									'value'            => $role_option_key,
5231
-									'switch'           => 'md',
5232
-									'no_wrap'          => true
5233
-								)
5234
-							);
5235
-							$content .= '</div>';
5236
-						}
5237
-					$content .= '</div>';
5238
-					$content .= '<div class="bs-vc-sep-wrap text-center position-absolute top-0 mt-n3"><div class="bs-vc-sep-cond d-inline-block badge text-dark bg-gray mt-1">' . esc_html__( 'AND', 'ayecode-connect' ) . '</div></div>';
5239
-				$content .= '</div>';
5240
-			$content .= '</div>';
5241
-			$content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">';
5242
-			$content .= '<div class="bs-vc-rule-sets"></div>';
5243
-			$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>';
5244
-			$content .= '<div class="row"><div class="col-md-6 col-sm-12">';
5245
-			$content .= aui()->select(
5246
-				array(
5247
-					'id'          => 'bsvc_output',
5248
-					'name'        => 'bsvc_output',
5249
-					'label'       => __( 'What should happen if rules met.', 'ayecode-connect' ),
5250
-					'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5251
-					'class'       => 'bsvc_output form-select-sm no-select2 mw-100',
5252
-					'options'     => sd_visibility_output_options(),
5253
-					'default'     => '',
5254
-					'value'       => '',
5255
-					'label_type'  => 'top',
5256
-					'select2'     => false,
5257
-					'extra_attributes' => array(
5258
-						'data-minimum-results-for-search' => '-1'
5259
-					)
5260
-				)
5261
-			);
5262
-
5263
-			$content .= '</div><div class="col-md-6 col-sm-12">';
5264
-
5265
-			$content .= aui()->select(
5266
-				array(
5267
-					'id'              => 'bsvc_page',
5268
-					'name'            => 'bsvc_page',
5269
-					'label'           => __( 'Page Content', 'ayecode-connect' ),
5270
-					'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5271
-					'class'           => 'bsvc_page form-select-sm no-select2 mw-100',
5272
-					'options'         => sd_template_page_options(),
5273
-					'default'         => '',
5274
-					'value'           => '',
5275
-					'label_type'      => 'top',
5276
-					'select2'         => false,
5277
-					'element_require' => '[%bsvc_output%]=="page"'
5278
-				)
5279
-			);
5280
-
5281
-			$content .= aui()->select(
5282
-				array(
5283
-					'id'          => 'bsvc_tmpl_part',
5284
-					'name'        => 'bsvc_tmpl_part',
5285
-					'label'       => __( 'Template Part', 'ayecode-connect' ),
5286
-					'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5287
-					'class'       => 'bsvc_tmpl_part form-select-sm no-select2 mw-100',
5288
-					'options'     => sd_template_part_options(),
5289
-					'default'     => '',
5290
-					'value'       => '',
5291
-					'label_type'  => 'top',
5292
-					'select2'     => false,
5293
-					'element_require'  => '[%bsvc_output%]=="template_part"',
5294
-					'extra_attributes' => array(
5295
-						'data-minimum-results-for-search' => '-1'
5296
-					)
5297
-				)
5298
-			);
5299
-
5300
-			$content .= aui()->select(
5301
-				array(
5302
-					'id'               => 'bsvc_message_type',
5303
-					'name'             => 'bsvc_message_type',
5304
-					'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5305
-					'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5306
-					'class'            => 'bsvc_message_type form-select-sm no-select2 mw-100',
5307
-					'options'          => sd_aui_colors(),
5308
-					'default'          => '',
5309
-					'value'            => '',
5310
-					'label_type'       => 'top',
5311
-					'select2'          => false,
5312
-					'element_require'  => '[%bsvc_output%]=="message"',
5313
-					'extra_attributes' => array(
5314
-						'data-minimum-results-for-search' => '-1'
5315
-					)
5316
-				)
5317
-			);
5318
-
5319
-			$content .= '</div><div class="col-sm-12">';
5320
-
5321
-			$content .= aui()->input(
5322
-				array(
5323
-					'type'            => 'text',
5324
-					'id'              => 'bsvc_message',
5325
-					'name'            => 'bsvc_message',
5326
-					'label'           => '',
5327
-					'class'           => 'bsvc_message form-control-sm mb-3',
5328
-					'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5329
-					'label_type'      => '',
5330
-					'value'           => '',
5331
-					'form_group_class' => ' ',
5332
-					'element_require' => '[%bsvc_output%]=="message"',
5333
-				)
5334
-			);
5335
-
5336
-			$content .= '</div></div><div class="row"><div class="col col-12"><div class="pt-3 mt-1 border-top"></div></div><div class="col-md-6 col-sm-12">';
5337
-			$content .= aui()->select(
5338
-				array(
5339
-					'id'          => 'bsvc_output_n',
5340
-					'name'        => 'bsvc_output_n',
5341
-					'label'       => __( 'What should happen if rules NOT met.', 'ayecode-connect' ),
5342
-					'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5343
-					'class'       => 'bsvc_output_n form-select-sm no-select2 mw-100',
5344
-					'options'     => sd_visibility_output_options(),
5345
-					'default'     => '',
5346
-					'value'       => '',
5347
-					'label_type'  => 'top',
5348
-					'select2'     => false,
5349
-					'extra_attributes' => array(
5350
-						'data-minimum-results-for-search' => '-1'
5351
-					)
5352
-				)
5353
-			);
5354
-
5355
-			$content .= '</div><div class="col-md-6 col-sm-12">';
5356
-
5357
-			$content .= aui()->select(
5358
-				array(
5359
-					'id'              => 'bsvc_page_n',
5360
-					'name'            => 'bsvc_page_n',
5361
-					'label'           => __( 'Page Content', 'ayecode-connect' ),
5362
-					'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5363
-					'class'           => 'bsvc_page_n form-select-sm no-select2 mw-100',
5364
-					'options'         => sd_template_page_options(),
5365
-					'default'         => '',
5366
-					'value'           => '',
5367
-					'label_type'      => 'top',
5368
-					'select2'         => false,
5369
-					'element_require' => '[%bsvc_output_n%]=="page"'
5370
-				)
5371
-			);
5372
-
5373
-			$content .= aui()->select(
5374
-				array(
5375
-					'id'          => 'bsvc_tmpl_part_n',
5376
-					'name'        => 'bsvc_tmpl_part_n',
5377
-					'label'       => __( 'Template Part', 'ayecode-connect' ),
5378
-					'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5379
-					'class'       => 'bsvc_tmpl_part_n form-select-sm no-select2 mw-100',
5380
-					'options'     => sd_template_part_options(),
5381
-					'default'     => '',
5382
-					'value'       => '',
5383
-					'label_type'  => 'top',
5384
-					'select2'     => false,
5385
-					'element_require'  => '[%bsvc_output_n%]=="template_part"',
5386
-					'extra_attributes' => array(
5387
-						'data-minimum-results-for-search' => '-1'
5388
-					)
5389
-				)
5390
-			);
5391
-
5392
-			$content .= aui()->select(
5393
-				array(
5394
-					'id'               => 'bsvc_message_type_n',
5395
-					'name'             => 'bsvc_message_type_n',
5396
-					'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5397
-					'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5398
-					'class'            => 'bsvc_message_type_n form-select-sm no-select2 mw-100',
5399
-					'options'          => sd_aui_colors(),
5400
-					'default'          => '',
5401
-					'value'            => '',
5402
-					'label_type'       => 'top',
5403
-					'select2'          => false,
5404
-					'element_require'  => '[%bsvc_output_n%]=="message"',
5405
-					'extra_attributes' => array(
5406
-						'data-minimum-results-for-search' => '-1'
5407
-					)
5408
-				)
5409
-			);
5410
-
5411
-			$content .= '</div><div class="col-sm-12">';
5412
-
5413
-			$content .= aui()->input(
5414
-				array(
5415
-					'type'            => 'text',
5416
-					'id'              => 'bsvc_message_n',
5417
-					'name'            => 'bsvc_message_n',
5418
-					'label'           => '',
5419
-					'class'           => 'bsvc_message_n form-control-sm',
5420
-					'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5421
-					'label_type'      => '',
5422
-					'value'           => '',
5423
-					'form_group_class' => ' ',
5424
-					'element_require' => '[%bsvc_output_n%]=="message"',
5425
-				)
5426
-			);
5427
-
5428
-			$content .= '</div></div></form><input type="hidden" id="bsvc_raw_value" name="bsvc_raw_value" value="' . $value . '">';
5429
-
5430
-			return $content;
5431
-		}
5212
+                    $content .= '</div>';
5213
+
5214
+                    $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>';
5215
+                        $role_options = sd_user_roles_options();
5216
+
5217
+                        $role_option_i = 0;
5218
+                        foreach ( $role_options as $role_option_key => $role_option_name ) {
5219
+                            $role_option_i++;
5220
+
5221
+                            $content .= '<div class="col-sm-6">';
5222
+                            $content .= aui()->input(
5223
+                                array(
5224
+                                    'id'               => 'bsvc_user_roles_BSVCINDEX_' . $role_option_i,
5225
+                                    'name'             => 'bsvc_user_roles_BSVCINDEX[]',
5226
+                                    'type'             => 'checkbox',
5227
+                                    'label'            => $role_option_name,
5228
+                                    'label_type'       => 'hidden',
5229
+                                    'class'            => 'bsvc_user_roles',
5230
+                                    'value'            => $role_option_key,
5231
+                                    'switch'           => 'md',
5232
+                                    'no_wrap'          => true
5233
+                                )
5234
+                            );
5235
+                            $content .= '</div>';
5236
+                        }
5237
+                    $content .= '</div>';
5238
+                    $content .= '<div class="bs-vc-sep-wrap text-center position-absolute top-0 mt-n3"><div class="bs-vc-sep-cond d-inline-block badge text-dark bg-gray mt-1">' . esc_html__( 'AND', 'ayecode-connect' ) . '</div></div>';
5239
+                $content .= '</div>';
5240
+            $content .= '</div>';
5241
+            $content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">';
5242
+            $content .= '<div class="bs-vc-rule-sets"></div>';
5243
+            $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>';
5244
+            $content .= '<div class="row"><div class="col-md-6 col-sm-12">';
5245
+            $content .= aui()->select(
5246
+                array(
5247
+                    'id'          => 'bsvc_output',
5248
+                    'name'        => 'bsvc_output',
5249
+                    'label'       => __( 'What should happen if rules met.', 'ayecode-connect' ),
5250
+                    'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5251
+                    'class'       => 'bsvc_output form-select-sm no-select2 mw-100',
5252
+                    'options'     => sd_visibility_output_options(),
5253
+                    'default'     => '',
5254
+                    'value'       => '',
5255
+                    'label_type'  => 'top',
5256
+                    'select2'     => false,
5257
+                    'extra_attributes' => array(
5258
+                        'data-minimum-results-for-search' => '-1'
5259
+                    )
5260
+                )
5261
+            );
5262
+
5263
+            $content .= '</div><div class="col-md-6 col-sm-12">';
5264
+
5265
+            $content .= aui()->select(
5266
+                array(
5267
+                    'id'              => 'bsvc_page',
5268
+                    'name'            => 'bsvc_page',
5269
+                    'label'           => __( 'Page Content', 'ayecode-connect' ),
5270
+                    'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5271
+                    'class'           => 'bsvc_page form-select-sm no-select2 mw-100',
5272
+                    'options'         => sd_template_page_options(),
5273
+                    'default'         => '',
5274
+                    'value'           => '',
5275
+                    'label_type'      => 'top',
5276
+                    'select2'         => false,
5277
+                    'element_require' => '[%bsvc_output%]=="page"'
5278
+                )
5279
+            );
5280
+
5281
+            $content .= aui()->select(
5282
+                array(
5283
+                    'id'          => 'bsvc_tmpl_part',
5284
+                    'name'        => 'bsvc_tmpl_part',
5285
+                    'label'       => __( 'Template Part', 'ayecode-connect' ),
5286
+                    'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5287
+                    'class'       => 'bsvc_tmpl_part form-select-sm no-select2 mw-100',
5288
+                    'options'     => sd_template_part_options(),
5289
+                    'default'     => '',
5290
+                    'value'       => '',
5291
+                    'label_type'  => 'top',
5292
+                    'select2'     => false,
5293
+                    'element_require'  => '[%bsvc_output%]=="template_part"',
5294
+                    'extra_attributes' => array(
5295
+                        'data-minimum-results-for-search' => '-1'
5296
+                    )
5297
+                )
5298
+            );
5299
+
5300
+            $content .= aui()->select(
5301
+                array(
5302
+                    'id'               => 'bsvc_message_type',
5303
+                    'name'             => 'bsvc_message_type',
5304
+                    'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5305
+                    'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5306
+                    'class'            => 'bsvc_message_type form-select-sm no-select2 mw-100',
5307
+                    'options'          => sd_aui_colors(),
5308
+                    'default'          => '',
5309
+                    'value'            => '',
5310
+                    'label_type'       => 'top',
5311
+                    'select2'          => false,
5312
+                    'element_require'  => '[%bsvc_output%]=="message"',
5313
+                    'extra_attributes' => array(
5314
+                        'data-minimum-results-for-search' => '-1'
5315
+                    )
5316
+                )
5317
+            );
5318
+
5319
+            $content .= '</div><div class="col-sm-12">';
5320
+
5321
+            $content .= aui()->input(
5322
+                array(
5323
+                    'type'            => 'text',
5324
+                    'id'              => 'bsvc_message',
5325
+                    'name'            => 'bsvc_message',
5326
+                    'label'           => '',
5327
+                    'class'           => 'bsvc_message form-control-sm mb-3',
5328
+                    'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5329
+                    'label_type'      => '',
5330
+                    'value'           => '',
5331
+                    'form_group_class' => ' ',
5332
+                    'element_require' => '[%bsvc_output%]=="message"',
5333
+                )
5334
+            );
5335
+
5336
+            $content .= '</div></div><div class="row"><div class="col col-12"><div class="pt-3 mt-1 border-top"></div></div><div class="col-md-6 col-sm-12">';
5337
+            $content .= aui()->select(
5338
+                array(
5339
+                    'id'          => 'bsvc_output_n',
5340
+                    'name'        => 'bsvc_output_n',
5341
+                    'label'       => __( 'What should happen if rules NOT met.', 'ayecode-connect' ),
5342
+                    'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5343
+                    'class'       => 'bsvc_output_n form-select-sm no-select2 mw-100',
5344
+                    'options'     => sd_visibility_output_options(),
5345
+                    'default'     => '',
5346
+                    'value'       => '',
5347
+                    'label_type'  => 'top',
5348
+                    'select2'     => false,
5349
+                    'extra_attributes' => array(
5350
+                        'data-minimum-results-for-search' => '-1'
5351
+                    )
5352
+                )
5353
+            );
5354
+
5355
+            $content .= '</div><div class="col-md-6 col-sm-12">';
5356
+
5357
+            $content .= aui()->select(
5358
+                array(
5359
+                    'id'              => 'bsvc_page_n',
5360
+                    'name'            => 'bsvc_page_n',
5361
+                    'label'           => __( 'Page Content', 'ayecode-connect' ),
5362
+                    'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5363
+                    'class'           => 'bsvc_page_n form-select-sm no-select2 mw-100',
5364
+                    'options'         => sd_template_page_options(),
5365
+                    'default'         => '',
5366
+                    'value'           => '',
5367
+                    'label_type'      => 'top',
5368
+                    'select2'         => false,
5369
+                    'element_require' => '[%bsvc_output_n%]=="page"'
5370
+                )
5371
+            );
5372
+
5373
+            $content .= aui()->select(
5374
+                array(
5375
+                    'id'          => 'bsvc_tmpl_part_n',
5376
+                    'name'        => 'bsvc_tmpl_part_n',
5377
+                    'label'       => __( 'Template Part', 'ayecode-connect' ),
5378
+                    'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5379
+                    'class'       => 'bsvc_tmpl_part_n form-select-sm no-select2 mw-100',
5380
+                    'options'     => sd_template_part_options(),
5381
+                    'default'     => '',
5382
+                    'value'       => '',
5383
+                    'label_type'  => 'top',
5384
+                    'select2'     => false,
5385
+                    'element_require'  => '[%bsvc_output_n%]=="template_part"',
5386
+                    'extra_attributes' => array(
5387
+                        'data-minimum-results-for-search' => '-1'
5388
+                    )
5389
+                )
5390
+            );
5391
+
5392
+            $content .= aui()->select(
5393
+                array(
5394
+                    'id'               => 'bsvc_message_type_n',
5395
+                    'name'             => 'bsvc_message_type_n',
5396
+                    'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5397
+                    'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5398
+                    'class'            => 'bsvc_message_type_n form-select-sm no-select2 mw-100',
5399
+                    'options'          => sd_aui_colors(),
5400
+                    'default'          => '',
5401
+                    'value'            => '',
5402
+                    'label_type'       => 'top',
5403
+                    'select2'          => false,
5404
+                    'element_require'  => '[%bsvc_output_n%]=="message"',
5405
+                    'extra_attributes' => array(
5406
+                        'data-minimum-results-for-search' => '-1'
5407
+                    )
5408
+                )
5409
+            );
5410
+
5411
+            $content .= '</div><div class="col-sm-12">';
5412
+
5413
+            $content .= aui()->input(
5414
+                array(
5415
+                    'type'            => 'text',
5416
+                    'id'              => 'bsvc_message_n',
5417
+                    'name'            => 'bsvc_message_n',
5418
+                    'label'           => '',
5419
+                    'class'           => 'bsvc_message_n form-control-sm',
5420
+                    'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5421
+                    'label_type'      => '',
5422
+                    'value'           => '',
5423
+                    'form_group_class' => ' ',
5424
+                    'element_require' => '[%bsvc_output_n%]=="message"',
5425
+                )
5426
+            );
5427
+
5428
+            $content .= '</div></div></form><input type="hidden" id="bsvc_raw_value" name="bsvc_raw_value" value="' . $value . '">';
5429
+
5430
+            return $content;
5431
+        }
5432 5432
 
5433
-		/**
5434
-		 * Handle media_buttons hook.
5435
-		 *
5436
-		 * @since 1.2.7
5437
-		 */
5438
-		public function wp_media_buttons() {
5439
-			global $shortcode_insert_button_once;
5440
-
5441
-			// Fix conflicts with UpSolution Core in header template edit element.
5442
-			if ( defined( 'US_CORE_DIR' ) && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html' ) {
5443
-				$shortcode_insert_button_once = true;
5444
-			}
5445
-		}
5446
-	}
5433
+        /**
5434
+         * Handle media_buttons hook.
5435
+         *
5436
+         * @since 1.2.7
5437
+         */
5438
+        public function wp_media_buttons() {
5439
+            global $shortcode_insert_button_once;
5440
+
5441
+            // Fix conflicts with UpSolution Core in header template edit element.
5442
+            if ( defined( 'US_CORE_DIR' ) && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html' ) {
5443
+                $shortcode_insert_button_once = true;
5444
+            }
5445
+        }
5446
+    }
5447 5447
 }
Please login to merge, or discard this patch.
Spacing   +831 added lines, -831 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.17' );
8
+	define('SUPER_DUPER_VER', '1.2.17');
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){
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
 	}
2112 2112
 }
2113 2113
 
2114
-<?php if( !isset( $_REQUEST['sd-block-recover-debug'] ) ){ ?>
2114
+<?php if (!isset($_REQUEST['sd-block-recover-debug'])) { ?>
2115 2115
 // Wait will window is loaded before calling.
2116 2116
 window.onload = function() {
2117 2117
 	sd_auto_recover_blocks();
@@ -2290,7 +2290,7 @@  discard block
 block discarded – undo
2290 2290
 				$classes = [];
2291 2291
 
2292 2292
 				<?php
2293
-				if($aui_bs5){
2293
+				if ($aui_bs5) {
2294 2294
 					?>
2295 2295
 				$aui_bs5 = true;
2296 2296
 				$p_ml = 'ms-';
@@ -2299,7 +2299,7 @@  discard block
 block discarded – undo
2299 2299
 				$p_pl = 'ps-';
2300 2300
 				$p_pr = 'pe-';
2301 2301
 					<?php
2302
-				}else{
2302
+				} else {
2303 2303
 						?>
2304 2304
 				$aui_bs5 = false;
2305 2305
 				$p_ml = 'ml-';
@@ -2487,7 +2487,7 @@  discard block
 block discarded – undo
2487 2487
 			}
2488 2488
 
2489 2489
 			function sd_get_class_build_keys(){
2490
-				return <?php echo json_encode(sd_get_class_build_keys());?>;
2490
+				return <?php echo json_encode(sd_get_class_build_keys()); ?>;
2491 2491
 			}
2492 2492
 
2493 2493
 			<?php
@@ -2495,7 +2495,7 @@  discard block
 block discarded – undo
2495 2495
 
2496 2496
 			}
2497 2497
 
2498
-			if(method_exists($this,'block_global_js')){
2498
+			if (method_exists($this, 'block_global_js')) {
2499 2499
 					echo $this->block_global_js();
2500 2500
 			}
2501 2501
 			?>
@@ -2527,9 +2527,9 @@  discard block
 block discarded – undo
2527 2527
 					var InnerBlocks = blockEditor.InnerBlocks;
2528 2528
 
2529 2529
 					var term_query_type = '';
2530
-					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 "[]";} ?>;
2531
-					const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2532
-					const sort_by_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2530
+					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 "[]"; } ?>;
2531
+					const taxonomies_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}];
2532
+					const sort_by_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}];
2533 2533
 					const MediaUpload = wp.blockEditor.MediaUpload;
2534 2534
 
2535 2535
 					/**
@@ -2544,87 +2544,87 @@  discard block
 block discarded – undo
2544 2544
 					 * @return {?WPBlock}          The block, if it has been successfully
2545 2545
 					 *                             registered; otherwise `undefined`.
2546 2546
 					 */
2547
-					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.
2548
-						apiVersion: <?php echo isset($this->options['block-api-version']) ? absint($this->options['block-api-version']) : 2 ; ?>,
2549
-						title: '<?php echo addslashes( $this->options['name'] ); ?>', // Block title.
2550
-						description: '<?php echo addslashes( $this->options['widget_ops']['description'] )?>', // Block title.
2551
-						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/.
2547
+					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.
2548
+						apiVersion: <?php echo isset($this->options['block-api-version']) ? absint($this->options['block-api-version']) : 2; ?>,
2549
+						title: '<?php echo addslashes($this->options['name']); ?>', // Block title.
2550
+						description: '<?php echo addslashes($this->options['widget_ops']['description'])?>', // Block title.
2551
+						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/.
2552 2552
 						supports: {
2553 2553
 							<?php
2554
-							if(!isset($this->options['block-supports']['renaming'])){
2554
+							if (!isset($this->options['block-supports']['renaming'])) {
2555 2555
 								$this->options['block-supports']['renaming'] = false;
2556 2556
 							}
2557
-							if ( isset( $this->options['block-supports'] ) ) {
2558
-								echo $this->array_to_attributes( $this->options['block-supports'] );
2557
+							if (isset($this->options['block-supports'])) {
2558
+								echo $this->array_to_attributes($this->options['block-supports']);
2559 2559
 							}
2560 2560
 							?>
2561 2561
 						},
2562 2562
 						__experimentalLabel( attributes, { context } ) {
2563 2563
 							var visibility_html = attributes && attributes.visibility_conditions ? ' &#128065;' : '';
2564 2564
 							var metadata_name = attributes && attributes.metadata && attributes.metadata.name ? attributes.metadata.name : '';
2565
-							var label_name = <?php echo !empty($this->options['block-label']) ? $this->options['block-label'] : "'" . esc_attr( addslashes( $this->options['name'] ) ) . "'"; ?>;
2565
+							var label_name = <?php echo !empty($this->options['block-label']) ? $this->options['block-label'] : "'" . esc_attr(addslashes($this->options['name'])) . "'"; ?>;
2566 2566
 							return metadata_name ? metadata_name + visibility_html  : label_name + visibility_html;
2567 2567
 						},
2568
-						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.
2569
-						<?php if ( isset( $this->options['block-keywords'] ) ) {
2568
+						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.
2569
+						<?php if (isset($this->options['block-keywords'])) {
2570 2570
 						echo "keywords : " . $this->options['block-keywords'] . ",";
2571 2571
 						}
2572 2572
 
2573 2573
 
2574 2574
 						// block hover preview.
2575 2575
 						$example_args = array();
2576
-						if(!empty($this->arguments)){
2577
-							foreach($this->arguments as $key => $a_args){
2578
-								if(isset($a_args['example'])){
2576
+						if (!empty($this->arguments)) {
2577
+							foreach ($this->arguments as $key => $a_args) {
2578
+								if (isset($a_args['example'])) {
2579 2579
 									$example_args[$key] = $a_args['example'];
2580 2580
 								}
2581 2581
 							}
2582 2582
 						}
2583
-						$viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : '';
2583
+						$viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: ' . absint($this->options['example']['viewportWidth']) : '';
2584 2584
 						$example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2585
-						if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2585
+						if (isset($this->options['example']) && $this->options['example'] === false) {
2586 2586
 							// no preview if set to false
2587
-						}elseif( !empty( $example_args ) ){
2588
-							echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2589
-						}elseif( !empty( $this->options['example'] ) ){
2587
+						}elseif (!empty($example_args)) {
2588
+							echo "example : {attributes:{" . $this->array_to_attributes($example_args) . "},$viewport_width},";
2589
+						}elseif (!empty($this->options['example'])) {
2590 2590
 							unset($this->options['example']['viewportWidth']);
2591 2591
 							unset($this->options['example']['innerBlocks']);
2592
-							$example_atts = $this->array_to_attributes( $this->options['example'] );
2592
+							$example_atts = $this->array_to_attributes($this->options['example']);
2593 2593
 							$example_parts = array();
2594
-							if($example_atts){
2595
-								$example_parts[] = rtrim($example_atts,",");
2594
+							if ($example_atts) {
2595
+								$example_parts[] = rtrim($example_atts, ",");
2596 2596
 							}
2597
-							if($viewport_width){
2597
+							if ($viewport_width) {
2598 2598
 								$example_parts[] = $viewport_width;
2599 2599
 							}
2600
-							if($example_inner_blocks){
2600
+							if ($example_inner_blocks) {
2601 2601
 								$example_parts[] = $example_inner_blocks;
2602 2602
 							}
2603
-							if(!empty($example_parts)){
2604
-								echo "example : {".implode(',', $example_parts)."},";
2603
+							if (!empty($example_parts)) {
2604
+								echo "example : {" . implode(',', $example_parts) . "},";
2605 2605
 							}
2606
-						}else{
2606
+						} else {
2607 2607
 							echo 'example : {viewportWidth: 500},';
2608 2608
 						}
2609 2609
 
2610 2610
 
2611 2611
 
2612 2612
 						// limit to parent
2613
-						if( !empty( $this->options['parent'] ) ){
2614
-							echo "parent : " . wp_json_encode( $this->options['parent'] ) . ",";
2613
+						if (!empty($this->options['parent'])) {
2614
+							echo "parent : " . wp_json_encode($this->options['parent']) . ",";
2615 2615
 						}
2616 2616
 
2617 2617
 						// limit allowed blocks
2618
-						if( !empty( $this->options['allowed-blocks'] ) ){
2619
-							echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ",";
2618
+						if (!empty($this->options['allowed-blocks'])) {
2619
+							echo "allowedBlocks : " . wp_json_encode($this->options['allowed-blocks']) . ",";
2620 2620
 						}
2621 2621
 
2622 2622
 						// maybe set no_wrap
2623
-						$no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2624
-						if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2623
+						$no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false;
2624
+						if (isset($this->arguments['no_wrap']) && $this->arguments['no_wrap']) {
2625 2625
 							$no_wrap = true;
2626 2626
 						}
2627
-						if ( $no_wrap ) {
2627
+						if ($no_wrap) {
2628 2628
 							$this->options['block-wrap'] = '';
2629 2629
 						}
2630 2630
 
@@ -2641,7 +2641,7 @@  discard block
 block discarded – undo
2641 2641
 
2642 2642
 							echo "attributes : {";
2643 2643
 
2644
-							if ( $show_advanced ) {
2644
+							if ($show_advanced) {
2645 2645
 								echo "show_advanced: {";
2646 2646
 								echo "	type: 'boolean',";
2647 2647
 								echo "  default: false,";
@@ -2649,57 +2649,57 @@  discard block
 block discarded – undo
2649 2649
 							}
2650 2650
 
2651 2651
 							// block wrap element
2652
-							if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2652
+							if (!empty($this->options['block-wrap'])) { //@todo we should validate this?
2653 2653
 								echo "block_wrap: {";
2654 2654
 								echo "	type: 'string',";
2655
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2655
+								echo "  default: '" . esc_attr($this->options['block-wrap']) . "',";
2656 2656
 								echo "},";
2657 2657
 							}
2658 2658
 
2659 2659
 
2660
-							if ( ! empty( $this->arguments ) ) {
2660
+							if (!empty($this->arguments)) {
2661 2661
 
2662
-								foreach ( $this->arguments as $key => $args ) {
2662
+								foreach ($this->arguments as $key => $args) {
2663 2663
 
2664
-									if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2664
+									if ($args['type'] == 'image' || $args['type'] == 'images') {
2665 2665
 										$img_drag_drop = true;
2666 2666
 									}
2667 2667
 
2668 2668
 									// set if we should show alignment
2669
-									if ( $key == 'alignment' ) {
2669
+									if ($key == 'alignment') {
2670 2670
 										$show_alignment = true;
2671 2671
 									}
2672 2672
 
2673 2673
 									$extra = '';
2674 2674
 
2675
-									if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2675
+									if ($args['type'] == 'notice' || $args['type'] == 'tab') {
2676 2676
 										continue;
2677 2677
 									}
2678
-									elseif ( $args['type'] == 'checkbox' ) {
2678
+									elseif ($args['type'] == 'checkbox') {
2679 2679
 										$type    = 'boolean';
2680
-										$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2681
-									} elseif ( $args['type'] == 'number' ) {
2680
+										$default = isset($args['default']) && $args['default'] ? 'true' : 'false';
2681
+									} elseif ($args['type'] == 'number') {
2682 2682
 										$type    = 'number';
2683
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2684
-									} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2683
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2684
+									} elseif ($args['type'] == 'select' && !empty($args['multiple'])) {
2685 2685
 										$type = 'array';
2686
-										if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2687
-											$default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2686
+										if (isset($args['default']) && is_array($args['default'])) {
2687
+											$default = !empty($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]";
2688 2688
 										} else {
2689
-											$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2689
+											$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2690 2690
 										}
2691
-									} elseif ( $args['type'] == 'tagselect' ) {
2691
+									} elseif ($args['type'] == 'tagselect') {
2692 2692
 										$type    = 'array';
2693
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2694
-									} elseif ( $args['type'] == 'multiselect' ) {
2693
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2694
+									} elseif ($args['type'] == 'multiselect') {
2695 2695
 										$type    = 'array';
2696
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2697
-									} elseif ( $args['type'] == 'image_xy' ) {
2696
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2697
+									} elseif ($args['type'] == 'image_xy') {
2698 2698
 										$type    = 'object';
2699
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2700
-									} elseif ( $args['type'] == 'image' ) {
2699
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2700
+									} elseif ($args['type'] == 'image') {
2701 2701
 										$type    = 'string';
2702
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2702
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2703 2703
 
2704 2704
 										// add a field for ID
2705 2705
 	//                                    echo $key . "_id : {";
@@ -2711,7 +2711,7 @@  discard block
 block discarded – undo
2711 2711
 
2712 2712
 									} else {
2713 2713
 										$type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2714
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2714
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2715 2715
 
2716 2716
 									}
2717 2717
 									echo $key . " : {";
@@ -2724,7 +2724,7 @@  discard block
 block discarded – undo
2724 2724
 							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2725 2725
 							echo "sd_shortcode : {type : 'string',default: ''},";
2726 2726
 
2727
-							if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
2727
+							if (!empty($this->options['nested-block']) || !empty($this->arguments['html'])) {
2728 2728
 								echo "sd_shortcode_close : {type : 'string',default: ''},";
2729 2729
 							}
2730 2730
 
@@ -2743,7 +2743,7 @@  discard block
 block discarded – undo
2743 2743
 
2744 2744
 <?php
2745 2745
 // only include the drag/drop functions if required.
2746
-if( $img_drag_drop ){
2746
+if ($img_drag_drop) {
2747 2747
 
2748 2748
 ?>
2749 2749
 
@@ -2809,9 +2809,9 @@  discard block
 block discarded – undo
2809 2809
 							}
2810 2810
 
2811 2811
 							<?php
2812
-							if(!empty($this->options['block-edit-raw'])) {
2812
+							if (!empty($this->options['block-edit-raw'])) {
2813 2813
 								echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2814
-							}else{
2814
+							} else {
2815 2815
 							?>
2816 2816
 
2817 2817
 function hasSelectedInnerBlock(props) {
@@ -2835,7 +2835,7 @@  discard block
 block discarded – undo
2835 2835
 	var $value = '';
2836 2836
 	<?php
2837 2837
 	// if we have a post_type and a category then link them
2838
-	if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2838
+	if (isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked'])) {
2839 2839
 	?>
2840 2840
 	if(typeof(prev_attributes[props.clientId]) != 'undefined' && selectedBlock && selectedBlock.clientId === props.clientId){
2841 2841
 		$pt = props.attributes.post_type;
@@ -2850,9 +2850,9 @@  discard block
 block discarded – undo
2850 2850
 		}
2851 2851
 <?php
2852 2852
 	$cat_path = '';
2853
-	if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) {
2854
-		$cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) );
2855
-		$cat_path = str_replace( array( '&quot;', '&#039;' ), array( '"', "'" ), $cat_path );
2853
+	if (!empty($this->arguments['post_type']['onchange_rest']['path'])) {
2854
+		$cat_path = esc_js(strip_tags($this->arguments['post_type']['onchange_rest']['path']));
2855
+		$cat_path = str_replace(array('&quot;', '&#039;'), array('"', "'"), $cat_path);
2856 2856
 	}
2857 2857
 ?>
2858 2858
 		/* taxonomies */
@@ -2860,15 +2860,15 @@  discard block
 block discarded – undo
2860 2860
 			if (!window.gdCPTCats) {
2861 2861
 				window.gdCPTCats = [];
2862 2862
 			}
2863
-			var gdCatPath = "<?php echo ( ! empty( $cat_path ) ? $cat_path : "/wp/v2/" + $value + "/categories/?per_page=100" ); ?>";
2863
+			var gdCatPath = "<?php echo (!empty($cat_path) ? $cat_path : "/wp/v2/" +$value + "/categories/?per_page=100"); ?>";
2864 2864
 			if (window.gdCPTCats[gdCatPath]) {
2865 2865
 				terms = window.gdCPTCats[gdCatPath];
2866
-				while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) {
2867
-					taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop();
2866
+				while (taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2867
+					taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2868 2868
 				}
2869
-				taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: "All", value: 0});
2869
+				taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: "All", value: 0});
2870 2870
 				jQuery.each( terms, function( key, val ) {
2871
-					taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: val.name, value: val.id});
2871
+					taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val.name, value: val.id});
2872 2872
 				});
2873 2873
 
2874 2874
 				/* Setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. */
@@ -2878,12 +2878,12 @@  discard block
 block discarded – undo
2878 2878
 			} else {
2879 2879
 				wp.apiFetch({path: gdCatPath}).then(terms => {
2880 2880
 					window.gdCPTCats[gdCatPath] = terms;
2881
-					while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) {
2882
-						taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop();
2881
+					while (taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2882
+						taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2883 2883
 					}
2884
-					taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: "All", value: 0});
2884
+					taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: "All", value: 0});
2885 2885
 					jQuery.each( terms, function( key, val ) {
2886
-						taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: val.name, value: val.id});
2886
+						taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val.name, value: val.id});
2887 2887
 					});
2888 2888
 
2889 2889
 					/* Setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. */
@@ -2891,7 +2891,7 @@  discard block
 block discarded – undo
2891 2891
 					props.setAttributes({category: [0] });
2892 2892
 					props.setAttributes({category: $old_cat_value });
2893 2893
 
2894
-					return taxonomies_<?php echo str_replace("-","_", $this->id);?>;
2894
+					return taxonomies_<?php echo str_replace("-", "_", $this->id); ?>;
2895 2895
 				});
2896 2896
 			}
2897 2897
 		}
@@ -2903,12 +2903,12 @@  discard block
 block discarded – undo
2903 2903
 			}
2904 2904
 			if (window.gdCPTSort[$pt]) {
2905 2905
 				response = window.gdCPTSort[$pt];
2906
-				while (sort_by_<?php echo str_replace("-","_", $this->id);?>.length) {
2907
-					sort_by_<?php echo str_replace("-","_", $this->id);?>.pop();
2906
+				while (sort_by_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2907
+					sort_by_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2908 2908
 				}
2909 2909
 
2910 2910
 				jQuery.each( response, function( key, val ) {
2911
-					sort_by_<?php echo str_replace("-","_", $this->id);?>.push({label: val, value: key});
2911
+					sort_by_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val, value: key});
2912 2912
 				});
2913 2913
 
2914 2914
 				// setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options.
@@ -2923,12 +2923,12 @@  discard block
 block discarded – undo
2923 2923
 				jQuery.post(ajaxurl, data, function(response) {
2924 2924
 					response = JSON.parse(response);
2925 2925
 					window.gdCPTSort[$pt] = response;
2926
-					while (sort_by_<?php echo str_replace("-","_", $this->id);?>.length) {
2927
-						sort_by_<?php echo str_replace("-","_", $this->id);?>.pop();
2926
+					while (sort_by_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2927
+						sort_by_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2928 2928
 					}
2929 2929
 
2930 2930
 					jQuery.each( response, function( key, val ) {
2931
-						sort_by_<?php echo str_replace("-","_", $this->id);?>.push({label: val, value: key});
2931
+						sort_by_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val, value: key});
2932 2932
 					});
2933 2933
 
2934 2934
 					// setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options.
@@ -2936,7 +2936,7 @@  discard block
 block discarded – undo
2936 2936
 					props.setAttributes({sort_by: [0] });
2937 2937
 					props.setAttributes({sort_by: $old_sort_by_value });
2938 2938
 
2939
-					return sort_by_<?php echo str_replace("-","_", $this->id);?>;
2939
+					return sort_by_<?php echo str_replace("-", "_", $this->id); ?>;
2940 2940
 				});
2941 2941
 			}
2942 2942
 		}
@@ -2944,9 +2944,9 @@  discard block
 block discarded – undo
2944 2944
 	<?php } ?>
2945 2945
 <?php
2946 2946
 $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2947
-if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2947
+if (!empty($current_screen->base) && $current_screen->base === 'widgets') {
2948 2948
 	echo 'const { deviceType } = "";';
2949
-}else{
2949
+} else {
2950 2950
 ?>
2951 2951
 /** Get device type const. */
2952 2952
 const wpVersion = '<?php global $wp_version; echo esc_attr($wp_version); ?>';
@@ -3005,13 +3005,13 @@  discard block
 block discarded – undo
3005 3005
 
3006 3006
 									var data = {
3007 3007
 										'action': 'super_duper_output_shortcode',
3008
-										'shortcode': '<?php echo $this->options['base_id'];?>',
3008
+										'shortcode': '<?php echo $this->options['base_id']; ?>',
3009 3009
 										'attributes': props.attributes,
3010 3010
 										'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '',
3011
-										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
3011
+										'post_id': <?php global $post; if (isset($post->ID)) {
3012 3012
 										echo $post->ID;
3013
-									}else{echo '0';}?>,
3014
-										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
3013
+									} else {echo '0'; }?>,
3014
+										'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
3015 3015
 									};
3016 3016
 
3017 3017
 									jQuery.post(ajaxurl, data, function (response) {
@@ -3020,17 +3020,17 @@  discard block
 block discarded – undo
3020 3020
 
3021 3021
 										// if the content is empty then we place some placeholder text
3022 3022
 										if (env == '') {
3023
-											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for:', 'ayecode-connect' );?> " + props.name + "</div>";
3023
+											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for:', 'ayecode-connect'); ?> " + props.name + "</div>";
3024 3024
 										}
3025 3025
 
3026 3026
 										 <?php
3027
-										if(!empty($this->options['nested-block'])){
3027
+										if (!empty($this->options['nested-block'])) {
3028 3028
 											?>
3029 3029
 											// props.setAttributes({content: env});
3030 3030
 										is_fetching = false;
3031 3031
 										prev_attributes[props.clientId] = props.attributes;
3032 3032
 											 <?php
3033
-										}else{
3033
+										} else {
3034 3034
 										?>
3035 3035
 										props.setAttributes({content: env});
3036 3036
 										is_fetching = false;
@@ -3056,38 +3056,38 @@  discard block
 block discarded – undo
3056 3056
 							}
3057 3057
 
3058 3058
 							<?php
3059
-							if(!empty($this->options['block-edit-js'])) {
3060
-								echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
3059
+							if (!empty($this->options['block-edit-js'])) {
3060
+								echo  $this->options['block-edit-js']; // strings have to be in single quotes, may cause issues
3061 3061
 							}
3062 3062
 
3063 3063
 
3064 3064
 
3065 3065
 
3066
-							if(empty($this->options['block-save-return'])){
3066
+							if (empty($this->options['block-save-return'])) {
3067 3067
 							?>
3068 3068
 								///////////////////////////////////////////////////////////////////////
3069 3069
 
3070 3070
 									 // build the shortcode.
3071
-								shortcode = "[<?php echo $this->options['base_id'];?>";
3071
+								shortcode = "[<?php echo $this->options['base_id']; ?>";
3072 3072
 								<?php
3073 3073
 
3074
-								if(! empty( $this->arguments )){
3074
+								if (!empty($this->arguments)) {
3075 3075
 
3076
-								foreach($this->arguments as $key => $args){
3076
+								foreach ($this->arguments as $key => $args) {
3077 3077
 								   // if($args['type']=='tabs'){continue;}
3078 3078
 
3079 3079
 								   // don't add metadata arguments
3080
-								   if (substr($key, 0, 9 ) === 'metadata_') {
3080
+								   if (substr($key, 0, 9) === 'metadata_') {
3081 3081
 									   continue;
3082 3082
 								   }
3083 3083
 								?>
3084
-								if (props.attributes.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3085
-									if ('<?php echo esc_attr( $key );?>' == 'html') {
3086
-									} else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') {
3087
-										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 +"}' " : "";
3084
+								if (props.attributes.hasOwnProperty("<?php echo esc_attr($key); ?>")) {
3085
+									if ('<?php echo esc_attr($key); ?>' == 'html') {
3086
+									} else if ('<?php echo esc_attr($args['type']); ?>' == 'image_xy') {
3087
+										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 +"}' " : "";
3088 3088
 									} else {
3089
-										//shortcode += props.attributes.<?php echo esc_attr( $key );?>.length ? " <?php echo esc_attr( $key );?>='" + props.attributes.<?php echo esc_attr( $key );?>.toString().replace('\'','&#39;') + "' " : "";
3090
-										shortcode +=  " <?php echo esc_attr( $key );?>='" + props.attributes.<?php echo esc_attr( $key );?>.toString().replace('\'','&#39;') + "' ";
3089
+										//shortcode += props.attributes.<?php echo esc_attr($key); ?>.length ? " <?php echo esc_attr($key); ?>='" + props.attributes.<?php echo esc_attr($key); ?>.toString().replace('\'','&#39;') + "' " : "";
3090
+										shortcode +=  " <?php echo esc_attr($key); ?>='" + props.attributes.<?php echo esc_attr($key); ?>.toString().replace('\'','&#39;') + "' ";
3091 3091
 									}
3092 3092
 								}
3093 3093
 								<?php
@@ -3106,8 +3106,8 @@  discard block
 block discarded – undo
3106 3106
 
3107 3107
 
3108 3108
 									<?php
3109
-									if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
3110
-										echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});";
3109
+									if (!empty($this->options['nested-block']) || !empty($this->arguments['html'])) {
3110
+										echo "props.setAttributes({sd_shortcode_close: '[/" . esc_attr($this->options['base_id']) . "]'});";
3111 3111
 									}
3112 3112
 									?>
3113 3113
 								}
@@ -3122,7 +3122,7 @@  discard block
 block discarded – undo
3122 3122
 
3123 3123
 								el(wp.blockEditor.BlockControls, {key: 'controls'},
3124 3124
 
3125
-									<?php if($show_alignment){?>
3125
+									<?php if ($show_alignment) {?>
3126 3126
 									el(
3127 3127
 										wp.blockEditor.AlignmentToolbar,
3128 3128
 										{
@@ -3140,9 +3140,9 @@  discard block
 block discarded – undo
3140 3140
 
3141 3141
 									<?php
3142 3142
 
3143
-									if(! empty( $this->arguments )){
3143
+									if (!empty($this->arguments)) {
3144 3144
 
3145
-									if ( $show_advanced ) {
3145
+									if ($show_advanced) {
3146 3146
 									?>
3147 3147
 									el('div', {
3148 3148
 											style: {'padding-left': '16px','padding-right': '16px'}
@@ -3162,42 +3162,42 @@  discard block
 block discarded – undo
3162 3162
 									<?php
3163 3163
 									}
3164 3164
 
3165
-									$arguments = $this->group_arguments( $this->arguments );
3166
-									$block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array();
3165
+									$arguments = $this->group_arguments($this->arguments);
3166
+									$block_group_tabs = !empty($this->options['block_group_tabs']) ? $this->group_block_tabs($this->options['block_group_tabs'], $arguments) : array();
3167 3167
 
3168 3168
 									// Do we have sections?
3169 3169
 									$has_sections = $arguments == $this->arguments ? false : true;
3170 3170
 
3171
-									if($has_sections){
3171
+									if ($has_sections) {
3172 3172
 									$panel_count = 0;
3173 3173
 									$open_tab = '';
3174 3174
 
3175 3175
 									$open_tab_groups = array();
3176 3176
 									$used_tabs = array();
3177 3177
 
3178
-									foreach ( $arguments as $key => $args ) {
3178
+									foreach ($arguments as $key => $args) {
3179 3179
 										$close_tab = false;
3180 3180
 										$close_tabs = false;
3181 3181
 
3182
-										 if ( ! empty( $block_group_tabs ) ) {
3183
-											foreach ( $block_group_tabs as $tab_name => $tab_args ) {
3184
-												if ( in_array( $key, $tab_args['groups'] ) ) {
3182
+										 if (!empty($block_group_tabs)) {
3183
+											foreach ($block_group_tabs as $tab_name => $tab_args) {
3184
+												if (in_array($key, $tab_args['groups'])) {
3185 3185
 													$open_tab_groups[] = $key;
3186 3186
 
3187
-													if ( $open_tab != $tab_name ) {
3187
+													if ($open_tab != $tab_name) {
3188 3188
 														$tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
3189 3189
 														$tab_args['tab']['open'] = true;
3190 3190
 
3191
-														$this->block_tab_start( '', $tab_args );
3191
+														$this->block_tab_start('', $tab_args);
3192 3192
 														$open_tab = $tab_name;
3193 3193
 														$used_tabs[] = $tab_name;
3194 3194
 													}
3195 3195
 
3196
-													if ( $open_tab_groups == $tab_args['groups'] ) {
3196
+													if ($open_tab_groups == $tab_args['groups']) {
3197 3197
 														$close_tab = true;
3198 3198
 														$open_tab_groups = array();
3199 3199
 
3200
-														if ( $used_tabs == array_keys( $block_group_tabs ) ) {
3200
+														if ($used_tabs == array_keys($block_group_tabs)) {
3201 3201
 															$close_tabs = true;
3202 3202
 														}
3203 3203
 													}
@@ -3206,27 +3206,27 @@  discard block
 block discarded – undo
3206 3206
 										}
3207 3207
 										?>
3208 3208
 										el(wp.components.PanelBody, {
3209
-												title: '<?php esc_attr_e( $key ); ?>',
3210
-												initialOpen: <?php if ( $panel_count ) {
3209
+												title: '<?php esc_attr_e($key); ?>',
3210
+												initialOpen: <?php if ($panel_count) {
3211 3211
 												echo "false";
3212 3212
 											} else {
3213 3213
 												echo "true";
3214 3214
 											}?>
3215 3215
 											},
3216 3216
 											<?php
3217
-											foreach ( $args as $k => $a ) {
3218
-												$this->block_tab_start( $k, $a );
3219
-												$this->block_row_start( $k, $a );
3220
-												$this->build_block_arguments( $k, $a );
3221
-												$this->block_row_end( $k, $a );
3222
-												$this->block_tab_end( $k, $a );
3217
+											foreach ($args as $k => $a) {
3218
+												$this->block_tab_start($k, $a);
3219
+												$this->block_row_start($k, $a);
3220
+												$this->build_block_arguments($k, $a);
3221
+												$this->block_row_end($k, $a);
3222
+												$this->block_tab_end($k, $a);
3223 3223
 											}
3224 3224
 											?>
3225 3225
 										),
3226 3226
 										<?php
3227
-										$panel_count ++;
3227
+										$panel_count++;
3228 3228
 
3229
-										if($close_tab || $close_tabs){
3229
+										if ($close_tab || $close_tabs) {
3230 3230
 											$tab_args = array(
3231 3231
 												'tab'	=> array(
3232 3232
 													'tabs_close' => $close_tabs,
@@ -3234,24 +3234,24 @@  discard block
 block discarded – undo
3234 3234
 												)
3235 3235
 
3236 3236
 											);
3237
-											$this->block_tab_end( '', $tab_args );
3237
+											$this->block_tab_end('', $tab_args);
3238 3238
 //											echo '###close'; print_r($tab_args);
3239 3239
 											$panel_count = 0;
3240 3240
 										}
3241 3241
 //
3242 3242
 
3243 3243
 									}
3244
-									}else {
3244
+									} else {
3245 3245
 									?>
3246 3246
 									el(wp.components.PanelBody, {
3247
-											title: '<?php esc_attr_e( "Settings", 'ayecode-connect' ); ?>',
3247
+											title: '<?php esc_attr_e("Settings", 'ayecode-connect'); ?>',
3248 3248
 											initialOpen: true
3249 3249
 										},
3250 3250
 										<?php
3251
-										foreach ( $this->arguments as $key => $args ) {
3252
-											$this->block_row_start( $key, $args );
3253
-											$this->build_block_arguments( $key, $args );
3254
-											$this->block_row_end( $key, $args );
3251
+										foreach ($this->arguments as $key => $args) {
3252
+											$this->block_row_start($key, $args);
3253
+											$this->build_block_arguments($key, $args);
3254
+											$this->block_row_end($key, $args);
3255 3255
 										}
3256 3256
 										?>
3257 3257
 									),
@@ -3265,11 +3265,11 @@  discard block
 block discarded – undo
3265 3265
 
3266 3266
 								<?php
3267 3267
 								// If the user sets block-output array then build it
3268
-								if ( ! empty( $this->options['block-output'] ) ) {
3269
-								$this->block_element( $this->options['block-output'] );
3270
-							}elseif(!empty($this->options['block-edit-return'])){
3268
+								if (!empty($this->options['block-output'])) {
3269
+								$this->block_element($this->options['block-output']);
3270
+							}elseif (!empty($this->options['block-edit-return'])) {
3271 3271
 								   echo $this->options['block-edit-return'];
3272
-							}else{
3272
+							} else {
3273 3273
 								// if no block-output is set then we try and get the shortcode html output via ajax.
3274 3274
 								$block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3275 3275
 								?>
@@ -3296,27 +3296,27 @@  discard block
 block discarded – undo
3296 3296
 							var align = '';
3297 3297
 
3298 3298
 							// build the shortcode.
3299
-							var content = "[<?php echo $this->options['base_id'];?>";
3299
+							var content = "[<?php echo $this->options['base_id']; ?>";
3300 3300
 							$html = '';
3301 3301
 							<?php
3302 3302
 
3303
-							if(! empty( $this->arguments )){
3303
+							if (!empty($this->arguments)) {
3304 3304
 
3305
-							foreach($this->arguments as $key => $args){
3305
+							foreach ($this->arguments as $key => $args) {
3306 3306
 							   // if($args['type']=='tabs'){continue;}
3307 3307
 
3308 3308
 							   // don't add metadata arguments
3309
-							   if (substr($key, 0, 9 ) === 'metadata_') {
3309
+							   if (substr($key, 0, 9) === 'metadata_') {
3310 3310
 								   continue;
3311 3311
 							   }
3312 3312
 							?>
3313
-							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3314
-								if ('<?php echo esc_attr( $key );?>' == 'html') {
3315
-									$html = attr.<?php echo esc_attr( $key );?>;
3316
-								} else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') {
3317
-									content += " <?php echo esc_attr( $key );?>='{x:" + attr.<?php echo esc_attr( $key );?>.x + ",y:"+attr.<?php echo esc_attr( $key );?>.y +"}' ";
3313
+							if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) {
3314
+								if ('<?php echo esc_attr($key); ?>' == 'html') {
3315
+									$html = attr.<?php echo esc_attr($key); ?>;
3316
+								} else if ('<?php echo esc_attr($args['type']); ?>' == 'image_xy') {
3317
+									content += " <?php echo esc_attr($key); ?>='{x:" + attr.<?php echo esc_attr($key); ?>.x + ",y:"+attr.<?php echo esc_attr($key); ?>.y +"}' ";
3318 3318
 								} else {
3319
-									content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>.toString().replace('\'','&#39;') + "' ";
3319
+									content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>.toString().replace('\'','&#39;') + "' ";
3320 3320
 								}
3321 3321
 							}
3322 3322
 							<?php
@@ -3336,7 +3336,7 @@  discard block
 block discarded – undo
3336 3336
 							?>
3337 3337
 							// if has html element
3338 3338
 							if ($html) {
3339
-								//content += $html + "[/<?php echo $this->options['base_id'];?>]";
3339
+								//content += $html + "[/<?php echo $this->options['base_id']; ?>]";
3340 3340
 							}
3341 3341
 
3342 3342
 							// @todo should we add inline style here or just css classes?
@@ -3366,7 +3366,7 @@  discard block
 block discarded – undo
3366 3366
 //                                <x?php
3367 3367
 //							}else
3368 3368
 
3369
-							if(!empty($this->options['block-output'])){
3369
+							if (!empty($this->options['block-output'])) {
3370 3370
 //                               echo "return";
3371 3371
 //                               $this->block_element( $this->options['block-output'], true );
3372 3372
 //                               echo ";";
@@ -3376,30 +3376,30 @@  discard block
 block discarded – undo
3376 3376
 								   '',
3377 3377
 								   {},
3378 3378
 								  // el('', {dangerouslySetInnerHTML: {__html: content}}),
3379
-								   <?php $this->block_element( $this->options['block-output'], true ); ?>
3380
-								  // el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3379
+								   <?php $this->block_element($this->options['block-output'], true); ?>
3380
+								  // el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}})
3381 3381
 							   );
3382 3382
 								<?php
3383 3383
 
3384
-							}elseif(!empty($this->options['block-save-return'])){
3384
+							}elseif (!empty($this->options['block-save-return'])) {
3385 3385
 								   echo 'return ' . $this->options['block-save-return'];
3386
-							}elseif(!empty($this->options['nested-block'])){
3386
+							}elseif (!empty($this->options['nested-block'])) {
3387 3387
 								?>
3388 3388
 							  return el(
3389 3389
 								   '',
3390 3390
 								   {},
3391 3391
 								   el('', {dangerouslySetInnerHTML: {__html: content+"\n"}}),
3392 3392
 								   InnerBlocks.Content ? el( InnerBlocks.Content ) : '', // @todo i think we need a comma here
3393
-								 //  el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3393
+								 //  el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}})
3394 3394
 							   );
3395 3395
 								<?php
3396
-							}elseif(!empty( $this->options['block-save-return'] ) ){
3397
-								echo "return ". $this->options['block-edit-return'].";";
3398
-							}elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3396
+							}elseif (!empty($this->options['block-save-return'])) {
3397
+								echo "return " . $this->options['block-edit-return'] . ";";
3398
+							}elseif (isset($this->options['block-wrap']) && $this->options['block-wrap'] == '') {
3399 3399
 							?>
3400 3400
 							return content;
3401 3401
 							<?php
3402
-							}else{
3402
+							} else {
3403 3403
 							?>
3404 3404
 							var block_wrap = 'div';
3405 3405
 							if (attr.hasOwnProperty("block_wrap")) {
@@ -3428,48 +3428,48 @@  discard block
 block discarded – undo
3428 3428
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
3429 3429
 			 */
3430 3430
 
3431
-			return str_replace( array(
3431
+			return str_replace(array(
3432 3432
 				'<script>',
3433 3433
 				'</script>'
3434
-			), '', $output );
3434
+			), '', $output);
3435 3435
 		}
3436 3436
 
3437 3437
 
3438 3438
 
3439
-		public function block_row_start($key, $args){
3439
+		public function block_row_start($key, $args) {
3440 3440
 
3441 3441
 			// check for row
3442
-			if(!empty($args['row'])){
3442
+			if (!empty($args['row'])) {
3443 3443
 
3444
-				if(!empty($args['row']['open'])){
3444
+				if (!empty($args['row']['open'])) {
3445 3445
 
3446 3446
 				// element require
3447
-				$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3448
-				$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3449
-				$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3447
+				$element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : "";
3448
+				$device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : '';
3449
+				$device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3450 3450
 				$device_type_icon = '';
3451
-				if($device_type=='Desktop'){
3451
+				if ($device_type == 'Desktop') {
3452 3452
 					$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3453
-				}elseif($device_type=='Tablet'){
3453
+				}elseif ($device_type == 'Tablet') {
3454 3454
 					$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3455
-				}elseif($device_type=='Mobile'){
3455
+				}elseif ($device_type == 'Mobile') {
3456 3456
 					$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3457 3457
 				}
3458 3458
 				echo $element_require;
3459 3459
 				echo $device_type_require;
3460 3460
 
3461
-					if(false){?><script><?php }?>
3461
+					if (false) {?><script><?php }?>
3462 3462
 						el('div', {
3463 3463
 								className: 'bsui components-base-control',
3464 3464
 							},
3465
-							<?php if(!empty($args['row']['title'])){ ?>
3465
+							<?php if (!empty($args['row']['title'])) { ?>
3466 3466
 							el('label', {
3467 3467
 									className: 'components-base-control__label position-relative',
3468 3468
 									style: {width:"100%"}
3469 3469
 								},
3470
-								el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['row']['title'] ) ?>'}}),
3471
-								<?php if($device_type_icon){ ?>
3472
-									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)"}})
3470
+								el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes($args['row']['title']) ?>'}}),
3471
+								<?php if ($device_type_icon) { ?>
3472
+									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)"}})
3473 3473
 								<?php
3474 3474
 								}
3475 3475
 								?>
@@ -3477,17 +3477,17 @@  discard block
 block discarded – undo
3477 3477
 
3478 3478
 							),
3479 3479
 							<?php }?>
3480
-							<?php if(!empty($args['row']['desc'])){ ?>
3480
+							<?php if (!empty($args['row']['desc'])) { ?>
3481 3481
 							el('p', {
3482 3482
 									className: 'components-base-control__help mb-0',
3483 3483
 								},
3484
-								'<?php echo addslashes( $args['row']['desc'] ); ?>'
3484
+								'<?php echo addslashes($args['row']['desc']); ?>'
3485 3485
 							),
3486 3486
 							<?php }?>
3487 3487
 							el(
3488 3488
 								'div',
3489 3489
 								{
3490
-									className: 'row mb-n2 <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>',
3490
+									className: 'row mb-n2 <?php if (!empty($args['row']['class'])) { echo esc_attr($args['row']['class']); } ?>',
3491 3491
 								},
3492 3492
 								el(
3493 3493
 									'div',
@@ -3496,36 +3496,36 @@  discard block
 block discarded – undo
3496 3496
 									},
3497 3497
 
3498 3498
 					<?php
3499
-					if(false){?></script><?php }
3500
-				}elseif(!empty($args['row']['close'])){
3501
-					if(false){?><script><?php }?>
3499
+					if (false) {?></script><?php }
3500
+				}elseif (!empty($args['row']['close'])) {
3501
+					if (false) {?><script><?php }?>
3502 3502
 						el(
3503 3503
 							'div',
3504 3504
 							{
3505 3505
 								className: 'col pl-0 ps-0',
3506 3506
 							},
3507 3507
 					<?php
3508
-					if(false){?></script><?php }
3509
-				}else{
3510
-					if(false){?><script><?php }?>
3508
+					if (false) {?></script><?php }
3509
+				} else {
3510
+					if (false) {?><script><?php }?>
3511 3511
 						el(
3512 3512
 							'div',
3513 3513
 							{
3514 3514
 								className: 'col pl-0 ps-0 pr-2 pe-2',
3515 3515
 							},
3516 3516
 					<?php
3517
-					if(false){?></script><?php }
3517
+					if (false) {?></script><?php }
3518 3518
 				}
3519 3519
 
3520 3520
 			}
3521 3521
 
3522 3522
 		}
3523 3523
 
3524
-		public function block_row_end($key, $args){
3524
+		public function block_row_end($key, $args) {
3525 3525
 
3526
-			if(!empty($args['row'])){
3526
+			if (!empty($args['row'])) {
3527 3527
 				// maybe close
3528
-				if(!empty($args['row']['close'])){
3528
+				if (!empty($args['row']['close'])) {
3529 3529
 					echo "))";
3530 3530
 				}
3531 3531
 
@@ -3533,14 +3533,14 @@  discard block
 block discarded – undo
3533 3533
 			}
3534 3534
 		}
3535 3535
 
3536
-		public function block_tab_start($key, $args){
3536
+		public function block_tab_start($key, $args) {
3537 3537
 
3538 3538
 			// check for row
3539
-			if(!empty($args['tab'])){
3539
+			if (!empty($args['tab'])) {
3540 3540
 
3541
-				if(!empty($args['tab']['tabs_open'])){
3541
+				if (!empty($args['tab']['tabs_open'])) {
3542 3542
 
3543
-					if(false){?><script><?php }?>
3543
+					if (false) {?><script><?php }?>
3544 3544
 
3545 3545
 el('div',{className: 'bsui'},
3546 3546
 
@@ -3549,52 +3549,52 @@  discard block
 block discarded – undo
3549 3549
 									{
3550 3550
 										activeClass: 'is-active',
3551 3551
 										className: 'btn-groupx',
3552
-										initialTabName: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3552
+										initialTabName: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>',
3553 3553
 										tabs: [
3554 3554
 
3555 3555
 					<?php
3556
-					if(false){?></script><?php }
3556
+					if (false) {?></script><?php }
3557 3557
 				}
3558 3558
 
3559
-				if(!empty($args['tab']['open'])){
3559
+				if (!empty($args['tab']['open'])) {
3560 3560
 
3561
-					if(false){?><script><?php }?>
3561
+					if (false) {?><script><?php }?>
3562 3562
 							{
3563
-												name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3564
-												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}),
3565
-												className: '<?php echo addslashes( esc_attr( $args['tab']['class']) ); ?>',
3566
-												content: el('div',{}, <?php if(!empty($args['tab']['desc'])){ ?>el('p', {
3563
+												name: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>',
3564
+												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes(esc_attr($args['tab']['title'])); ?>'}}),
3565
+												className: '<?php echo addslashes(esc_attr($args['tab']['class'])); ?>',
3566
+												content: el('div',{}, <?php if (!empty($args['tab']['desc'])) { ?>el('p', {
3567 3567
 									className: 'components-base-control__help mb-0',
3568
-									dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'}
3568
+									dangerouslySetInnerHTML: {__html:'<?php echo addslashes($args['tab']['desc']); ?>'}
3569 3569
 								}),<?php }
3570
-					if(false){?></script><?php }
3570
+					if (false) {?></script><?php }
3571 3571
 				}
3572 3572
 
3573 3573
 			}
3574 3574
 
3575 3575
 		}
3576 3576
 
3577
-		public function block_tab_end($key, $args){
3577
+		public function block_tab_end($key, $args) {
3578 3578
 
3579
-			if(!empty($args['tab'])){
3579
+			if (!empty($args['tab'])) {
3580 3580
 				// maybe close
3581
-				if(!empty($args['tab']['close'])){
3581
+				if (!empty($args['tab']['close'])) {
3582 3582
 					echo ")}, /* tab close */";
3583 3583
 				}
3584 3584
 
3585
-				if(!empty($args['tab']['tabs_close'])){
3586
-					if(false){?><script><?php }?>
3585
+				if (!empty($args['tab']['tabs_close'])) {
3586
+					if (false) {?><script><?php }?>
3587 3587
 						]}, ( tab ) => {
3588 3588
 								return tab.content;
3589 3589
 							}
3590 3590
 						)), /* tabs close */
3591
-					<?php if(false){ ?></script><?php }
3591
+					<?php if (false) { ?></script><?php }
3592 3592
 				}
3593 3593
 			}
3594 3594
 		}
3595 3595
 
3596
-		public function build_block_arguments( $key, $args ) {
3597
-			$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3596
+		public function build_block_arguments($key, $args) {
3597
+			$custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
3598 3598
 			$options           = '';
3599 3599
 			$extra             = '';
3600 3600
 			$require           = '';
@@ -3602,28 +3602,28 @@  discard block
 block discarded – undo
3602 3602
 			$after_elements	   = '';
3603 3603
 
3604 3604
 			// `content` is a protected and special argument
3605
-			if ( $key == 'content' ) {
3605
+			if ($key == 'content') {
3606 3606
 				return;
3607 3607
 			}
3608 3608
 
3609
-			$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3610
-			$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3609
+			$device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : '';
3610
+			$device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3611 3611
 			$device_type_icon = '';
3612
-			if($device_type=='Desktop'){
3612
+			if ($device_type == 'Desktop') {
3613 3613
 				$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3614
-			}elseif($device_type=='Tablet'){
3614
+			}elseif ($device_type == 'Tablet') {
3615 3615
 				$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3616
-			}elseif($device_type=='Mobile'){
3616
+			}elseif ($device_type == 'Mobile') {
3617 3617
 				$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3618 3618
 			}
3619 3619
 
3620 3620
 			// icon
3621 3621
 			$icon = '';
3622
-			if( !empty( $args['icon'] ) ){
3622
+			if (!empty($args['icon'])) {
3623 3623
 				$icon .= "el('div', {";
3624
-									$icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3624
+									$icon .= "dangerouslySetInnerHTML: {__html: '" . self::get_widget_icon(esc_attr($args['icon'])) . "'},";
3625 3625
 									$icon .= "className: 'text-center',";
3626
-									$icon .= "title: '".addslashes( $args['title'] )."',";
3626
+									$icon .= "title: '" . addslashes($args['title']) . "',";
3627 3627
 								$icon .= "}),";
3628 3628
 
3629 3629
 				// blank title as its added to the icon.
@@ -3631,27 +3631,27 @@  discard block
 block discarded – undo
3631 3631
 			}
3632 3632
 
3633 3633
 			// require advanced
3634
-			$require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3634
+			$require_advanced = !empty($args['advanced']) ? "props.attributes.show_advanced && " : "";
3635 3635
 
3636 3636
 			// element require
3637
-			$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3637
+			$element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : "";
3638 3638
 
3639 3639
 
3640 3640
 			$onchange  = "props.setAttributes({ $key: $key } )";
3641
-			$onchangecomplete  = "";
3641
+			$onchangecomplete = "";
3642 3642
 			$value     = "props.attributes.$key";
3643
-			$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3644
-			if ( in_array( $args['type'], $text_type ) ) {
3643
+			$text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'colorx', 'range');
3644
+			if (in_array($args['type'], $text_type)) {
3645 3645
 				$type = 'TextControl';
3646 3646
 				// Save numbers as numbers and not strings
3647
-				if ( $args['type'] == 'number' ) {
3647
+				if ($args['type'] == 'number') {
3648 3648
 					$onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3649 3649
 				}
3650 3650
 
3651
-				if (substr($key, 0, 9 ) === 'metadata_') {
3652
-					$real_key = str_replace('metadata_','', $key );
3651
+				if (substr($key, 0, 9) === 'metadata_') {
3652
+					$real_key = str_replace('metadata_', '', $key);
3653 3653
 					$onchange = "props.setAttributes({ metadata: { $real_key: $key } } )";
3654
-					$value     = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3654
+					$value = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3655 3655
 				}
3656 3656
 			}
3657 3657
 //			else if ( $args['type'] == 'popup' ) {
@@ -3671,12 +3671,12 @@  discard block
 block discarded – undo
3671 3671
 //
3672 3672
 //				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3673 3673
 //			}
3674
-			else if ( $args['type'] == 'styleid' ) {
3674
+			else if ($args['type'] == 'styleid') {
3675 3675
 				$type = 'TextControl';
3676 3676
 				$args['type'] == 'text';
3677 3677
 				// Save numbers as numbers and not strings
3678
-				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3679
-			}else if ( $args['type'] == 'notice' ) {
3678
+				$value = "props.attributes.$key ? props.attributes.$key : ''";
3679
+			} else if ($args['type'] == 'notice') {
3680 3680
 
3681 3681
 				$notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3682 3682
 				$notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
@@ -3738,11 +3738,11 @@  discard block
 block discarded – undo
3738 3738
 							return;
3739 3739
 						}
3740 3740
 */
3741
-			elseif ( $args['type'] == 'color' ) {
3741
+			elseif ($args['type'] == 'color') {
3742 3742
 				$type = 'ColorPicker';
3743 3743
 				$onchange = "";
3744 3744
 				$extra = "color: $value,";
3745
-				if(!empty($args['disable_alpha'])){
3745
+				if (!empty($args['disable_alpha'])) {
3746 3746
 					$extra .= "disableAlpha: true,";
3747 3747
 				}
3748 3748
 				$onchangecomplete = "onChangeComplete: function($key) {
@@ -3751,7 +3751,7 @@  discard block
 block discarded – undo
3751 3751
 							$key: value
3752 3752
 						});
3753 3753
 					},";
3754
-			}elseif ( $args['type'] == 'gradient' ) {
3754
+			}elseif ($args['type'] == 'gradient') {
3755 3755
 				$type = 'GradientPicker';
3756 3756
 				$extra .= "gradients: [{
3757 3757
 			name: 'Vivid cyan blue to vivid purple',
@@ -3790,7 +3790,7 @@  discard block
 block discarded – undo
3790 3790
 			slug: 'cool-to-warm-spectrum',
3791 3791
 		}],";
3792 3792
 
3793
-			}elseif ( $args['type'] == 'image' ) {
3793
+			}elseif ($args['type'] == 'image') {
3794 3794
 //                print_r($args);
3795 3795
 
3796 3796
 				$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,{
@@ -3852,7 +3852,7 @@  discard block
 block discarded – undo
3852 3852
 				$onchange = "";
3853 3853
 
3854 3854
 				//$inside_elements = ",el('div',{},'file upload')";
3855
-			} else if ( $args['type'] == 'images' ) {
3855
+			} else if ($args['type'] == 'images') {
3856 3856
 				$img_preview = "props.attributes.$key && (function() {
3857 3857
 	let uploads = JSON.parse('['+props.attributes.$key+']');
3858 3858
 	let images = [];
@@ -3865,7 +3865,7 @@  discard block
 block discarded – undo
3865 3865
 			el('i',{
3866 3866
 				className: 'fas fa-times-circle text-danger position-absolute  ml-n2 mt-n1 bg-white rounded-circle c-pointer',
3867 3867
 				onClick: function() {
3868
-					aui_confirm('".esc_attr__('Are you sure?')."', '".esc_attr__('Delete')."', '".esc_attr__('Cancel')."', true).then(function(confirmed) {
3868
+					aui_confirm('" . esc_attr__('Are you sure?') . "', '" . esc_attr__('Delete') . "', '" . esc_attr__('Cancel') . "', true).then(function(confirmed) {
3869 3869
 						if (confirmed) {
3870 3870
 							let new_uploads = JSON.parse('['+props.attributes.$key+']');
3871 3871
 							new_uploads.splice(index, 1);
@@ -3928,36 +3928,36 @@  discard block
 block discarded – undo
3928 3928
 
3929 3929
 				//$inside_elements = ",el('div',{},'file upload')";
3930 3930
 			}
3931
-			elseif ( $args['type'] == 'checkbox' ) {
3931
+			elseif ($args['type'] == 'checkbox') {
3932 3932
 				$type = 'CheckboxControl';
3933 3933
 				$extra .= "checked: props.attributes.$key,";
3934 3934
 				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3935
-			} elseif ( $args['type'] == 'textarea' ) {
3935
+			} elseif ($args['type'] == 'textarea') {
3936 3936
 				$type = 'TextareaControl';
3937 3937
 
3938
-			} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3938
+			} elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') {
3939 3939
 				$type = 'SelectControl';
3940 3940
 
3941
-				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3942
-					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3943
-				}elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3944
-					$options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3945
-				}else {
3941
+				if ($args['name'] == 'category' && !empty($args['post_type_linked'])) {
3942
+					$options .= "options: taxonomies_" . str_replace("-", "_", $this->id) . ",";
3943
+				}elseif ($args['name'] == 'sort_by' && !empty($args['post_type_linked'])) {
3944
+					$options .= "options: sort_by_" . str_replace("-", "_", $this->id) . ",";
3945
+				} else {
3946 3946
 
3947
-					if ( ! empty( $args['options'] ) ) {
3947
+					if (!empty($args['options'])) {
3948 3948
 						$options .= "options: [";
3949
-						foreach ( $args['options'] as $option_val => $option_label ) {
3950
-							$options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },";
3949
+						foreach ($args['options'] as $option_val => $option_label) {
3950
+							$options .= "{ value: '" . esc_attr($option_val) . "', label: '" . esc_js(addslashes($option_label)) . "' },";
3951 3951
 						}
3952 3952
 						$options .= "],";
3953 3953
 					}
3954 3954
 				}
3955
-				if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3955
+				if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3956 3956
 					$extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3957 3957
 				}
3958 3958
 
3959
-				if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3960
-					$after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3959
+				if ($args['type'] == 'multiselect' || (isset($args['multiple']) && $args['multiple'])) {
3960
+					$after_elements .= "props.attributes.$key && el( wp.components.Button, {
3961 3961
 									  className: 'components-button components-circular-option-picker__clear is-secondary is-small',
3962 3962
 									  style: {margin:'-8px 0 8px 0',display: 'block'},
3963 3963
 									  onClick: function(){
@@ -3969,7 +3969,7 @@  discard block
 block discarded – undo
3969 3969
 									'Clear'
3970 3970
 							),";
3971 3971
 				}
3972
-			} elseif ( $args['type'] == 'tagselect' ) {
3972
+			} elseif ($args['type'] == 'tagselect') {
3973 3973
 //				$type = 'FormTokenField';
3974 3974
 //
3975 3975
 //				if ( ! empty( $args['options'] ) ) {
@@ -4004,19 +4004,19 @@  discard block
 block discarded – undo
4004 4004
 //				$value     = "[]";
4005 4005
 //				$extra .= ' __experimentalExpandOnFocus: true,';
4006 4006
 
4007
-			} else if ( $args['type'] == 'alignment' ) {
4007
+			} else if ($args['type'] == 'alignment') {
4008 4008
 				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
4009
-			} else if ( $args['type'] == 'margins' ) {
4009
+			} else if ($args['type'] == 'margins') {
4010 4010
 
4011
-			} else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) {
4011
+			} else if ($args['type'] == 'visibility_conditions' && (function_exists('wp_is_block_theme') && wp_is_block_theme())) {
4012 4012
 				$type = 'TextControl';
4013 4013
 				$value = "(props.attributes.$key ? props.attributes.$key : '')";
4014 4014
 				$args['type'] = 'text';
4015 4015
 				$options .= 'disabled:true,';
4016
-				$bsvc_title = esc_attr( addslashes( $args['title'] ) );
4017
-				$bsvc_body = $this->block_visibility_fields( $args );
4016
+				$bsvc_title = esc_attr(addslashes($args['title']));
4017
+				$bsvc_body = $this->block_visibility_fields($args);
4018 4018
 				// @TODO reset button
4019
-				$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>';
4019
+				$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>';
4020 4020
 				$after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, {
4021 4021
 						className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
4022 4022
 						onClick: function() {
@@ -4035,25 +4035,25 @@  discard block
 block discarded – undo
4035 4035
 									jQuery('.bs-vc-modal-form').trigger('change');
4036 4036
 								}
4037 4037
 							});
4038
-							aui_modal('" . $bsvc_title . "', '" . addslashes( $bsvc_body ) . "', '" . $bsvc_footer . "', true, 'bs-vc-modal', 'modal-lg', '');
4038
+							aui_modal('" . $bsvc_title . "', '" . addslashes($bsvc_body) . "', '" . $bsvc_footer . "', true, 'bs-vc-modal', 'modal-lg', '');
4039 4039
 							jQuery(document).off('change', '#bsvc_raw_value').on('change', '#bsvc_raw_value', function(e) {
4040 4040
 								props.setAttributes({" . $key . ": e.target.value});
4041 4041
 							});
4042 4042
 						}
4043 4043
 					},
4044
-					'" . addslashes( ! empty( $args['button_title'] ) ? $args['button_title'] : $args['title'] ) . "'
4044
+					'" . addslashes(!empty($args['button_title']) ? $args['button_title'] : $args['title']) . "'
4045 4045
 				) ),";
4046 4046
 			} else {
4047
-				return;// if we have not implemented the control then don't break the JS.
4047
+				return; // if we have not implemented the control then don't break the JS.
4048 4048
 			}
4049 4049
 
4050 4050
 			// color input does not show the labels so we add them
4051
-			if($args['type']=='color'){
4051
+			if ($args['type'] == 'color') {
4052 4052
 				// add show only if advanced
4053 4053
 				echo $require_advanced;
4054 4054
 				// add setting require if defined
4055 4055
 				echo $element_require;
4056
-				echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
4056
+				echo "el('div', {style: {'marginBottom': '8px'}}, '" . addslashes($args['title']) . "'),";
4057 4057
 			}
4058 4058
 
4059 4059
 			// add show only if advanced
@@ -4065,22 +4065,22 @@  discard block
 block discarded – undo
4065 4065
 			// icon
4066 4066
 			echo $icon;
4067 4067
 			?>
4068
-			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type  : "wp.components.".$type; ?>, {
4069
-			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
4070
-			} else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>,
4071
-			help: <?php echo ( isset( $args['desc'] ) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim( wp_kses_post( addslashes( $args['desc'] ) ) ) . "'}})" : "''" ); ?>,
4068
+			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components." . $type; ?>, {
4069
+			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
4070
+			} else { ?>'<?php echo addslashes(trim(esc_html($args['title']))); ?>'<?php } ?>,
4071
+			help: <?php echo (isset($args['desc']) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim(wp_kses_post(addslashes($args['desc']))) . "'}})" : "''"); ?>,
4072 4072
 			value: <?php echo $value; ?>,
4073
-			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
4074
-				echo "type: '" . addslashes( $args['type'] ) . "',";
4073
+			<?php if ($type == 'TextControl' && $args['type'] != 'text') {
4074
+				echo "type: '" . addslashes($args['type']) . "',";
4075 4075
 			} ?>
4076
-			<?php if ( ! empty( $args['placeholder'] ) ) {
4077
-				echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',";
4076
+			<?php if (!empty($args['placeholder'])) {
4077
+				echo "placeholder: '" . esc_js(addslashes(trim(esc_html($args['placeholder'])))) . "',";
4078 4078
 			} ?>
4079 4079
 			<?php echo $options; ?>
4080 4080
 			<?php echo $extra; ?>
4081 4081
 			<?php echo $custom_attributes; ?>
4082 4082
 			<?php echo $onchangecomplete; ?>
4083
-			<?php if ( $onchange ) { ?>
4083
+			<?php if ($onchange) { ?>
4084 4084
 			onChange: function ( <?php echo $key; ?> ) {
4085 4085
 				<?php echo $onchange; ?>
4086 4086
 			}
@@ -4099,15 +4099,15 @@  discard block
 block discarded – undo
4099 4099
 		 *@todo there is prob a faster way to do this, also we could add some validation here.
4100 4100
 		 *
4101 4101
 		 */
4102
-		public function array_to_attributes( $custom_attributes, $html = false ) {
4102
+		public function array_to_attributes($custom_attributes, $html = false) {
4103 4103
 			$attributes = '';
4104
-			if ( ! empty( $custom_attributes ) ) {
4104
+			if (!empty($custom_attributes)) {
4105 4105
 
4106
-				foreach ( $custom_attributes as $key => $val ) {
4107
-					if(is_array($val)){
4108
-						$attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4109
-					}else{
4110
-						$attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4106
+				foreach ($custom_attributes as $key => $val) {
4107
+					if (is_array($val)) {
4108
+						$attributes .= $key . ': {' . $this->array_to_attributes($val, $html) . '},';
4109
+					} else {
4110
+						$attributes .= $html ? " $key='$val' " : "'$key': '$val',";
4111 4111
 					}
4112 4112
 				}
4113 4113
 
@@ -4125,113 +4125,113 @@  discard block
 block discarded – undo
4125 4125
 		 *
4126 4126
 		 * @param $args
4127 4127
 		 */
4128
-		public function block_element( $args, $save = false ) {
4128
+		public function block_element($args, $save = false) {
4129 4129
 
4130 4130
 //            print_r($args);echo '###';exit;
4131 4131
 
4132
-			if ( ! empty( $args ) ) {
4133
-				foreach ( $args as $element => $new_args ) {
4132
+			if (!empty($args)) {
4133
+				foreach ($args as $element => $new_args) {
4134 4134
 
4135
-					if ( is_array( $new_args ) ) { // its an element
4135
+					if (is_array($new_args)) { // its an element
4136 4136
 
4137 4137
 
4138
-						if ( isset( $new_args['element'] ) ) {
4138
+						if (isset($new_args['element'])) {
4139 4139
 
4140
-							if ( isset( $new_args['element_require'] ) ) {
4141
-								echo str_replace( array(
4140
+							if (isset($new_args['element_require'])) {
4141
+								echo str_replace(array(
4142 4142
 										"'+",
4143 4143
 										"+'"
4144
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
4145
-								unset( $new_args['element_require'] );
4144
+									), '', $this->block_props_replace($new_args['element_require'])) . " &&  ";
4145
+								unset($new_args['element_require']);
4146 4146
 							}
4147 4147
 
4148
-							if($new_args['element']=='InnerBlocks'){
4148
+							if ($new_args['element'] == 'InnerBlocks') {
4149 4149
 								echo "\n el( InnerBlocks, {";
4150
-							}elseif($new_args['element']=='innerBlocksProps'){
4150
+							}elseif ($new_args['element'] == 'innerBlocksProps') {
4151 4151
 								$element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4152 4152
 							  //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4153 4153
 //                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4154 4154
 								echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4155 4155
 								echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
4156
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4156
+								echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : '';
4157 4157
 
4158 4158
 								echo "} ), {";
4159
-								echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
4159
+								echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element($new_args['innerBlocksProps'], $save) : '';
4160 4160
 							//    echo '###';
4161 4161
 
4162 4162
 							  //  echo '###';
4163
-							}elseif($new_args['element']=='BlocksProps'){
4163
+							}elseif ($new_args['element'] == 'BlocksProps') {
4164 4164
 
4165
-								if ( isset($new_args['if_inner_element']) ) {
4165
+								if (isset($new_args['if_inner_element'])) {
4166 4166
 									$element = $new_args['if_inner_element'];
4167
-								}else {
4168
-									$element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4167
+								} else {
4168
+									$element = isset($new_args['inner_element']) ? "'" . esc_attr($new_args['inner_element']) . "'" : "'div'";
4169 4169
 								}
4170 4170
 
4171 4171
 								unset($new_args['inner_element']);
4172 4172
 								echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
4173
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4173
+								echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : '';
4174 4174
 
4175 4175
 
4176 4176
 							   // echo "} ),";
4177 4177
 
4178
-							}else{
4178
+							} else {
4179 4179
 								echo "\n el( '" . $new_args['element'] . "', {";
4180 4180
 							}
4181 4181
 
4182 4182
 
4183 4183
 							// get the attributes
4184
-							foreach ( $new_args as $new_key => $new_value ) {
4184
+							foreach ($new_args as $new_key => $new_value) {
4185 4185
 
4186 4186
 
4187
-								if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
4187
+								if ($new_key == 'element' || $new_key == 'content' || $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) {
4188 4188
 									// do nothing
4189 4189
 								} else {
4190
-									echo $this->block_element( array( $new_key => $new_value ),$save );
4190
+									echo $this->block_element(array($new_key => $new_value), $save);
4191 4191
 								}
4192 4192
 							}
4193 4193
 
4194
-							echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
4194
+							echo $new_args['element'] == 'BlocksProps' ? '} ),' : "},"; // end attributes
4195 4195
 
4196 4196
 							// get the content
4197 4197
 							$first_item = 0;
4198
-							foreach ( $new_args as $new_key => $new_value ) {
4199
-								if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
4198
+							foreach ($new_args as $new_key => $new_value) {
4199
+								if ($new_key === 'content' || $new_key === 'if_content' || is_array($new_value)) {
4200 4200
 
4201
-									if ( $new_key === 'content' ) {
4202
-										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4203
-									}else if ( $new_key === 'if_content' ) {
4204
-										echo  $this->block_props_replace(  $new_value  );
4201
+									if ($new_key === 'content') {
4202
+										echo "'" . $this->block_props_replace(wp_slash($new_value)) . "'";
4203
+									} else if ($new_key === 'if_content') {
4204
+										echo  $this->block_props_replace($new_value);
4205 4205
 									}
4206 4206
 
4207
-									if ( is_array( $new_value ) ) {
4207
+									if (is_array($new_value)) {
4208 4208
 
4209
-										if ( isset( $new_value['element_require'] ) ) {
4210
-											echo str_replace( array(
4209
+										if (isset($new_value['element_require'])) {
4210
+											echo str_replace(array(
4211 4211
 													"'+",
4212 4212
 													"+'"
4213
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
4214
-											unset( $new_value['element_require'] );
4213
+												), '', $this->block_props_replace($new_value['element_require'])) . " &&  ";
4214
+											unset($new_value['element_require']);
4215 4215
 										}
4216 4216
 
4217
-										if ( isset( $new_value['element_repeat'] ) ) {
4217
+										if (isset($new_value['element_repeat'])) {
4218 4218
 											$x = 1;
4219
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
4220
-												$this->block_element( array( '' => $new_value ),$save );
4221
-												$x ++;
4219
+											while ($x <= absint($new_value['element_repeat'])) {
4220
+												$this->block_element(array('' => $new_value), $save);
4221
+												$x++;
4222 4222
 											}
4223 4223
 										} else {
4224
-											$this->block_element( array( '' => $new_value ),$save );
4224
+											$this->block_element(array('' => $new_value), $save);
4225 4225
 										}
4226 4226
 									}
4227
-									$first_item ++;
4227
+									$first_item++;
4228 4228
 								}
4229 4229
 							}
4230 4230
 
4231
-							if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4232
-								echo "))";// end content
4233
-							}else{
4234
-								echo ")";// end content
4231
+							if ($new_args['element'] == 'innerBlocksProps' || $new_args['element'] == 'xBlocksProps') {
4232
+								echo "))"; // end content
4233
+							} else {
4234
+								echo ")"; // end content
4235 4235
 							}
4236 4236
 
4237 4237
 
@@ -4240,26 +4240,26 @@  discard block
 block discarded – undo
4240 4240
 						}
4241 4241
 					} else {
4242 4242
 
4243
-						if ( substr( $element, 0, 3 ) === "if_" ) {
4243
+						if (substr($element, 0, 3) === "if_") {
4244 4244
 							$extra = '';
4245
-							if( strpos($new_args, '[%WrapClass%]') !== false ){
4246
-								$new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
4247
-								$new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
4245
+							if (strpos($new_args, '[%WrapClass%]') !== false) {
4246
+								$new_args = str_replace('[%WrapClass%]"', '" + sd_build_aui_class(props.attributes)', $new_args);
4247
+								$new_args = str_replace('[%WrapClass%]', '+ sd_build_aui_class(props.attributes)', $new_args);
4248 4248
 							}
4249
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
4250
-						} elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
4251
-							$new_args = str_replace('[%WrapStyle%]','',$new_args);
4252
-							echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
4249
+							echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ",";
4250
+						} elseif ($element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false) {
4251
+							$new_args = str_replace('[%WrapStyle%]', '', $new_args);
4252
+							echo $element . ": {..." . $this->block_props_replace($new_args) . " , ...sd_build_aui_styles(props.attributes) },";
4253 4253
 //                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4254
-						} elseif ( $element == 'style' ) {
4255
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4256
-						} elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
4257
-							$new_args = str_replace('[%WrapClass%]','',$new_args);
4258
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
4259
-						} elseif ( $element == 'template' && $new_args ) {
4254
+						} elseif ($element == 'style') {
4255
+							echo $element . ": " . $this->block_props_replace($new_args) . ",";
4256
+						} elseif (($element == 'class' || $element == 'className') && strpos($new_args, '[%WrapClass%]') !== false) {
4257
+							$new_args = str_replace('[%WrapClass%]', '', $new_args);
4258
+							echo $element . ": '" . $this->block_props_replace($new_args) . "' + sd_build_aui_class(props.attributes),";
4259
+						} elseif ($element == 'template' && $new_args) {
4260 4260
 							echo $element . ": $new_args,";
4261 4261
 						} else {
4262
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
4262
+							echo $element . ": '" . $this->block_props_replace($new_args) . "',";
4263 4263
 						}
4264 4264
 
4265 4265
 					}
@@ -4274,11 +4274,11 @@  discard block
 block discarded – undo
4274 4274
 		 *
4275 4275
 		 * @return mixed
4276 4276
 		 */
4277
-		public function block_props_replace( $string, $no_wrap = false ) {
4278
-			if ( $no_wrap ) {
4279
-				$string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string );
4277
+		public function block_props_replace($string, $no_wrap = false) {
4278
+			if ($no_wrap) {
4279
+				$string = str_replace(array("[%", "%]", "%:checked]"), array("props.attributes.", "", ""), $string);
4280 4280
 			} else {
4281
-				$string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string );
4281
+				$string = str_replace(array("![%", "[%", "%]", "%:checked]"), array("'+!props.attributes.", "'+props.attributes.", "+'", "+'"), $string);
4282 4282
 			}
4283 4283
 
4284 4284
 			return $string;
@@ -4290,65 +4290,65 @@  discard block
 block discarded – undo
4290 4290
 		 * @param array $args
4291 4291
 		 * @param array $instance
4292 4292
 		 */
4293
-		public function widget( $args, $instance ) {
4294
-			if ( ! is_array( $args ) ) {
4293
+		public function widget($args, $instance) {
4294
+			if (!is_array($args)) {
4295 4295
 				$args = array();
4296 4296
 			}
4297 4297
 
4298 4298
 			// Get the filtered values
4299
-			$argument_values = $this->argument_values( $instance );
4300
-			$argument_values = $this->string_to_bool( $argument_values );
4301
-			$output          = $this->output( $argument_values, $args );
4299
+			$argument_values = $this->argument_values($instance);
4300
+			$argument_values = $this->string_to_bool($argument_values);
4301
+			$output          = $this->output($argument_values, $args);
4302 4302
 
4303 4303
 			$no_wrap = false;
4304
-			if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
4304
+			if (isset($argument_values['no_wrap']) && $argument_values['no_wrap']) {
4305 4305
 				$no_wrap = true;
4306 4306
 			}
4307 4307
 
4308 4308
 			ob_start();
4309
-			if ( $output && ! $no_wrap ) {
4309
+			if ($output && !$no_wrap) {
4310 4310
 
4311 4311
 				$class_original = $this->options['widget_ops']['classname'];
4312
-				$class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
4312
+				$class = $this->options['widget_ops']['classname'] . " sdel-" . $this->get_instance_hash();
4313 4313
 
4314 4314
 				// Before widget
4315
-				$before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : '';
4316
-				$before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget;
4317
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
4318
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
4315
+				$before_widget = !empty($args['before_widget']) ? $args['before_widget'] : '';
4316
+				$before_widget = $before_widget ? str_replace($class_original, $class, $before_widget) : $before_widget;
4317
+				$before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this);
4318
+				$before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this);
4319 4319
 
4320 4320
 				// After widget
4321
-				$after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : '';
4322
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
4323
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
4321
+				$after_widget = !empty($args['after_widget']) ? $args['after_widget'] : '';
4322
+				$after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this);
4323
+				$after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this);
4324 4324
 
4325 4325
 				echo $before_widget;
4326 4326
 				// elementor strips the widget wrapping div so we check for and add it back if needed
4327
-				if ( $this->is_elementor_widget_output() ) {
4327
+				if ($this->is_elementor_widget_output()) {
4328 4328
 					// Filter class & attrs for elementor widget output.
4329
-					$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
4330
-					$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
4329
+					$class = apply_filters('wp_super_duper_div_classname', $class, $args, $this);
4330
+					$class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this);
4331 4331
 
4332
-					$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
4333
-					$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
4332
+					$attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this);
4333
+					$attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this);
4334 4334
 
4335
-					echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
4335
+					echo "<span class='" . esc_attr($class) . "' " . $attrs . ">";
4336 4336
 				}
4337
-				echo $this->output_title( $args, $instance );
4337
+				echo $this->output_title($args, $instance);
4338 4338
 				echo $output;
4339
-				if ( $this->is_elementor_widget_output() ) {
4339
+				if ($this->is_elementor_widget_output()) {
4340 4340
 					echo "</span>";
4341 4341
 				}
4342 4342
 				echo $after_widget;
4343
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
4344
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
4343
+			} elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty
4344
+				$output = $this->preview_placeholder_text("{{" . $this->base_id . "}}");
4345 4345
 				echo $output;
4346
-			} elseif ( $output && $no_wrap ) {
4346
+			} elseif ($output && $no_wrap) {
4347 4347
 				echo $output;
4348 4348
 			}
4349 4349
 			$output = ob_get_clean();
4350 4350
 
4351
-			$output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
4351
+			$output = apply_filters('wp_super_duper_widget_output', $output, $instance, $args, $this);
4352 4352
 
4353 4353
 			echo $output;
4354 4354
 		}
@@ -4361,7 +4361,7 @@  discard block
 block discarded – undo
4361 4361
 		 */
4362 4362
 		public function is_elementor_widget_output() {
4363 4363
 			$result = false;
4364
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
4364
+			if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') {
4365 4365
 				$result = true;
4366 4366
 			}
4367 4367
 
@@ -4376,7 +4376,7 @@  discard block
 block discarded – undo
4376 4376
 		 */
4377 4377
 		public function is_elementor_preview() {
4378 4378
 			$result = false;
4379
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
4379
+			if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) {
4380 4380
 				$result = true;
4381 4381
 			}
4382 4382
 
@@ -4391,7 +4391,7 @@  discard block
 block discarded – undo
4391 4391
 		 */
4392 4392
 		public function is_divi_preview() {
4393 4393
 			$result = false;
4394
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
4394
+			if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) {
4395 4395
 				$result = true;
4396 4396
 			}
4397 4397
 
@@ -4406,7 +4406,7 @@  discard block
 block discarded – undo
4406 4406
 		 */
4407 4407
 		public function is_beaver_preview() {
4408 4408
 			$result = false;
4409
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
4409
+			if (isset($_REQUEST['fl_builder'])) {
4410 4410
 				$result = true;
4411 4411
 			}
4412 4412
 
@@ -4421,7 +4421,7 @@  discard block
 block discarded – undo
4421 4421
 		 */
4422 4422
 		public function is_siteorigin_preview() {
4423 4423
 			$result = false;
4424
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
4424
+			if (!empty($_REQUEST['siteorigin_panels_live_editor'])) {
4425 4425
 				$result = true;
4426 4426
 			}
4427 4427
 
@@ -4436,7 +4436,7 @@  discard block
 block discarded – undo
4436 4436
 		 */
4437 4437
 		public function is_cornerstone_preview() {
4438 4438
 			$result = false;
4439
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
4439
+			if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') {
4440 4440
 				$result = true;
4441 4441
 			}
4442 4442
 
@@ -4451,7 +4451,7 @@  discard block
 block discarded – undo
4451 4451
 		 */
4452 4452
 		public function is_fusion_preview() {
4453 4453
 			$result = false;
4454
-			if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
4454
+			if (!empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce'])) {
4455 4455
 				$result = true;
4456 4456
 			}
4457 4457
 
@@ -4466,7 +4466,7 @@  discard block
 block discarded – undo
4466 4466
 		 */
4467 4467
 		public function is_oxygen_preview() {
4468 4468
 			$result = false;
4469
-			if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
4469
+			if (!empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_"))) {
4470 4470
 				$result = true;
4471 4471
 			}
4472 4472
 
@@ -4483,7 +4483,7 @@  discard block
 block discarded – undo
4483 4483
 		public function is_kallyas_zion_preview() {
4484 4484
 			$result = false;
4485 4485
 
4486
-			if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) {
4486
+			if (function_exists('znhg_kallyas_theme_config') && !empty($_REQUEST['zn_pb_edit'])) {
4487 4487
 				$result = true;
4488 4488
 			}
4489 4489
 
@@ -4500,7 +4500,7 @@  discard block
 block discarded – undo
4500 4500
 		public function is_bricks_preview() {
4501 4501
 			$result = false;
4502 4502
 
4503
-			if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) {
4503
+			if (function_exists('bricks_is_builder') && (bricks_is_builder() || bricks_is_builder_call())) {
4504 4504
 				$result = true;
4505 4505
 			}
4506 4506
 
@@ -4515,25 +4515,25 @@  discard block
 block discarded – undo
4515 4515
 		 */
4516 4516
 		public function is_preview() {
4517 4517
 			$preview = false;
4518
-			if ( $this->is_divi_preview() ) {
4518
+			if ($this->is_divi_preview()) {
4519 4519
 				$preview = true;
4520
-			} elseif ( $this->is_elementor_preview() ) {
4520
+			} elseif ($this->is_elementor_preview()) {
4521 4521
 				$preview = true;
4522
-			} elseif ( $this->is_beaver_preview() ) {
4522
+			} elseif ($this->is_beaver_preview()) {
4523 4523
 				$preview = true;
4524
-			} elseif ( $this->is_siteorigin_preview() ) {
4524
+			} elseif ($this->is_siteorigin_preview()) {
4525 4525
 				$preview = true;
4526
-			} elseif ( $this->is_cornerstone_preview() ) {
4526
+			} elseif ($this->is_cornerstone_preview()) {
4527 4527
 				$preview = true;
4528
-			} elseif ( $this->is_fusion_preview() ) {
4528
+			} elseif ($this->is_fusion_preview()) {
4529 4529
 				$preview = true;
4530
-			} elseif ( $this->is_oxygen_preview() ) {
4530
+			} elseif ($this->is_oxygen_preview()) {
4531 4531
 				$preview = true;
4532
-			} elseif( $this->is_kallyas_zion_preview() ) {
4532
+			} elseif ($this->is_kallyas_zion_preview()) {
4533 4533
 				$preview = true;
4534
-			} elseif( $this->is_block_content_call() ) {
4534
+			} elseif ($this->is_block_content_call()) {
4535 4535
 				$preview = true;
4536
-			} elseif( $this->is_bricks_preview() ) {
4536
+			} elseif ($this->is_bricks_preview()) {
4537 4537
 				$preview = true;
4538 4538
 			}
4539 4539
 
@@ -4548,44 +4548,44 @@  discard block
 block discarded – undo
4548 4548
 		 *
4549 4549
 		 * @return string
4550 4550
 		 */
4551
-		public function output_title( $args, $instance = array() ) {
4551
+		public function output_title($args, $instance = array()) {
4552 4552
 			$output = '';
4553
-			if ( ! empty( $instance['title'] ) ) {
4553
+			if (!empty($instance['title'])) {
4554 4554
 				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
4555
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
4555
+				$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
4556 4556
 
4557
-				if ( empty( $instance['widget_title_tag'] ) ) {
4558
-					if ( ! isset( $args['before_title'] ) ) {
4557
+				if (empty($instance['widget_title_tag'])) {
4558
+					if (!isset($args['before_title'])) {
4559 4559
 						$args['before_title'] = '';
4560 4560
 					}
4561 4561
 
4562
-					if ( ! isset( $args['after_title'] ) ) {
4562
+					if (!isset($args['after_title'])) {
4563 4563
 						$args['after_title'] = '';
4564 4564
 					}
4565 4565
 
4566 4566
 					$output = $args['before_title'] . $title . $args['after_title'];
4567 4567
 				} else {
4568
-					$tag 			= esc_attr( $instance['widget_title_tag'] );
4569
-					$allowed_tags 	= array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' );
4570
-					$title_tag      = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2';
4568
+					$tag 			= esc_attr($instance['widget_title_tag']);
4569
+					$allowed_tags = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p');
4570
+					$title_tag = in_array($tag, $allowed_tags, true) ? esc_attr($tag) : 'h2';
4571 4571
 
4572 4572
 					// classes
4573 4573
 					$title_classes = array();
4574
-					$title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
4575
-					$title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
4576
-					$title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
4577
-					$title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
4578
-					$title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
4579
-					$title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
4580
-					$title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
4581
-					$title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
4582
-					$title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
4583
-					$title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
4584
-					$title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
4585
-					$title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
4586
-					$title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
4587
-
4588
-					$class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
4574
+					$title_classes[] = !empty($instance['widget_title_size_class']) ? sanitize_html_class($instance['widget_title_size_class']) : '';
4575
+					$title_classes[] = !empty($instance['widget_title_align_class']) ? sanitize_html_class($instance['widget_title_align_class']) : '';
4576
+					$title_classes[] = !empty($instance['widget_title_color_class']) ? "text-" . sanitize_html_class($instance['widget_title_color_class']) : '';
4577
+					$title_classes[] = !empty($instance['widget_title_border_class']) ? sanitize_html_class($instance['widget_title_border_class']) : '';
4578
+					$title_classes[] = !empty($instance['widget_title_border_color_class']) ? "border-" . sanitize_html_class($instance['widget_title_border_color_class']) : '';
4579
+					$title_classes[] = !empty($instance['widget_title_mt_class']) ? "mt-" . absint($instance['widget_title_mt_class']) : '';
4580
+					$title_classes[] = !empty($instance['widget_title_mr_class']) ? "mr-" . absint($instance['widget_title_mr_class']) : '';
4581
+					$title_classes[] = !empty($instance['widget_title_mb_class']) ? "mb-" . absint($instance['widget_title_mb_class']) : '';
4582
+					$title_classes[] = !empty($instance['widget_title_ml_class']) ? "ml-" . absint($instance['widget_title_ml_class']) : '';
4583
+					$title_classes[] = !empty($instance['widget_title_pt_class']) ? "pt-" . absint($instance['widget_title_pt_class']) : '';
4584
+					$title_classes[] = !empty($instance['widget_title_pr_class']) ? "pr-" . absint($instance['widget_title_pr_class']) : '';
4585
+					$title_classes[] = !empty($instance['widget_title_pb_class']) ? "pb-" . absint($instance['widget_title_pb_class']) : '';
4586
+					$title_classes[] = !empty($instance['widget_title_pl_class']) ? "pl-" . absint($instance['widget_title_pl_class']) : '';
4587
+
4588
+					$class = !empty($title_classes) ? implode(" ", $title_classes) : '';
4589 4589
 					$output = "<$title_tag class='$class' >$title</$title_tag>";
4590 4590
 				}
4591 4591
 
@@ -4599,7 +4599,7 @@  discard block
 block discarded – undo
4599 4599
 		 *
4600 4600
 		 * @param array $instance The widget options.
4601 4601
 		 */
4602
-		public function form( $instance ) {
4602
+		public function form($instance) {
4603 4603
 
4604 4604
 			// set widget instance
4605 4605
 			$this->instance = $instance;
@@ -4607,20 +4607,20 @@  discard block
 block discarded – undo
4607 4607
 			// set it as a SD widget
4608 4608
 			echo $this->widget_advanced_toggle();
4609 4609
 
4610
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
4610
+			echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>";
4611 4611
 			$arguments_raw = $this->get_arguments();
4612 4612
 
4613
-			if ( is_array( $arguments_raw ) ) {
4613
+			if (is_array($arguments_raw)) {
4614 4614
 
4615
-				$arguments = $this->group_arguments( $arguments_raw );
4615
+				$arguments = $this->group_arguments($arguments_raw);
4616 4616
 
4617 4617
 				// Do we have sections?
4618 4618
 				$has_sections = $arguments == $arguments_raw ? false : true;
4619 4619
 
4620 4620
 
4621
-				if ( $has_sections ) {
4621
+				if ($has_sections) {
4622 4622
 					$panel_count = 0;
4623
-					foreach ( $arguments as $key => $args ) {
4623
+					foreach ($arguments as $key => $args) {
4624 4624
 
4625 4625
 						?>
4626 4626
 						<script>
@@ -4630,26 +4630,26 @@  discard block
 block discarded – undo
4630 4630
 
4631 4631
 						$hide       = $panel_count ? ' style="display:none;" ' : '';
4632 4632
 						$icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
4633
-						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>";
4634
-						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
4633
+						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>";
4634
+						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes($key) . "' $hide>";
4635 4635
 
4636
-						foreach ( $args as $k => $a ) {
4636
+						foreach ($args as $k => $a) {
4637 4637
 
4638 4638
 							$this->widget_inputs_row_start($k, $a);
4639
-							$this->widget_inputs( $a, $instance );
4639
+							$this->widget_inputs($a, $instance);
4640 4640
 							$this->widget_inputs_row_end($k, $a);
4641 4641
 
4642 4642
 						}
4643 4643
 
4644 4644
 						echo "</div>";
4645 4645
 
4646
-						$panel_count ++;
4646
+						$panel_count++;
4647 4647
 
4648 4648
 					}
4649 4649
 				} else {
4650
-					foreach ( $arguments as $key => $args ) {
4650
+					foreach ($arguments as $key => $args) {
4651 4651
 						$this->widget_inputs_row_start($key, $args);
4652
-						$this->widget_inputs( $args, $instance );
4652
+						$this->widget_inputs($args, $instance);
4653 4653
 						$this->widget_inputs_row_end($key, $args);
4654 4654
 					}
4655 4655
 				}
@@ -4657,28 +4657,28 @@  discard block
 block discarded – undo
4657 4657
 			}
4658 4658
 		}
4659 4659
 
4660
-		public function widget_inputs_row_start( $key, $args ) {
4661
-			if ( ! empty( $args['row'] ) ) {
4660
+		public function widget_inputs_row_start($key, $args) {
4661
+			if (!empty($args['row'])) {
4662 4662
 				// Maybe open
4663
-				if ( ! empty( $args['row']['open'] ) ) {
4663
+				if (!empty($args['row']['open'])) {
4664 4664
 					?>
4665
-					<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'] ) : '' ); ?>'>
4666
-					<?php if ( ! empty( $args['row']['title'] ) ) { ?>
4665
+					<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']) : ''); ?>'>
4666
+					<?php if (!empty($args['row']['title'])) { ?>
4667 4667
 					<?php
4668
-						if ( isset( $args['row']['icon'] ) ) {
4668
+						if (isset($args['row']['icon'])) {
4669 4669
 							$args['row']['icon'] = '';
4670 4670
 						}
4671 4671
 
4672
-						if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) {
4672
+						if (!isset($args['row']['device_type']) && isset($args['device_type'])) {
4673 4673
 							$args['row']['device_type'] = $args['device_type'];
4674 4674
 						}
4675 4675
 					?>
4676
-					<label class="mb-0"><?php echo $this->widget_field_title( $args['row'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label>
4676
+					<label class="mb-0"><?php echo $this->widget_field_title($args['row']); ?><?php echo $this->widget_field_desc($args['row']); ?></label>
4677 4677
 					<?php } ?>
4678
-					<div class='row<?php echo ( ! empty( $args['row']['class'] ) ? ' ' . esc_attr( $args['row']['class'] ) : '' ); ?>'>
4678
+					<div class='row<?php echo (!empty($args['row']['class']) ? ' ' . esc_attr($args['row']['class']) : ''); ?>'>
4679 4679
 					<div class='col pr-2'>
4680 4680
 					<?php
4681
-				} else if ( ! empty( $args['row']['close'] ) ) {
4681
+				} else if (!empty($args['row']['close'])) {
4682 4682
 					echo "<div class='col pl-0 ps-0'>";
4683 4683
 				} else {
4684 4684
 					echo "<div class='col pl-0 ps-0 pr-2 pe-2'>";
@@ -4686,10 +4686,10 @@  discard block
 block discarded – undo
4686 4686
 			}
4687 4687
 		}
4688 4688
 
4689
-		public function widget_inputs_row_end( $key, $args ) {
4690
-			if ( ! empty( $args['row'] ) ) {
4689
+		public function widget_inputs_row_end($key, $args) {
4690
+			if (!empty($args['row'])) {
4691 4691
 				// Maybe close
4692
-				if ( ! empty( $args['row']['close'] ) ) {
4692
+				if (!empty($args['row']['close'])) {
4693 4693
 					echo "</div></div>";
4694 4694
 				}
4695 4695
 				echo "</div>";
@@ -4704,7 +4704,7 @@  discard block
 block discarded – undo
4704 4704
 		public function widget_advanced_toggle() {
4705 4705
 
4706 4706
 			$output = '';
4707
-			if ( $this->block_show_advanced() ) {
4707
+			if ($this->block_show_advanced()) {
4708 4708
 				$val = 1;
4709 4709
 			} else {
4710 4710
 				$val = 0;
@@ -4724,14 +4724,14 @@  discard block
 block discarded – undo
4724 4724
 		 *@since 1.0.0
4725 4725
 		 *
4726 4726
 		 */
4727
-		public function convert_element_require( $input ) {
4728
-			$input = str_replace( "'", '"', $input );// we only want double quotes
4727
+		public function convert_element_require($input) {
4728
+			$input = str_replace("'", '"', $input); // we only want double quotes
4729 4729
 
4730
-			$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
4730
+			$output = esc_attr(str_replace(array("[%", "%]", "%:checked]"), array(
4731 4731
 				"jQuery(form).find('[data-argument=\"",
4732 4732
 				"\"]').find('input,select,textarea').val()",
4733 4733
 				"\"]').find('input:checked').val()"
4734
-			), $input ) );
4734
+			), $input));
4735 4735
 
4736 4736
 			return $output;
4737 4737
 		}
@@ -4742,48 +4742,48 @@  discard block
 block discarded – undo
4742 4742
 		 * @param $args
4743 4743
 		 * @param $instance
4744 4744
 		 */
4745
-		public function widget_inputs( $args, $instance ) {
4745
+		public function widget_inputs($args, $instance) {
4746 4746
 
4747 4747
 			$class             = "";
4748 4748
 			$element_require   = "";
4749 4749
 			$custom_attributes = "";
4750 4750
 
4751 4751
 			// get value
4752
-			if ( isset( $instance[ $args['name'] ] ) ) {
4753
-				$value = $instance[ $args['name'] ];
4754
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4755
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4752
+			if (isset($instance[$args['name']])) {
4753
+				$value = $instance[$args['name']];
4754
+			} elseif (!isset($instance[$args['name']]) && !empty($args['default'])) {
4755
+				$value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']);
4756 4756
 			} else {
4757 4757
 				$value = '';
4758 4758
 			}
4759 4759
 
4760 4760
 			// get placeholder
4761
-			if ( ! empty( $args['placeholder'] ) ) {
4762
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4761
+			if (!empty($args['placeholder'])) {
4762
+				$placeholder = "placeholder='" . esc_html($args['placeholder']) . "'";
4763 4763
 			} else {
4764 4764
 				$placeholder = '';
4765 4765
 			}
4766 4766
 
4767 4767
 			// get if advanced
4768
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4768
+			if (isset($args['advanced']) && $args['advanced']) {
4769 4769
 				$class .= " sd-advanced-setting ";
4770 4770
 			}
4771 4771
 
4772 4772
 			// element_require
4773
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4773
+			if (isset($args['element_require']) && $args['element_require']) {
4774 4774
 				$element_require = $args['element_require'];
4775 4775
 			}
4776 4776
 
4777 4777
 			// custom_attributes
4778
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4779
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4778
+			if (isset($args['custom_attributes']) && $args['custom_attributes']) {
4779
+				$custom_attributes = $this->array_to_attributes($args['custom_attributes'], true);
4780 4780
 			}
4781 4781
 
4782 4782
 			// before wrapper
4783 4783
 			?>
4784
-			<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 );} ?>'>
4784
+			<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); } ?>'>
4785 4785
 			<?php
4786
-			switch ( $args['type'] ) {
4786
+			switch ($args['type']) {
4787 4787
 				//array('text','password','number','email','tel','url','color')
4788 4788
 				case "text":
4789 4789
 				case "password":
@@ -4793,33 +4793,33 @@  discard block
 block discarded – undo
4793 4793
 				case "url":
4794 4794
 				case "color":
4795 4795
 					?>
4796
-					<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>
4797
-					<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 ); ?>">
4796
+					<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>
4797
+					<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); ?>">
4798 4798
 					<?php
4799 4799
 
4800 4800
 					break;
4801 4801
 				case "select":
4802
-					$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4803
-					if ( $multiple ) {
4804
-						if ( empty( $value ) ) {
4802
+					$multiple = isset($args['multiple']) && $args['multiple'] ? true : false;
4803
+					if ($multiple) {
4804
+						if (empty($value)) {
4805 4805
 							$value = array();
4806 4806
 						}
4807 4807
 					}
4808 4808
 					?>
4809
-					<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>
4810
-					<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 "[]"; } ?>"
4811
-						<?php if ( $multiple ) {
4809
+					<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>
4810
+					<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 "[]"; } ?>"
4811
+						<?php if ($multiple) {
4812 4812
 							echo "multiple";
4813 4813
 						} //@todo not implemented yet due to gutenberg not supporting it
4814 4814
 						?>>
4815 4815
 						<?php
4816 4816
 
4817
-						if ( ! empty( $args['options'] ) ) {
4818
-							foreach ( $args['options'] as $val => $label ) {
4819
-								if ( $multiple ) {
4820
-									$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4817
+						if (!empty($args['options'])) {
4818
+							foreach ($args['options'] as $val => $label) {
4819
+								if ($multiple) {
4820
+									$selected = in_array($val, $value) ? 'selected="selected"' : '';
4821 4821
 								} else {
4822
-									$selected = selected( $value, $val, false );
4822
+									$selected = selected($value, $val, false);
4823 4823
 								}
4824 4824
 								echo "<option value='$val' " . $selected . ">$label</option>";
4825 4825
 							}
@@ -4830,20 +4830,20 @@  discard block
 block discarded – undo
4830 4830
 					break;
4831 4831
 				case "checkbox":
4832 4832
 					?>
4833
-					<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">
4834
-					<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>
4833
+					<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">
4834
+					<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>
4835 4835
 					<?php
4836 4836
 					break;
4837 4837
 				case "textarea":
4838 4838
 					?>
4839
-					<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>
4840
-					<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>
4839
+					<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>
4840
+					<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>
4841 4841
 					<?php
4842 4842
 
4843 4843
 					break;
4844 4844
 				case "hidden":
4845 4845
 					?>
4846
-					<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 ); ?>">
4846
+					<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); ?>">
4847 4847
 					<?php
4848 4848
 					break;
4849 4849
 				default:
@@ -4853,15 +4853,15 @@  discard block
 block discarded – undo
4853 4853
 			?></p><?php
4854 4854
 		}
4855 4855
 
4856
-		public function get_widget_icon($icon = 'box-top', $title = ''){
4857
-			if($icon=='box-top'){
4858
-				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>';
4859
-			}elseif($icon=='box-right'){
4860
-				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>';
4861
-			}elseif($icon=='box-bottom'){
4862
-				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>';
4863
-			}elseif($icon=='box-left'){
4864
-				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>';
4856
+		public function get_widget_icon($icon = 'box-top', $title = '') {
4857
+			if ($icon == 'box-top') {
4858
+				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>';
4859
+			}elseif ($icon == 'box-right') {
4860
+				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>';
4861
+			}elseif ($icon == 'box-bottom') {
4862
+				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>';
4863
+			}elseif ($icon == 'box-left') {
4864
+				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>';
4865 4865
 			}
4866 4866
 		}
4867 4867
 
@@ -4873,14 +4873,14 @@  discard block
 block discarded – undo
4873 4873
 		 * @return string
4874 4874
 		 * @todo, need to make its own tooltip script
4875 4875
 		 */
4876
-		public function widget_field_desc( $args ) {
4876
+		public function widget_field_desc($args) {
4877 4877
 
4878 4878
 			$description = '';
4879
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
4880
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4881
-					$description = $this->desc_tip( $args['desc'] );
4879
+			if (isset($args['desc']) && $args['desc']) {
4880
+				if (isset($args['desc_tip']) && $args['desc_tip']) {
4881
+					$description = $this->desc_tip($args['desc']);
4882 4882
 				} else {
4883
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4883
+					$description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>';
4884 4884
 				}
4885 4885
 			}
4886 4886
 
@@ -4894,18 +4894,18 @@  discard block
 block discarded – undo
4894 4894
 		 *
4895 4895
 		 * @return string
4896 4896
 		 */
4897
-		public function widget_field_title( $args ) {
4897
+		public function widget_field_title($args) {
4898 4898
 			$title = '';
4899 4899
 
4900
-			if ( isset( $args['title'] ) && $args['title'] ) {
4901
-				if ( ! empty( $args['device_type'] ) ) {
4900
+			if (isset($args['title']) && $args['title']) {
4901
+				if (!empty($args['device_type'])) {
4902 4902
 					$args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title.
4903 4903
 				}
4904 4904
 
4905
-				if ( isset( $args['icon'] ) && $args['icon'] ) {
4906
-					$title = self::get_widget_icon( $args['icon'], $args['title']  );
4905
+				if (isset($args['icon']) && $args['icon']) {
4906
+					$title = self::get_widget_icon($args['icon'], $args['title']);
4907 4907
 				} else {
4908
-					$title = esc_attr( $args['title'] );
4908
+					$title = esc_attr($args['title']);
4909 4909
 				}
4910 4910
 			}
4911 4911
 
@@ -4920,11 +4920,11 @@  discard block
 block discarded – undo
4920 4920
 		 *
4921 4921
 		 * @return string
4922 4922
 		 */
4923
-		function desc_tip( $tip, $allow_html = false ) {
4924
-			if ( $allow_html ) {
4925
-				$tip = $this->sanitize_tooltip( $tip );
4923
+		function desc_tip($tip, $allow_html = false) {
4924
+			if ($allow_html) {
4925
+				$tip = $this->sanitize_tooltip($tip);
4926 4926
 			} else {
4927
-				$tip = esc_attr( $tip );
4927
+				$tip = esc_attr($tip);
4928 4928
 			}
4929 4929
 
4930 4930
 			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -4937,8 +4937,8 @@  discard block
 block discarded – undo
4937 4937
 		 *
4938 4938
 		 * @return string
4939 4939
 		 */
4940
-		public function sanitize_tooltip( $var ) {
4941
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4940
+		public function sanitize_tooltip($var) {
4941
+			return htmlspecialchars(wp_kses(html_entity_decode($var), array(
4942 4942
 				'br'     => array(),
4943 4943
 				'em'     => array(),
4944 4944
 				'strong' => array(),
@@ -4948,7 +4948,7 @@  discard block
 block discarded – undo
4948 4948
 				'li'     => array(),
4949 4949
 				'ol'     => array(),
4950 4950
 				'p'      => array(),
4951
-			) ) );
4951
+			)));
4952 4952
 		}
4953 4953
 
4954 4954
 		/**
@@ -4960,23 +4960,23 @@  discard block
 block discarded – undo
4960 4960
 		 * @return array
4961 4961
 		 * @todo we should add some sanitation here.
4962 4962
 		 */
4963
-		public function update( $new_instance, $old_instance ) {
4963
+		public function update($new_instance, $old_instance) {
4964 4964
 
4965 4965
 			//save the widget
4966
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
4966
+			$instance = array_merge((array) $old_instance, (array) $new_instance);
4967 4967
 
4968 4968
 			// set widget instance
4969 4969
 			$this->instance = $instance;
4970 4970
 
4971
-			if ( empty( $this->arguments ) ) {
4971
+			if (empty($this->arguments)) {
4972 4972
 				$this->get_arguments();
4973 4973
 			}
4974 4974
 
4975 4975
 			// check for checkboxes
4976
-			if ( ! empty( $this->arguments ) ) {
4977
-				foreach ( $this->arguments as $argument ) {
4978
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4979
-						$instance[ $argument['name'] ] = '0';
4976
+			if (!empty($this->arguments)) {
4977
+				foreach ($this->arguments as $argument) {
4978
+					if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) {
4979
+						$instance[$argument['name']] = '0';
4980 4980
 					}
4981 4981
 				}
4982 4982
 			}
@@ -4994,7 +4994,7 @@  discard block
 block discarded – undo
4994 4994
 		 */
4995 4995
 		public function is_block_content_call() {
4996 4996
 			$result = false;
4997
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4997
+			if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') {
4998 4998
 				$result = true;
4999 4999
 			}
5000 5000
 
@@ -5007,9 +5007,9 @@  discard block
 block discarded – undo
5007 5007
 		 * @return string
5008 5008
 		 *@since 1.0.20
5009 5009
 		 */
5010
-		public function get_instance_hash(){
5011
-			$instance_string = $this->base_id.serialize($this->instance);
5012
-			return hash('crc32b',$instance_string);
5010
+		public function get_instance_hash() {
5011
+			$instance_string = $this->base_id . serialize($this->instance);
5012
+			return hash('crc32b', $instance_string);
5013 5013
 		}
5014 5014
 
5015 5015
 		/**
@@ -5020,14 +5020,14 @@  discard block
 block discarded – undo
5020 5020
 		 * @return string
5021 5021
 		 *@since 1.0.20
5022 5022
 		 */
5023
-		public function get_instance_style($rules = array()){
5023
+		public function get_instance_style($rules = array()) {
5024 5024
 			$css = '';
5025 5025
 
5026
-			if(!empty($rules)){
5026
+			if (!empty($rules)) {
5027 5027
 				$rules = array_unique($rules);
5028 5028
 				$instance_hash = $this->get_instance_hash();
5029 5029
 				$css .= "<style>";
5030
-				foreach($rules as $rule){
5030
+				foreach ($rules as $rule) {
5031 5031
 					$css .= ".sdel-$instance_hash $rule";
5032 5032
 				}
5033 5033
 				$css .= "</style>";
@@ -5045,9 +5045,9 @@  discard block
 block discarded – undo
5045 5045
 		 *@since 1.0.28
5046 5046
 		 *
5047 5047
 		 */
5048
-		public function encode_shortcodes( $content ) {
5048
+		public function encode_shortcodes($content) {
5049 5049
 			// Avoids existing encoded tags.
5050
-			$trans   = array(
5050
+			$trans = array(
5051 5051
 				'&#91;' => '&#091;',
5052 5052
 				'&#93;' => '&#093;',
5053 5053
 				'&amp;#91;' => '&#091;',
@@ -5058,7 +5058,7 @@  discard block
 block discarded – undo
5058 5058
 				'&amp;gt;' => '&0gt;',
5059 5059
 			);
5060 5060
 
5061
-			$content = strtr( $content, $trans );
5061
+			$content = strtr($content, $trans);
5062 5062
 
5063 5063
 			$trans   = array(
5064 5064
 				'[' => '&#91;',
@@ -5069,7 +5069,7 @@  discard block
 block discarded – undo
5069 5069
 				"'" => '&#39;',
5070 5070
 			);
5071 5071
 
5072
-			$content = strtr( $content, $trans );
5072
+			$content = strtr($content, $trans);
5073 5073
 
5074 5074
 			return $content;
5075 5075
 		}
@@ -5083,8 +5083,8 @@  discard block
 block discarded – undo
5083 5083
 		 *@since 1.0.28
5084 5084
 		 *
5085 5085
 		 */
5086
-		public function decode_shortcodes( $content ) {
5087
-			$trans   = array(
5086
+		public function decode_shortcodes($content) {
5087
+			$trans = array(
5088 5088
 				'&#91;' => '[',
5089 5089
 				'&#93;' => ']',
5090 5090
 				'&amp;#91;' => '[',
@@ -5097,7 +5097,7 @@  discard block
 block discarded – undo
5097 5097
 				'&apos;' => "'",
5098 5098
 			);
5099 5099
 
5100
-			$content = strtr( $content, $trans );
5100
+			$content = strtr($content, $trans);
5101 5101
 
5102 5102
 			$trans   = array(
5103 5103
 				'&#091;' => '&#91;',
@@ -5110,31 +5110,31 @@  discard block
 block discarded – undo
5110 5110
 				'&amp;0gt;' => '&gt;',
5111 5111
 			);
5112 5112
 
5113
-			$content = strtr( $content, $trans );
5113
+			$content = strtr($content, $trans);
5114 5114
 
5115 5115
 			return $content;
5116 5116
 		}
5117 5117
 
5118
-		public function block_visibility_fields( $args ) {
5119
-			$value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : '';
5118
+		public function block_visibility_fields($args) {
5119
+			$value = !empty($args['value']) ? esc_attr($args['value']) : '';
5120 5120
 			$content = '<div class="bs-vc-rule-template d-none">';
5121 5121
 				$content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >';
5122 5122
 					$content .= '<div class="row">';
5123 5123
 						$content .= '<div class="col-sm-12">';
5124
-							$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>';
5124
+							$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>';
5125 5125
 							$content .= aui()->select(
5126 5126
 								array(
5127 5127
 									'id'          => 'bsvc_rule_BSVCINDEX',
5128 5128
 									'name'        => 'bsvc_rule_BSVCINDEX',
5129
-									'label'       => __( 'Rule', 'ayecode-connect' ),
5130
-									'placeholder' => __( 'Select Rule...', 'ayecode-connect' ),
5129
+									'label'       => __('Rule', 'ayecode-connect'),
5130
+									'placeholder' => __('Select Rule...', 'ayecode-connect'),
5131 5131
 									'class'       => 'bsvc_rule form-select-sm no-select2 mw-100',
5132 5132
 									'options'     => sd_visibility_rules_options(),
5133 5133
 									'default'     => '',
5134 5134
 									'value'       => '',
5135 5135
 									'label_type'  => '',
5136 5136
 									'select2'     => false,
5137
-									'input_group_left' => __( 'Rule:', 'ayecode-connect' ),
5137
+									'input_group_left' => __('Rule:', 'ayecode-connect'),
5138 5138
 									'extra_attributes' => array(
5139 5139
 										'data-minimum-results-for-search' => '-1'
5140 5140
 									)
@@ -5143,15 +5143,15 @@  discard block
 block discarded – undo
5143 5143
 
5144 5144
 						$content .= '</div>';
5145 5145
 
5146
-						if ( class_exists( 'GeoDirectory' ) ) {
5146
+						if (class_exists('GeoDirectory')) {
5147 5147
 							$content .= '<div class="col-md-7 col-sm-12">';
5148 5148
 
5149 5149
 								$content .= aui()->select(
5150 5150
 									array(
5151 5151
 										'id'          => 'bsvc_gd_field_BSVCINDEX',
5152 5152
 										'name'        => 'bsvc_gd_field_BSVCINDEX',
5153
-										'label'       => __( 'FIELD', 'ayecode-connect' ),
5154
-										'placeholder' => __( 'FIELD', 'ayecode-connect' ),
5153
+										'label'       => __('FIELD', 'ayecode-connect'),
5154
+										'placeholder' => __('FIELD', 'ayecode-connect'),
5155 5155
 										'class'       => 'bsvc_gd_field form-select-sm no-select2 mw-100',
5156 5156
 										'options'     => sd_visibility_gd_field_options(),
5157 5157
 										'default'     => '',
@@ -5172,8 +5172,8 @@  discard block
 block discarded – undo
5172 5172
 									array(
5173 5173
 										'id'          => 'bsvc_gd_field_condition_BSVCINDEX',
5174 5174
 										'name'        => 'bsvc_gd_field_condition_BSVCINDEX',
5175
-										'label'       => __( 'CONDITION', 'ayecode-connect' ),
5176
-										'placeholder' => __( 'CONDITION', 'ayecode-connect' ),
5175
+										'label'       => __('CONDITION', 'ayecode-connect'),
5176
+										'placeholder' => __('CONDITION', 'ayecode-connect'),
5177 5177
 										'class'       => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100',
5178 5178
 										'options'     => sd_visibility_field_condition_options(),
5179 5179
 										'default'     => '',
@@ -5195,9 +5195,9 @@  discard block
 block discarded – undo
5195 5195
 										'type'            => 'text',
5196 5196
 										'id'              => 'bsvc_gd_field_search_BSVCINDEX',
5197 5197
 										'name'            => 'bsvc_gd_field_search_BSVCINDEX',
5198
-										'label'           => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5198
+										'label'           => __('VALUE TO MATCH', 'ayecode-connect'),
5199 5199
 										'class'           => 'bsvc_gd_field_search form-control-sm',
5200
-										'placeholder'     => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5200
+										'placeholder'     => __('VALUE TO MATCH', 'ayecode-connect'),
5201 5201
 										'label_type'      => '',
5202 5202
 										'value'           => '',
5203 5203
 										'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")'
@@ -5207,15 +5207,15 @@  discard block
 block discarded – undo
5207 5207
 							$content .= '</div>';
5208 5208
 						}
5209 5209
 
5210
-                        $content .= apply_filters( 'sd_block_visibility_fields', '', $args );
5210
+                        $content .= apply_filters('sd_block_visibility_fields', '', $args);
5211 5211
 
5212 5212
 					$content .= '</div>';
5213 5213
 
5214
-					$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>';
5214
+					$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>';
5215 5215
 						$role_options = sd_user_roles_options();
5216 5216
 
5217 5217
 						$role_option_i = 0;
5218
-						foreach ( $role_options as $role_option_key => $role_option_name ) {
5218
+						foreach ($role_options as $role_option_key => $role_option_name) {
5219 5219
 							$role_option_i++;
5220 5220
 
5221 5221
 							$content .= '<div class="col-sm-6">';
@@ -5235,19 +5235,19 @@  discard block
 block discarded – undo
5235 5235
 							$content .= '</div>';
5236 5236
 						}
5237 5237
 					$content .= '</div>';
5238
-					$content .= '<div class="bs-vc-sep-wrap text-center position-absolute top-0 mt-n3"><div class="bs-vc-sep-cond d-inline-block badge text-dark bg-gray mt-1">' . esc_html__( 'AND', 'ayecode-connect' ) . '</div></div>';
5238
+					$content .= '<div class="bs-vc-sep-wrap text-center position-absolute top-0 mt-n3"><div class="bs-vc-sep-cond d-inline-block badge text-dark bg-gray mt-1">' . esc_html__('AND', 'ayecode-connect') . '</div></div>';
5239 5239
 				$content .= '</div>';
5240 5240
 			$content .= '</div>';
5241 5241
 			$content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">';
5242 5242
 			$content .= '<div class="bs-vc-rule-sets"></div>';
5243
-			$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>';
5243
+			$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>';
5244 5244
 			$content .= '<div class="row"><div class="col-md-6 col-sm-12">';
5245 5245
 			$content .= aui()->select(
5246 5246
 				array(
5247 5247
 					'id'          => 'bsvc_output',
5248 5248
 					'name'        => 'bsvc_output',
5249
-					'label'       => __( 'What should happen if rules met.', 'ayecode-connect' ),
5250
-					'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5249
+					'label'       => __('What should happen if rules met.', 'ayecode-connect'),
5250
+					'placeholder' => __('Show Block', 'ayecode-connect'),
5251 5251
 					'class'       => 'bsvc_output form-select-sm no-select2 mw-100',
5252 5252
 					'options'     => sd_visibility_output_options(),
5253 5253
 					'default'     => '',
@@ -5266,8 +5266,8 @@  discard block
 block discarded – undo
5266 5266
 				array(
5267 5267
 					'id'              => 'bsvc_page',
5268 5268
 					'name'            => 'bsvc_page',
5269
-					'label'           => __( 'Page Content', 'ayecode-connect' ),
5270
-					'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5269
+					'label'           => __('Page Content', 'ayecode-connect'),
5270
+					'placeholder'     => __('Select Page ID...', 'ayecode-connect'),
5271 5271
 					'class'           => 'bsvc_page form-select-sm no-select2 mw-100',
5272 5272
 					'options'         => sd_template_page_options(),
5273 5273
 					'default'         => '',
@@ -5282,8 +5282,8 @@  discard block
 block discarded – undo
5282 5282
 				array(
5283 5283
 					'id'          => 'bsvc_tmpl_part',
5284 5284
 					'name'        => 'bsvc_tmpl_part',
5285
-					'label'       => __( 'Template Part', 'ayecode-connect' ),
5286
-					'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5285
+					'label'       => __('Template Part', 'ayecode-connect'),
5286
+					'placeholder' => __('Select Template Part...', 'ayecode-connect'),
5287 5287
 					'class'       => 'bsvc_tmpl_part form-select-sm no-select2 mw-100',
5288 5288
 					'options'     => sd_template_part_options(),
5289 5289
 					'default'     => '',
@@ -5301,8 +5301,8 @@  discard block
 block discarded – undo
5301 5301
 				array(
5302 5302
 					'id'               => 'bsvc_message_type',
5303 5303
 					'name'             => 'bsvc_message_type',
5304
-					'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5305
-					'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5304
+					'label'            => __('Custom Message Type', 'ayecode-connect'),
5305
+					'placeholder'      => __('Default (none)', 'ayecode-connect'),
5306 5306
 					'class'            => 'bsvc_message_type form-select-sm no-select2 mw-100',
5307 5307
 					'options'          => sd_aui_colors(),
5308 5308
 					'default'          => '',
@@ -5325,7 +5325,7 @@  discard block
 block discarded – undo
5325 5325
 					'name'            => 'bsvc_message',
5326 5326
 					'label'           => '',
5327 5327
 					'class'           => 'bsvc_message form-control-sm mb-3',
5328
-					'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5328
+					'placeholder'     => __('CUSTOM MESSAGE TO SHOW', 'ayecode-connect'),
5329 5329
 					'label_type'      => '',
5330 5330
 					'value'           => '',
5331 5331
 					'form_group_class' => ' ',
@@ -5338,8 +5338,8 @@  discard block
 block discarded – undo
5338 5338
 				array(
5339 5339
 					'id'          => 'bsvc_output_n',
5340 5340
 					'name'        => 'bsvc_output_n',
5341
-					'label'       => __( 'What should happen if rules NOT met.', 'ayecode-connect' ),
5342
-					'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5341
+					'label'       => __('What should happen if rules NOT met.', 'ayecode-connect'),
5342
+					'placeholder' => __('Show Block', 'ayecode-connect'),
5343 5343
 					'class'       => 'bsvc_output_n form-select-sm no-select2 mw-100',
5344 5344
 					'options'     => sd_visibility_output_options(),
5345 5345
 					'default'     => '',
@@ -5358,8 +5358,8 @@  discard block
 block discarded – undo
5358 5358
 				array(
5359 5359
 					'id'              => 'bsvc_page_n',
5360 5360
 					'name'            => 'bsvc_page_n',
5361
-					'label'           => __( 'Page Content', 'ayecode-connect' ),
5362
-					'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5361
+					'label'           => __('Page Content', 'ayecode-connect'),
5362
+					'placeholder'     => __('Select Page ID...', 'ayecode-connect'),
5363 5363
 					'class'           => 'bsvc_page_n form-select-sm no-select2 mw-100',
5364 5364
 					'options'         => sd_template_page_options(),
5365 5365
 					'default'         => '',
@@ -5374,8 +5374,8 @@  discard block
 block discarded – undo
5374 5374
 				array(
5375 5375
 					'id'          => 'bsvc_tmpl_part_n',
5376 5376
 					'name'        => 'bsvc_tmpl_part_n',
5377
-					'label'       => __( 'Template Part', 'ayecode-connect' ),
5378
-					'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5377
+					'label'       => __('Template Part', 'ayecode-connect'),
5378
+					'placeholder' => __('Select Template Part...', 'ayecode-connect'),
5379 5379
 					'class'       => 'bsvc_tmpl_part_n form-select-sm no-select2 mw-100',
5380 5380
 					'options'     => sd_template_part_options(),
5381 5381
 					'default'     => '',
@@ -5393,8 +5393,8 @@  discard block
 block discarded – undo
5393 5393
 				array(
5394 5394
 					'id'               => 'bsvc_message_type_n',
5395 5395
 					'name'             => 'bsvc_message_type_n',
5396
-					'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5397
-					'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5396
+					'label'            => __('Custom Message Type', 'ayecode-connect'),
5397
+					'placeholder'      => __('Default (none)', 'ayecode-connect'),
5398 5398
 					'class'            => 'bsvc_message_type_n form-select-sm no-select2 mw-100',
5399 5399
 					'options'          => sd_aui_colors(),
5400 5400
 					'default'          => '',
@@ -5417,7 +5417,7 @@  discard block
 block discarded – undo
5417 5417
 					'name'            => 'bsvc_message_n',
5418 5418
 					'label'           => '',
5419 5419
 					'class'           => 'bsvc_message_n form-control-sm',
5420
-					'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5420
+					'placeholder'     => __('CUSTOM MESSAGE TO SHOW', 'ayecode-connect'),
5421 5421
 					'label_type'      => '',
5422 5422
 					'value'           => '',
5423 5423
 					'form_group_class' => ' ',
@@ -5439,7 +5439,7 @@  discard block
 block discarded – undo
5439 5439
 			global $shortcode_insert_button_once;
5440 5440
 
5441 5441
 			// Fix conflicts with UpSolution Core in header template edit element.
5442
-			if ( defined( 'US_CORE_DIR' ) && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html' ) {
5442
+			if (defined('US_CORE_DIR') && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html') {
5443 5443
 				$shortcode_insert_button_once = true;
5444 5444
 			}
5445 5445
 		}
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.
includes/class-getpaid-daily-maintenance.php 2 patches
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -12,142 +12,142 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Daily_Maintenance {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 */
18
-	public function __construct() {
19
-
20
-		// Clear deprecated events.
21
-		add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
22
-
23
-		// (Maybe) schedule a cron that runs daily.
24
-		add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
25
-
26
-		// Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
-		add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
-		add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
-		add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) );
31
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
32
-
33
-	}
34
-
35
-	/**
36
-	 * Schedules a cron to run every day at 7 a.m
37
-	 *
38
-	 */
39
-	public function maybe_create_scheduled_event() {
40
-
41
-		if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
42
-			$timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
43
-			wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
44
-		}
45
-
46
-	}
47
-
48
-	/**
49
-	 * Clears deprecated events.
50
-	 *
51
-	 */
52
-	public function maybe_clear_deprecated_events() {
53
-
54
-		if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
55
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
56
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
57
-			update_option( 'wpinv_cleared_old_events', 1 );
58
-		}
59
-
60
-	}
61
-
62
-	/**
63
-	 * Fires the old hook for backwards compatibility.
64
-	 *
65
-	 */
66
-	public function backwards_compat() {
67
-		do_action( 'wpinv_register_schedule_event_daily' );
68
-	}
69
-
70
-	/**
71
-	 * Checks for subscriptions that are scheduled to renew.
72
-	 *
73
-	 */
74
-	public function check_renewing_subscriptions() {
75
-
76
-		// Fetch subscriptions that expire today.
77
-		$args  = array(
78
-			'number'             => -1,
79
-			'count_total'        => false,
80
-			'status'             => 'trialling active',
81
-			'date_expires_query' => array(
82
-				array(
83
-					'year'    => gmdate( 'Y' ),
84
-					'month'   => gmdate( 'n' ),
85
-					'day'     => gmdate( 'j' ),
86
-					'compare' => '=',
87
-				),
88
-			),
89
-		);
90
-
91
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
92
-
93
-		foreach ( $subscriptions->get_results() as $subscription ) {
94
-			/** @var WPInv_Subscription $subscription */
95
-			if ( $subscription->is_last_renewal() ) {
96
-				$subscription->complete();
97
-			} else {
98
-				do_action( 'getpaid_should_renew_subscription', $subscription, $subscription->get_parent_invoice() );
99
-			}
100
-		}
101
-	}
102
-
103
-	/**
104
-	 * Expires expired subscriptions.
105
-	 *
106
-	 */
107
-	public function maybe_expire_subscriptions() {
108
-
109
-		// Fetch expired subscriptions (skips those that expire today).
110
-		$args  = array(
111
-			'number'             => -1,
112
-			'count_total'        => false,
113
-			'status'             => 'trialling active failing cancelled',
114
-			'date_expires_query' => array(
115
-				'before'    => 'yesterday',
116
-				'inclusive' => false,
117
-			),
118
-		);
119
-
120
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
121
-
122
-		foreach ( $subscriptions->get_results() as $subscription ) {
123
-			if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', false, $subscription ) ) {
124
-				$subscription->set_status( 'expired' );
125
-				$subscription->save();
126
-			}
127
-		}
128
-
129
-	}
130
-
131
-	/**
132
-	 * Logs cron runs.
133
-	 *
134
-	 */
135
-	public function log_cron_run() {
136
-		wpinv_error_log( 'GetPaid Daily Cron', false );
137
-	}
138
-
139
-	/**
140
-	 * Updates GeoIP databases.
141
-	 *
142
-	 */
143
-	public function maybe_update_geoip_databases() {
144
-		$updated = get_transient( 'getpaid_updated_geoip_databases' );
145
-
146
-		if ( false === $updated ) {
147
-			set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
148
-			do_action( 'getpaid_update_geoip_databases' );
149
-		}
150
-
151
-	}
15
+    /**
16
+     * Class constructor.
17
+     */
18
+    public function __construct() {
19
+
20
+        // Clear deprecated events.
21
+        add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
22
+
23
+        // (Maybe) schedule a cron that runs daily.
24
+        add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
25
+
26
+        // Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
+        add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
+        add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
+        add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
+        add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) );
31
+        add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
32
+
33
+    }
34
+
35
+    /**
36
+     * Schedules a cron to run every day at 7 a.m
37
+     *
38
+     */
39
+    public function maybe_create_scheduled_event() {
40
+
41
+        if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
42
+            $timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
43
+            wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
44
+        }
45
+
46
+    }
47
+
48
+    /**
49
+     * Clears deprecated events.
50
+     *
51
+     */
52
+    public function maybe_clear_deprecated_events() {
53
+
54
+        if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
55
+            wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
56
+            wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
57
+            update_option( 'wpinv_cleared_old_events', 1 );
58
+        }
59
+
60
+    }
61
+
62
+    /**
63
+     * Fires the old hook for backwards compatibility.
64
+     *
65
+     */
66
+    public function backwards_compat() {
67
+        do_action( 'wpinv_register_schedule_event_daily' );
68
+    }
69
+
70
+    /**
71
+     * Checks for subscriptions that are scheduled to renew.
72
+     *
73
+     */
74
+    public function check_renewing_subscriptions() {
75
+
76
+        // Fetch subscriptions that expire today.
77
+        $args  = array(
78
+            'number'             => -1,
79
+            'count_total'        => false,
80
+            'status'             => 'trialling active',
81
+            'date_expires_query' => array(
82
+                array(
83
+                    'year'    => gmdate( 'Y' ),
84
+                    'month'   => gmdate( 'n' ),
85
+                    'day'     => gmdate( 'j' ),
86
+                    'compare' => '=',
87
+                ),
88
+            ),
89
+        );
90
+
91
+        $subscriptions = new GetPaid_Subscriptions_Query( $args );
92
+
93
+        foreach ( $subscriptions->get_results() as $subscription ) {
94
+            /** @var WPInv_Subscription $subscription */
95
+            if ( $subscription->is_last_renewal() ) {
96
+                $subscription->complete();
97
+            } else {
98
+                do_action( 'getpaid_should_renew_subscription', $subscription, $subscription->get_parent_invoice() );
99
+            }
100
+        }
101
+    }
102
+
103
+    /**
104
+     * Expires expired subscriptions.
105
+     *
106
+     */
107
+    public function maybe_expire_subscriptions() {
108
+
109
+        // Fetch expired subscriptions (skips those that expire today).
110
+        $args  = array(
111
+            'number'             => -1,
112
+            'count_total'        => false,
113
+            'status'             => 'trialling active failing cancelled',
114
+            'date_expires_query' => array(
115
+                'before'    => 'yesterday',
116
+                'inclusive' => false,
117
+            ),
118
+        );
119
+
120
+        $subscriptions = new GetPaid_Subscriptions_Query( $args );
121
+
122
+        foreach ( $subscriptions->get_results() as $subscription ) {
123
+            if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', false, $subscription ) ) {
124
+                $subscription->set_status( 'expired' );
125
+                $subscription->save();
126
+            }
127
+        }
128
+
129
+    }
130
+
131
+    /**
132
+     * Logs cron runs.
133
+     *
134
+     */
135
+    public function log_cron_run() {
136
+        wpinv_error_log( 'GetPaid Daily Cron', false );
137
+    }
138
+
139
+    /**
140
+     * Updates GeoIP databases.
141
+     *
142
+     */
143
+    public function maybe_update_geoip_databases() {
144
+        $updated = get_transient( 'getpaid_updated_geoip_databases' );
145
+
146
+        if ( false === $updated ) {
147
+            set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
148
+            do_action( 'getpaid_update_geoip_databases' );
149
+        }
150
+
151
+    }
152 152
 
153 153
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Daily maintenance class.
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
 	public function __construct() {
19 19
 
20 20
 		// Clear deprecated events.
21
-		add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
21
+		add_action('wp', array($this, 'maybe_clear_deprecated_events'));
22 22
 
23 23
 		// (Maybe) schedule a cron that runs daily.
24
-		add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
24
+		add_action('wp', array($this, 'maybe_create_scheduled_event'));
25 25
 
26 26
 		// Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
-		add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
-		add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
-		add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) );
31
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
27
+		add_action('getpaid_daily_maintenance', array($this, 'log_cron_run'));
28
+		add_action('getpaid_daily_maintenance', array($this, 'backwards_compat'));
29
+		add_action('getpaid_daily_maintenance', array($this, 'maybe_expire_subscriptions'));
30
+		add_action('getpaid_daily_maintenance', array($this, 'check_renewing_subscriptions'));
31
+		add_action('getpaid_daily_maintenance', array($this, 'maybe_update_geoip_databases'));
32 32
 
33 33
 	}
34 34
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	public function maybe_create_scheduled_event() {
40 40
 
41
-		if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
42
-			$timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
43
-			wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
41
+		if (!wp_next_scheduled('getpaid_daily_maintenance')) {
42
+			$timestamp = strtotime('tomorrow 07:00:00', current_time('timestamp'));
43
+			wp_schedule_event($timestamp, 'daily', 'getpaid_daily_maintenance');
44 44
 		}
45 45
 
46 46
 	}
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function maybe_clear_deprecated_events() {
53 53
 
54
-		if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
55
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
56
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
57
-			update_option( 'wpinv_cleared_old_events', 1 );
54
+		if (!get_option('wpinv_cleared_old_events')) {
55
+			wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily');
56
+			wp_clear_scheduled_hook('wpinv_register_schedule_event_daily');
57
+			update_option('wpinv_cleared_old_events', 1);
58 58
 		}
59 59
 
60 60
 	}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 */
66 66
 	public function backwards_compat() {
67
-		do_action( 'wpinv_register_schedule_event_daily' );
67
+		do_action('wpinv_register_schedule_event_daily');
68 68
 	}
69 69
 
70 70
 	/**
@@ -74,28 +74,28 @@  discard block
 block discarded – undo
74 74
 	public function check_renewing_subscriptions() {
75 75
 
76 76
 		// Fetch subscriptions that expire today.
77
-		$args  = array(
77
+		$args = array(
78 78
 			'number'             => -1,
79 79
 			'count_total'        => false,
80 80
 			'status'             => 'trialling active',
81 81
 			'date_expires_query' => array(
82 82
 				array(
83
-					'year'    => gmdate( 'Y' ),
84
-					'month'   => gmdate( 'n' ),
85
-					'day'     => gmdate( 'j' ),
83
+					'year'    => gmdate('Y'),
84
+					'month'   => gmdate('n'),
85
+					'day'     => gmdate('j'),
86 86
 					'compare' => '=',
87 87
 				),
88 88
 			),
89 89
 		);
90 90
 
91
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
91
+		$subscriptions = new GetPaid_Subscriptions_Query($args);
92 92
 
93
-		foreach ( $subscriptions->get_results() as $subscription ) {
93
+		foreach ($subscriptions->get_results() as $subscription) {
94 94
 			/** @var WPInv_Subscription $subscription */
95
-			if ( $subscription->is_last_renewal() ) {
95
+			if ($subscription->is_last_renewal()) {
96 96
 				$subscription->complete();
97 97
 			} else {
98
-				do_action( 'getpaid_should_renew_subscription', $subscription, $subscription->get_parent_invoice() );
98
+				do_action('getpaid_should_renew_subscription', $subscription, $subscription->get_parent_invoice());
99 99
 			}
100 100
 		}
101 101
 	}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	public function maybe_expire_subscriptions() {
108 108
 
109 109
 		// Fetch expired subscriptions (skips those that expire today).
110
-		$args  = array(
110
+		$args = array(
111 111
 			'number'             => -1,
112 112
 			'count_total'        => false,
113 113
 			'status'             => 'trialling active failing cancelled',
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 			),
118 118
 		);
119 119
 
120
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
120
+		$subscriptions = new GetPaid_Subscriptions_Query($args);
121 121
 
122
-		foreach ( $subscriptions->get_results() as $subscription ) {
123
-			if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', false, $subscription ) ) {
124
-				$subscription->set_status( 'expired' );
122
+		foreach ($subscriptions->get_results() as $subscription) {
123
+			if (apply_filters('getpaid_daily_maintenance_should_expire_subscription', false, $subscription)) {
124
+				$subscription->set_status('expired');
125 125
 				$subscription->save();
126 126
 			}
127 127
 		}
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 */
135 135
 	public function log_cron_run() {
136
-		wpinv_error_log( 'GetPaid Daily Cron', false );
136
+		wpinv_error_log('GetPaid Daily Cron', false);
137 137
 	}
138 138
 
139 139
 	/**
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 */
143 143
 	public function maybe_update_geoip_databases() {
144
-		$updated = get_transient( 'getpaid_updated_geoip_databases' );
144
+		$updated = get_transient('getpaid_updated_geoip_databases');
145 145
 
146
-		if ( false === $updated ) {
147
-			set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
148
-			do_action( 'getpaid_update_geoip_databases' );
146
+		if (false === $updated) {
147
+			set_transient('getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS);
148
+			do_action('getpaid_update_geoip_databases');
149 149
 		}
150 150
 
151 151
 	}
Please login to merge, or discard this patch.