Passed
Pull Request — master (#191)
by
unknown
04:15
created
includes/wpinv-invoice-functions.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 }
670 670
 
671 671
 function wpinv_get_payment_key( $invoice_id = 0 ) {
672
-	$invoice = new WPInv_Invoice( $invoice_id );
672
+    $invoice = new WPInv_Invoice( $invoice_id );
673 673
     return $invoice->get_key();
674 674
 }
675 675
 
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
         return false;
920 920
     }
921 921
     $invoice = wpinv_get_invoice_cart();
922
-	if ( empty( $invoice ) ) {
922
+    if ( empty( $invoice ) ) {
923 923
         return false;
924 924
     }
925 925
 
@@ -1212,20 +1212,20 @@  discard block
 block discarded – undo
1212 1212
 }
1213 1213
 
1214 1214
 function wpinv_checkout_get_cc_info() {
1215
-	$cc_info = array();
1216
-	$cc_info['card_name']      = isset( $_POST['card_name'] )       ? sanitize_text_field( $_POST['card_name'] )       : '';
1217
-	$cc_info['card_number']    = isset( $_POST['card_number'] )     ? sanitize_text_field( $_POST['card_number'] )     : '';
1218
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] )        ? sanitize_text_field( $_POST['card_cvc'] )        : '';
1219
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] )  ? sanitize_text_field( $_POST['card_exp_month'] )  : '';
1220
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] )   ? sanitize_text_field( $_POST['card_exp_year'] )   : '';
1221
-	$cc_info['card_address']   = isset( $_POST['wpinv_address'] )  ? sanitize_text_field( $_POST['wpinv_address'] ) : '';
1222
-	$cc_info['card_city']      = isset( $_POST['wpinv_city'] )     ? sanitize_text_field( $_POST['wpinv_city'] )    : '';
1223
-	$cc_info['card_state']     = isset( $_POST['wpinv_state'] )    ? sanitize_text_field( $_POST['wpinv_state'] )   : '';
1224
-	$cc_info['card_country']   = isset( $_POST['wpinv_country'] )  ? sanitize_text_field( $_POST['wpinv_country'] ) : '';
1225
-	$cc_info['card_zip']       = isset( $_POST['wpinv_zip'] )      ? sanitize_text_field( $_POST['wpinv_zip'] )     : '';
1226
-
1227
-	// Return cc info
1228
-	return $cc_info;
1215
+    $cc_info = array();
1216
+    $cc_info['card_name']      = isset( $_POST['card_name'] )       ? sanitize_text_field( $_POST['card_name'] )       : '';
1217
+    $cc_info['card_number']    = isset( $_POST['card_number'] )     ? sanitize_text_field( $_POST['card_number'] )     : '';
1218
+    $cc_info['card_cvc']       = isset( $_POST['card_cvc'] )        ? sanitize_text_field( $_POST['card_cvc'] )        : '';
1219
+    $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] )  ? sanitize_text_field( $_POST['card_exp_month'] )  : '';
1220
+    $cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] )   ? sanitize_text_field( $_POST['card_exp_year'] )   : '';
1221
+    $cc_info['card_address']   = isset( $_POST['wpinv_address'] )  ? sanitize_text_field( $_POST['wpinv_address'] ) : '';
1222
+    $cc_info['card_city']      = isset( $_POST['wpinv_city'] )     ? sanitize_text_field( $_POST['wpinv_city'] )    : '';
1223
+    $cc_info['card_state']     = isset( $_POST['wpinv_state'] )    ? sanitize_text_field( $_POST['wpinv_state'] )   : '';
1224
+    $cc_info['card_country']   = isset( $_POST['wpinv_country'] )  ? sanitize_text_field( $_POST['wpinv_country'] ) : '';
1225
+    $cc_info['card_zip']       = isset( $_POST['wpinv_zip'] )      ? sanitize_text_field( $_POST['wpinv_zip'] )     : '';
1226
+
1227
+    // Return cc info
1228
+    return $cc_info;
1229 1229
 }
1230 1230
 
1231 1231
 function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) {
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
         $required_fields  = wpinv_checkout_required_fields();
1423 1423
 
1424 1424
         // Loop through required fields and show error messages
1425
-         if ( !empty( $required_fields ) ) {
1425
+            if ( !empty( $required_fields ) ) {
1426 1426
             foreach ( $required_fields as $field_name => $value ) {
1427 1427
                 if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) {
1428 1428
                     wpinv_set_error( $value['error_id'], $value['error_message'] );
@@ -1528,7 +1528,7 @@  discard block
 block discarded – undo
1528 1528
 }
1529 1529
 
1530 1530
 function wpinv_get_checkout_session() {
1531
-	global $wpi_session;
1531
+    global $wpi_session;
1532 1532
     
1533 1533
     return $wpi_session->get( 'wpinv_checkout' );
1534 1534
 }
@@ -1891,57 +1891,57 @@  discard block
 block discarded – undo
1891 1891
 }
1892 1892
 
1893 1893
 function wpinv_get_invoice_id_by_key( $key ) {
1894
-	global $wpdb;
1894
+    global $wpdb;
1895 1895
 
1896
-	$invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) );
1896
+    $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) );
1897 1897
 
1898
-	if ( $invoice_id != NULL )
1899
-		return $invoice_id;
1898
+    if ( $invoice_id != NULL )
1899
+        return $invoice_id;
1900 1900
 
1901
-	return 0;
1901
+    return 0;
1902 1902
 }
1903 1903
 
1904 1904
 function wpinv_can_view_receipt( $invoice_key = '' ) {
1905
-	$return = false;
1906
-
1907
-	if ( empty( $invoice_key ) ) {
1908
-		return $return;
1909
-	}
1910
-
1911
-	global $wpinv_receipt_args;
1912
-
1913
-	$wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key );
1914
-	if ( isset( $_GET['invoice-id'] ) ) {
1915
-		$wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0;
1916
-	}
1917
-
1918
-	if ( empty( $wpinv_receipt_args['id'] ) ) {
1919
-		return $return;
1920
-	}
1921
-
1922
-	$invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] );
1923
-	if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) {
1924
-		return $return;
1925
-	}
1926
-
1927
-	if ( is_user_logged_in() ) {
1928
-		if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) {
1929
-			$return = true;
1930
-		}
1931
-	}
1932
-
1933
-	$session = wpinv_get_checkout_session();
1934
-	if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) {
1935
-		$check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key'];
1936
-
1937
-		if ( wpinv_require_login_to_checkout() ) {
1938
-			$return = $return && $check_key === $invoice_key;
1939
-		} else {
1940
-			$return = $check_key === $invoice_key;
1941
-		}
1942
-	}
1943
-
1944
-	return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key );
1905
+    $return = false;
1906
+
1907
+    if ( empty( $invoice_key ) ) {
1908
+        return $return;
1909
+    }
1910
+
1911
+    global $wpinv_receipt_args;
1912
+
1913
+    $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key );
1914
+    if ( isset( $_GET['invoice-id'] ) ) {
1915
+        $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0;
1916
+    }
1917
+
1918
+    if ( empty( $wpinv_receipt_args['id'] ) ) {
1919
+        return $return;
1920
+    }
1921
+
1922
+    $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] );
1923
+    if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) {
1924
+        return $return;
1925
+    }
1926
+
1927
+    if ( is_user_logged_in() ) {
1928
+        if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) {
1929
+            $return = true;
1930
+        }
1931
+    }
1932
+
1933
+    $session = wpinv_get_checkout_session();
1934
+    if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) {
1935
+        $check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key'];
1936
+
1937
+        if ( wpinv_require_login_to_checkout() ) {
1938
+            $return = $return && $check_key === $invoice_key;
1939
+        } else {
1940
+            $return = $check_key === $invoice_key;
1941
+        }
1942
+    }
1943
+
1944
+    return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key );
1945 1945
 }
1946 1946
 
1947 1947
 function wpinv_pay_for_invoice() {
Please login to merge, or discard this patch.
includes/class-wpinv-privacy.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -31,27 +31,27 @@
 block discarded – undo
31 31
     public function get_privacy_message() {
32 32
 
33 33
         $content = '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' .
34
-                   '<div contenteditable="false">' .
35
-                   '<p class="wp-policy-help">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' .
36
-                   '</div>' .
37
-                   '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' .
38
-                   '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' .
39
-                   '<ul>' .
40
-                   '<li>' . __( '- Send you important account/order/service information.', 'invoicing' ) . '</li>' .
41
-                   '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' .
42
-                   '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' .
43
-                   '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
44
-                   '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' .
45
-                   '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
46
-                   '</ul>' .
47
-                   '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' .
48
-                   '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' .
49
-                   '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' .
50
-                   '<div contenteditable="false">' .
51
-                   '<p class="wp-policy-help">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' .
52
-                   '</div>' .
53
-                   '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' .
54
-                   '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>';
34
+                    '<div contenteditable="false">' .
35
+                    '<p class="wp-policy-help">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' .
36
+                    '</div>' .
37
+                    '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' .
38
+                    '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' .
39
+                    '<ul>' .
40
+                    '<li>' . __( '- Send you important account/order/service information.', 'invoicing' ) . '</li>' .
41
+                    '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' .
42
+                    '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' .
43
+                    '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
44
+                    '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' .
45
+                    '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
46
+                    '</ul>' .
47
+                    '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' .
48
+                    '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' .
49
+                    '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' .
50
+                    '<div contenteditable="false">' .
51
+                    '<p class="wp-policy-help">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' .
52
+                    '</div>' .
53
+                    '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' .
54
+                    '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>';
55 55
 
56 56
 
57 57
 
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/OxidInstaller.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
 class OxidInstaller extends BaseInstaller
7 7
 {
8
-	const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/';
8
+    const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/';
9 9
 
10 10
     protected $locations = array(
11 11
         'module'    => 'modules/{$name}/',
@@ -13,47 +13,47 @@  discard block
 block discarded – undo
13 13
         'out'    => 'out/{$name}/',
14 14
     );
15 15
 
16
-	/**
17
-	 * getInstallPath
18
-	 *
19
-	 * @param PackageInterface $package
20
-	 * @param string $frameworkType
21
-	 * @return void
22
-	 */
23
-	public function getInstallPath(PackageInterface $package, $frameworkType = '')
24
-	{
25
-		$installPath = parent::getInstallPath($package, $frameworkType);
26
-		$type = $this->package->getType();
27
-		if ($type === 'oxid-module') {
28
-			$this->prepareVendorDirectory($installPath);
29
-		}
30
-		return $installPath;
31
-	}
16
+    /**
17
+     * getInstallPath
18
+     *
19
+     * @param PackageInterface $package
20
+     * @param string $frameworkType
21
+     * @return void
22
+     */
23
+    public function getInstallPath(PackageInterface $package, $frameworkType = '')
24
+    {
25
+        $installPath = parent::getInstallPath($package, $frameworkType);
26
+        $type = $this->package->getType();
27
+        if ($type === 'oxid-module') {
28
+            $this->prepareVendorDirectory($installPath);
29
+        }
30
+        return $installPath;
31
+    }
32 32
 
33
-	/**
34
-	 * prepareVendorDirectory
35
-	 *
36
-	 * Makes sure there is a vendormetadata.php file inside
37
-	 * the vendor folder if there is a vendor folder.
38
-	 *
39
-	 * @param string $installPath
40
-	 * @return void
41
-	 */
42
-	protected function prepareVendorDirectory($installPath)
43
-	{
44
-		$matches = '';
45
-		$hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches);
46
-		if (!$hasVendorDirectory) {
47
-			return;
48
-		}
33
+    /**
34
+     * prepareVendorDirectory
35
+     *
36
+     * Makes sure there is a vendormetadata.php file inside
37
+     * the vendor folder if there is a vendor folder.
38
+     *
39
+     * @param string $installPath
40
+     * @return void
41
+     */
42
+    protected function prepareVendorDirectory($installPath)
43
+    {
44
+        $matches = '';
45
+        $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches);
46
+        if (!$hasVendorDirectory) {
47
+            return;
48
+        }
49 49
 
50
-		$vendorDirectory = $matches['vendor'];
51
-		$vendorPath = getcwd() . '/modules/' . $vendorDirectory;
52
-		if (!file_exists($vendorPath)) {
53
-			mkdir($vendorPath, 0755, true);
54
-		}
50
+        $vendorDirectory = $matches['vendor'];
51
+        $vendorPath = getcwd() . '/modules/' . $vendorDirectory;
52
+        if (!file_exists($vendorPath)) {
53
+            mkdir($vendorPath, 0755, true);
54
+        }
55 55
 
56
-		$vendorMetaDataPath = $vendorPath . '/vendormetadata.php';
57
-		touch($vendorMetaDataPath);
58
-	}
56
+        $vendorMetaDataPath = $vendorPath . '/vendormetadata.php';
57
+        touch($vendorMetaDataPath);
58
+    }
59 59
 }
Please login to merge, or discard this patch.
composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 
4 4
 class ClanCatsFrameworkInstaller extends BaseInstaller
5 5
 {
6
-	protected $locations = array(
7
-		'ship'      => 'CCF/orbit/{$name}/',
8
-		'theme'     => 'CCF/app/themes/{$name}/',
9
-	);
6
+    protected $locations = array(
7
+        'ship'      => 'CCF/orbit/{$name}/',
8
+        'theme'     => 'CCF/app/themes/{$name}/',
9
+    );
10 10
 }
11 11
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
         'library'   => 'libraries/{$name}/',
11 11
         'profile'   => 'profiles/{$name}/',
12 12
         'drush'     => 'drush/{$name}/',
13
-	    'custom-theme' => 'themes/custom/{$name}/',
14
-	    'custom-module' => 'modules/custom/{$name}/',
13
+        'custom-theme' => 'themes/custom/{$name}/',
14
+        'custom-module' => 'modules/custom/{$name}/',
15 15
     );
16 16
 }
Please login to merge, or discard this patch.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 1 patch
Indentation   +353 added lines, -353 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Bail if we are not in WP.
14 14
  */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -21,285 +21,285 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class WP_Font_Awesome_Settings
28
-	 * @since 1.0.10 Now able to pass wp.org theme check.
29
-	 * @ver 1.0.10
30
-	 * @todo decide how to implement textdomain
31
-	 */
32
-	class WP_Font_Awesome_Settings {
33
-
34
-		/**
35
-		 * Class version version.
36
-		 *
37
-		 * @var string
38
-		 */
39
-		public $version = '1.0.10';
40
-
41
-		/**
42
-		 * Class textdomain.
43
-		 *
44
-		 * @var string
45
-		 */
46
-		public $textdomain = 'font-awesome-settings';
47
-
48
-		/**
49
-		 * Latest version of Font Awesome at time of publish published.
50
-		 *
51
-		 * @var string
52
-		 */
53
-		public $latest = "5.6.1";
54
-
55
-		/**
56
-		 * The title.
57
-		 *
58
-		 * @var string
59
-		 */
60
-		public $name = 'Font Awesome';
61
-
62
-		/**
63
-		 * Holds the settings values.
64
-		 *
65
-		 * @var array
66
-		 */
67
-		private $settings;
68
-
69
-		/**
70
-		 * WP_Font_Awesome_Settings instance.
71
-		 *
72
-		 * @access private
73
-		 * @since  1.0.0
74
-		 * @var    WP_Font_Awesome_Settings There can be only one!
75
-		 */
76
-		private static $instance = null;
77
-
78
-		/**
79
-		 * Main WP_Font_Awesome_Settings Instance.
80
-		 *
81
-		 * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
82
-		 *
83
-		 * @since 1.0.0
84
-		 * @static
85
-		 * @return WP_Font_Awesome_Settings - Main instance.
86
-		 */
87
-		public static function instance() {
88
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
89
-				self::$instance = new WP_Font_Awesome_Settings;
90
-
91
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
92
-
93
-				if ( is_admin() ) {
94
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
95
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
96
-				}
97
-
98
-				do_action( 'wp_font_awesome_settings_loaded' );
99
-			}
100
-
101
-			return self::$instance;
102
-		}
103
-
104
-		/**
105
-		 * Initiate the settings and add the required action hooks.
106
-		 *
107
-		 * @since 1.0.8 Settings name wrong - FIXED
108
-		 */
109
-		public function init() {
110
-			$this->settings = $this->get_settings();
111
-
112
-			if ( $this->settings['type'] == 'CSS' ) {
113
-
114
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
115
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );//echo '###';exit;
116
-				}
117
-
118
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
119
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
120
-				}
121
-
122
-			} else {
123
-
124
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
125
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );//echo '###';exit;
126
-				}
127
-
128
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
129
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
130
-				}
131
-			}
132
-
133
-			// remove font awesome if set to do so
134
-			if ( $this->settings['dequeue'] == '1' ) {
135
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
136
-			}
137
-
138
-		}
139
-
140
-		/**
141
-		 * Adds the Font Awesome styles.
142
-		 */
143
-		public function enqueue_style() {
144
-			// build url
145
-			$url = $this->get_url();
146
-
147
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
148
-			wp_register_style( 'font-awesome', $url, array(), null );
149
-			wp_enqueue_style( 'font-awesome' );
150
-
151
-			if ( $this->settings['shims'] ) {
152
-				$url = $this->get_url( true );
153
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
154
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
155
-				wp_enqueue_style( 'font-awesome-shims' );
156
-			}
157
-		}
158
-
159
-		/**
160
-		 * Adds the Font Awesome JS.
161
-		 */
162
-		public function enqueue_scripts() {
163
-			// build url
164
-			$url = $this->get_url();
165
-
166
-			$deregister_function = 'wp'.'_'.'deregister'.'_'.'script';
167
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
168
-			wp_register_script( 'font-awesome', $url, array(), null );
169
-			wp_enqueue_script( 'font-awesome' );
170
-
171
-			if ( $this->settings['shims'] ) {
172
-				$url = $this->get_url( true );
173
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
174
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
175
-				wp_enqueue_script( 'font-awesome-shims' );
176
-			}
177
-		}
178
-
179
-		/**
180
-		 * Get the url of the Font Awesome files.
181
-		 *
182
-		 * @param bool $shims If this is a shim file or not.
183
-		 *
184
-		 * @return string The url to the file.
185
-		 */
186
-		public function get_url( $shims = false ) {
187
-			$script  = $shims ? 'v4-shims' : 'all';
188
-			$type    = $this->settings['type'];
189
-			$version = $this->settings['version'];
190
-
191
-			$url = "https://use.fontawesome.com/releases/"; // CDN
192
-			$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
193
-			$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
194
-			$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
195
-			$url .= "?wpfas=true"; // set our var so our version is not removed
196
-
197
-			return $url;
198
-		}
199
-
200
-		/**
201
-		 * Try and remove any other versions of Font Awesome added by other plugins/themes.
202
-		 *
203
-		 * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
204
-		 *
205
-		 * @param $url
206
-		 * @param $original_url
207
-		 * @param $_context
208
-		 *
209
-		 * @return string The filtered url.
210
-		 */
211
-		public function remove_font_awesome( $url, $original_url, $_context ) {
212
-
213
-			if ( $_context == 'display'
214
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
215
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
216
-			) {// it's a font-awesome-url (probably)
217
-
218
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
219
-					if ( $this->settings['type'] == 'JS' ) {
220
-						if ( $this->settings['js-pseudo'] ) {
221
-							$url .= "' data-search-pseudo-elements defer='defer";
222
-						} else {
223
-							$url .= "' defer='defer";
224
-						}
225
-					}
226
-				} else {
227
-					$url = ''; // removing the url removes the file
228
-				}
229
-
230
-			}
231
-
232
-			return $url;
233
-		}
234
-
235
-		/**
236
-		 * Register the database settings with WordPress.
237
-		 */
238
-		public function register_settings() {
239
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
240
-		}
241
-
242
-		/**
243
-		 * Add the WordPress settings menu item.
244
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
245
-		 */
246
-		public function menu_item() {
247
-			$menu_function = 'add'.'_'.'options'.'_'.'page'; // won't pass theme check if function name present in theme
248
-			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
249
-				$this,
250
-				'settings_page'
251
-			) );
252
-		}
253
-
254
-		/**
255
-		 * Get the current Font Awesome output settings.
256
-		 *
257
-		 * @return array The array of settings.
258
-		 */
259
-		public function get_settings() {
260
-
261
-			$db_settings = get_option( 'wp-font-awesome-settings' );
262
-
263
-			$defaults = array(
264
-				'type'      => 'CSS', // type to use, CSS or JS
265
-				'version'   => '', // latest
266
-				'enqueue'   => '', // front and backend
267
-				'shims'     => '1', // default on for now, @todo maybe change to off in 2020
268
-				'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
269
-				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
270
-			);
271
-
272
-			$settings = wp_parse_args( $db_settings, $defaults );
273
-
274
-			/**
275
-			 * Filter the Font Awesome settings.
276
-			 *
277
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
278
-			 */
279
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
280
-		}
281
-
282
-
283
-		/**
284
-		 * The settings page html output.
285
-		 */
286
-		public function settings_page() {
287
-			if ( ! current_user_can( 'manage_options' ) ) {
288
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
289
-			}
290
-
291
-			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
292
-			if(isset($_REQUEST['force-version-check'])){
293
-				$this->get_latest_version($force_api = true);
294
-			}
295
-			?>
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class WP_Font_Awesome_Settings
28
+     * @since 1.0.10 Now able to pass wp.org theme check.
29
+     * @ver 1.0.10
30
+     * @todo decide how to implement textdomain
31
+     */
32
+    class WP_Font_Awesome_Settings {
33
+
34
+        /**
35
+         * Class version version.
36
+         *
37
+         * @var string
38
+         */
39
+        public $version = '1.0.10';
40
+
41
+        /**
42
+         * Class textdomain.
43
+         *
44
+         * @var string
45
+         */
46
+        public $textdomain = 'font-awesome-settings';
47
+
48
+        /**
49
+         * Latest version of Font Awesome at time of publish published.
50
+         *
51
+         * @var string
52
+         */
53
+        public $latest = "5.6.1";
54
+
55
+        /**
56
+         * The title.
57
+         *
58
+         * @var string
59
+         */
60
+        public $name = 'Font Awesome';
61
+
62
+        /**
63
+         * Holds the settings values.
64
+         *
65
+         * @var array
66
+         */
67
+        private $settings;
68
+
69
+        /**
70
+         * WP_Font_Awesome_Settings instance.
71
+         *
72
+         * @access private
73
+         * @since  1.0.0
74
+         * @var    WP_Font_Awesome_Settings There can be only one!
75
+         */
76
+        private static $instance = null;
77
+
78
+        /**
79
+         * Main WP_Font_Awesome_Settings Instance.
80
+         *
81
+         * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
82
+         *
83
+         * @since 1.0.0
84
+         * @static
85
+         * @return WP_Font_Awesome_Settings - Main instance.
86
+         */
87
+        public static function instance() {
88
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
89
+                self::$instance = new WP_Font_Awesome_Settings;
90
+
91
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
92
+
93
+                if ( is_admin() ) {
94
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
95
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
96
+                }
97
+
98
+                do_action( 'wp_font_awesome_settings_loaded' );
99
+            }
100
+
101
+            return self::$instance;
102
+        }
103
+
104
+        /**
105
+         * Initiate the settings and add the required action hooks.
106
+         *
107
+         * @since 1.0.8 Settings name wrong - FIXED
108
+         */
109
+        public function init() {
110
+            $this->settings = $this->get_settings();
111
+
112
+            if ( $this->settings['type'] == 'CSS' ) {
113
+
114
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
115
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );//echo '###';exit;
116
+                }
117
+
118
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
119
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
120
+                }
121
+
122
+            } else {
123
+
124
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
125
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );//echo '###';exit;
126
+                }
127
+
128
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
129
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
130
+                }
131
+            }
132
+
133
+            // remove font awesome if set to do so
134
+            if ( $this->settings['dequeue'] == '1' ) {
135
+                add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
136
+            }
137
+
138
+        }
139
+
140
+        /**
141
+         * Adds the Font Awesome styles.
142
+         */
143
+        public function enqueue_style() {
144
+            // build url
145
+            $url = $this->get_url();
146
+
147
+            wp_deregister_style( 'font-awesome' ); // deregister in case its already there
148
+            wp_register_style( 'font-awesome', $url, array(), null );
149
+            wp_enqueue_style( 'font-awesome' );
150
+
151
+            if ( $this->settings['shims'] ) {
152
+                $url = $this->get_url( true );
153
+                wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
154
+                wp_register_style( 'font-awesome-shims', $url, array(), null );
155
+                wp_enqueue_style( 'font-awesome-shims' );
156
+            }
157
+        }
158
+
159
+        /**
160
+         * Adds the Font Awesome JS.
161
+         */
162
+        public function enqueue_scripts() {
163
+            // build url
164
+            $url = $this->get_url();
165
+
166
+            $deregister_function = 'wp'.'_'.'deregister'.'_'.'script';
167
+            call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
168
+            wp_register_script( 'font-awesome', $url, array(), null );
169
+            wp_enqueue_script( 'font-awesome' );
170
+
171
+            if ( $this->settings['shims'] ) {
172
+                $url = $this->get_url( true );
173
+                call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
174
+                wp_register_script( 'font-awesome-shims', $url, array(), null );
175
+                wp_enqueue_script( 'font-awesome-shims' );
176
+            }
177
+        }
178
+
179
+        /**
180
+         * Get the url of the Font Awesome files.
181
+         *
182
+         * @param bool $shims If this is a shim file or not.
183
+         *
184
+         * @return string The url to the file.
185
+         */
186
+        public function get_url( $shims = false ) {
187
+            $script  = $shims ? 'v4-shims' : 'all';
188
+            $type    = $this->settings['type'];
189
+            $version = $this->settings['version'];
190
+
191
+            $url = "https://use.fontawesome.com/releases/"; // CDN
192
+            $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
193
+            $url .= $type == 'CSS' ? 'css/' : 'js/'; // type
194
+            $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
195
+            $url .= "?wpfas=true"; // set our var so our version is not removed
196
+
197
+            return $url;
198
+        }
199
+
200
+        /**
201
+         * Try and remove any other versions of Font Awesome added by other plugins/themes.
202
+         *
203
+         * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
204
+         *
205
+         * @param $url
206
+         * @param $original_url
207
+         * @param $_context
208
+         *
209
+         * @return string The filtered url.
210
+         */
211
+        public function remove_font_awesome( $url, $original_url, $_context ) {
212
+
213
+            if ( $_context == 'display'
214
+                 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
215
+                 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
216
+            ) {// it's a font-awesome-url (probably)
217
+
218
+                if ( strstr( $url, "wpfas=true" ) !== false ) {
219
+                    if ( $this->settings['type'] == 'JS' ) {
220
+                        if ( $this->settings['js-pseudo'] ) {
221
+                            $url .= "' data-search-pseudo-elements defer='defer";
222
+                        } else {
223
+                            $url .= "' defer='defer";
224
+                        }
225
+                    }
226
+                } else {
227
+                    $url = ''; // removing the url removes the file
228
+                }
229
+
230
+            }
231
+
232
+            return $url;
233
+        }
234
+
235
+        /**
236
+         * Register the database settings with WordPress.
237
+         */
238
+        public function register_settings() {
239
+            register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
240
+        }
241
+
242
+        /**
243
+         * Add the WordPress settings menu item.
244
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
245
+         */
246
+        public function menu_item() {
247
+            $menu_function = 'add'.'_'.'options'.'_'.'page'; // won't pass theme check if function name present in theme
248
+            call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
249
+                $this,
250
+                'settings_page'
251
+            ) );
252
+        }
253
+
254
+        /**
255
+         * Get the current Font Awesome output settings.
256
+         *
257
+         * @return array The array of settings.
258
+         */
259
+        public function get_settings() {
260
+
261
+            $db_settings = get_option( 'wp-font-awesome-settings' );
262
+
263
+            $defaults = array(
264
+                'type'      => 'CSS', // type to use, CSS or JS
265
+                'version'   => '', // latest
266
+                'enqueue'   => '', // front and backend
267
+                'shims'     => '1', // default on for now, @todo maybe change to off in 2020
268
+                'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
269
+                'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
270
+            );
271
+
272
+            $settings = wp_parse_args( $db_settings, $defaults );
273
+
274
+            /**
275
+             * Filter the Font Awesome settings.
276
+             *
277
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
278
+             */
279
+            return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
280
+        }
281
+
282
+
283
+        /**
284
+         * The settings page html output.
285
+         */
286
+        public function settings_page() {
287
+            if ( ! current_user_can( 'manage_options' ) ) {
288
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
289
+            }
290
+
291
+            // a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
292
+            if(isset($_REQUEST['force-version-check'])){
293
+                $this->get_latest_version($force_api = true);
294
+            }
295
+            ?>
296 296
 			<div class="wrap">
297 297
 				<h1><?php echo $this->name; ?></h1>
298 298
 				<form method="post" action="options.php">
299 299
 					<?php
300
-					settings_fields( 'wp-font-awesome-settings' );
301
-					do_settings_sections( 'wp-font-awesome-settings' );
302
-					?>
300
+                    settings_fields( 'wp-font-awesome-settings' );
301
+                    do_settings_sections( 'wp-font-awesome-settings' );
302
+                    ?>
303 303
 					<table class="form-table">
304 304
 						<tr valign="top">
305 305
 							<th scope="row"><label for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th>
@@ -396,87 +396,87 @@  discard block
 block discarded – undo
396 396
 
397 397
 					</table>
398 398
 					<?php
399
-					submit_button();
400
-					?>
399
+                    submit_button();
400
+                    ?>
401 401
 				</form>
402 402
 
403 403
 				<div id="wpfas-version"><?php echo $this->version; ?></div>
404 404
 			</div>
405 405
 
406 406
 			<?php
407
-		}
408
-
409
-		/**
410
-		 * Check a version number is valid and if so return it or else return an empty string.
411
-		 *
412
-		 * @param $version string The version number to check.
413
-		 * @since 1.0.6
414
-		 *
415
-		 * @return string Either a valid version number or an empty string.
416
-		 */
417
-		public function validate_version_number( $version ) {
418
-
419
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
420
-				// valid
421
-			} else {
422
-				$version = '';// not validated
423
-			}
424
-
425
-			return $version;
426
-		}
427
-
428
-
429
-		/**
430
-		 * Get the latest version of Font Awesome.
431
-		 *
432
-		 * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours.
433
-		 *
434
-		 * @since 1.0.7
435
-		 * @return mixed|string The latest version number found.
436
-		 */
437
-		public function get_latest_version($force_api = false) {
438
-			$latest_version = $this->latest;
439
-
440
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
441
-
442
-			if ( $cache === false || $force_api) { // its not set
443
-				$api_ver = $this->get_latest_version_from_api();
444
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
445
-					$latest_version = $api_ver;
446
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
447
-				}
448
-			} elseif ( $this->validate_version_number( $cache ) ) {
449
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
450
-					$latest_version = $cache;
451
-				}
452
-			}
453
-
454
-			return $latest_version;
455
-		}
456
-
457
-		/**
458
-		 * Get the latest Font Awesome version from the github API.
459
-		 *
460
-		 * @since 1.0.7
461
-		 * @return string The latest version number or `0` on API fail.
462
-		 */
463
-		public function get_latest_version_from_api() {
464
-			$version  = "0";
465
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
466
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
467
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
468
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
469
-					$version = $api_response['tag_name'];
470
-				}
471
-			}
472
-
473
-			return $version;
474
-		}
475
-
476
-	}
477
-
478
-	/**
479
-	 * Run the class if found.
480
-	 */
481
-	WP_Font_Awesome_Settings::instance();
407
+        }
408
+
409
+        /**
410
+         * Check a version number is valid and if so return it or else return an empty string.
411
+         *
412
+         * @param $version string The version number to check.
413
+         * @since 1.0.6
414
+         *
415
+         * @return string Either a valid version number or an empty string.
416
+         */
417
+        public function validate_version_number( $version ) {
418
+
419
+            if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
420
+                // valid
421
+            } else {
422
+                $version = '';// not validated
423
+            }
424
+
425
+            return $version;
426
+        }
427
+
428
+
429
+        /**
430
+         * Get the latest version of Font Awesome.
431
+         *
432
+         * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours.
433
+         *
434
+         * @since 1.0.7
435
+         * @return mixed|string The latest version number found.
436
+         */
437
+        public function get_latest_version($force_api = false) {
438
+            $latest_version = $this->latest;
439
+
440
+            $cache = get_transient( 'wp-font-awesome-settings-version' );
441
+
442
+            if ( $cache === false || $force_api) { // its not set
443
+                $api_ver = $this->get_latest_version_from_api();
444
+                if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
445
+                    $latest_version = $api_ver;
446
+                    set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
447
+                }
448
+            } elseif ( $this->validate_version_number( $cache ) ) {
449
+                if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
450
+                    $latest_version = $cache;
451
+                }
452
+            }
453
+
454
+            return $latest_version;
455
+        }
456
+
457
+        /**
458
+         * Get the latest Font Awesome version from the github API.
459
+         *
460
+         * @since 1.0.7
461
+         * @return string The latest version number or `0` on API fail.
462
+         */
463
+        public function get_latest_version_from_api() {
464
+            $version  = "0";
465
+            $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
466
+            if ( ! is_wp_error( $response ) && is_array( $response ) ) {
467
+                $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
468
+                if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
469
+                    $version = $api_response['tag_name'];
470
+                }
471
+            }
472
+
473
+            return $version;
474
+        }
475
+
476
+    }
477
+
478
+    /**
479
+     * Run the class if found.
480
+     */
481
+    WP_Font_Awesome_Settings::instance();
482 482
 }
483 483
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-item-functions.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -799,7 +799,7 @@
 block discarded – undo
799 799
                 case 'trial_interval':
800 800
                     $value = absint( $value );
801 801
                 break;
802
-				case 'editable':
802
+                case 'editable':
803 803
                     $value = (int) $value;
804 804
                 break;
805 805
             }
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/wp-super-duper.php 1 patch
Indentation   +1360 added lines, -1360 removed lines patch added patch discarded remove patch
@@ -1,141 +1,141 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 if ( ! class_exists( 'WP_Super_Duper' ) ) {
7 7
 
8 8
 
9
-	/**
10
-	 * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
11
-	 *
12
-	 * Should not be called direct but extended instead.
13
-	 *
14
-	 * Class WP_Super_Duper
15
-	 * @since 1.0.3 is_block_content_call() method added.
16
-	 * @since 1.0.3 Placeholder text will be shown for widget that return no block content.
17
-	 * @since 1.0.4 is_elementor_widget_output() method added.
18
-	 * @since 1.0.4 is_elementor_preview() method added.
19
-	 * @since 1.0.5 Block checkbox options are set as true by default even when set as false - FIXED
20
-	 * @since 1.0.6 Some refactoring for page builders - CHANGED
21
-	 * @since 1.0.7 Some refactoring for page builders - CHANGED
22
-	 * @since 1.0.8 Some refactoring for page builders ( cornerstone builder now supported ) - CHANGED
23
-	 * @since 1.0.9 Numbers saving as strings and not numbers which can cause block render issues on refresh - FIXED
24
-	 * @since 1.0.10 Some refactoring for page builders ( Avia builder for Enfold theme now supported ) - CHANGED
25
-	 * @ver 1.0.10
26
-	 */
27
-	class WP_Super_Duper extends WP_Widget {
28
-
29
-		public $version = "1.0.10";
30
-		public $block_code;
31
-		public $options;
32
-		public $base_id;
33
-		public $arguments = array();
34
-		public $instance = array();
35
-		private $class_name;
36
-
37
-		/**
38
-		 * Take the array options and use them to build.
39
-		 */
40
-		public function __construct( $options ) {
41
-			global $sd_widgets;
42
-
43
-			$sd_widgets[ $options['base_id'] ] = array(
44
-				'name'       => $options['name'],
45
-				'class_name' => $options['class_name']
46
-			);
47
-			$this->base_id                     = $options['base_id'];
48
-			// lets filter the options before we do anything
49
-			$options       = apply_filters( "wp_super_duper_options", $options );
50
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
51
-			$options       = $this->add_name_from_key( $options );
52
-			$this->options = $options;
53
-
54
-			$this->base_id   = $options['base_id'];
55
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
56
-
57
-			// init parent
58
-			parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
59
-
60
-			if ( isset( $options['class_name'] ) ) {
61
-				// register widget
62
-				$this->class_name = $options['class_name'];
63
-
64
-				// register shortcode
65
-				$this->register_shortcode();
66
-
67
-				// register block
68
-				add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
69
-			}
70
-
71
-			// add the CSS and JS we need ONCE
72
-			global $sd_widget_scripts;
73
-
74
-			if ( ! $sd_widget_scripts ) {
75
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
76
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
77
-				wp_add_inline_style( 'widgets', $this->widget_css() );
78
-
79
-				$sd_widget_scripts = true;
80
-
81
-				// add shortcode insert button once
82
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
83
-				if ( $this->is_preview() ) {
84
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
85
-					// this makes the insert button work for elementor
86
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
87
-						$this,
88
-						'shortcode_insert_button_script'
89
-					) ); // for elementor
90
-				}
91
-				// this makes the insert button work for cornerstone
92
-				add_action( 'cornerstone_load_builder', array(
93
-					$this,
94
-					'shortcode_insert_button_script'
95
-				) ); // for cornerstone builder (this is the preview)
96
-
97
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
98
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
99
-
100
-				// add generator text to admin head
101
-				add_action( 'admin_head', array( $this, 'generator' ) );
102
-			}
103
-
104
-			do_action( 'wp_super_duper_widget_init', $options, $this );
105
-		}
106
-
107
-		/**
108
-		 * A function to ge the shortcode builder picker html.
109
-		 *
110
-		 * @param string $editor_id
111
-		 *
112
-		 * @return string
113
-		 */
114
-		public static function get_picker( $editor_id = '' ) {
115
-
116
-			ob_start();
117
-			if ( isset( $_POST['editor_id'] ) ) {
118
-				$editor_id = esc_attr( $_POST['editor_id'] );
119
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
120
-				$editor_id = 'main_content_content_vb_tiny_mce';
121
-			}
122
-
123
-			global $sd_widgets;
124
-			?>
9
+    /**
10
+     * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
11
+     *
12
+     * Should not be called direct but extended instead.
13
+     *
14
+     * Class WP_Super_Duper
15
+     * @since 1.0.3 is_block_content_call() method added.
16
+     * @since 1.0.3 Placeholder text will be shown for widget that return no block content.
17
+     * @since 1.0.4 is_elementor_widget_output() method added.
18
+     * @since 1.0.4 is_elementor_preview() method added.
19
+     * @since 1.0.5 Block checkbox options are set as true by default even when set as false - FIXED
20
+     * @since 1.0.6 Some refactoring for page builders - CHANGED
21
+     * @since 1.0.7 Some refactoring for page builders - CHANGED
22
+     * @since 1.0.8 Some refactoring for page builders ( cornerstone builder now supported ) - CHANGED
23
+     * @since 1.0.9 Numbers saving as strings and not numbers which can cause block render issues on refresh - FIXED
24
+     * @since 1.0.10 Some refactoring for page builders ( Avia builder for Enfold theme now supported ) - CHANGED
25
+     * @ver 1.0.10
26
+     */
27
+    class WP_Super_Duper extends WP_Widget {
28
+
29
+        public $version = "1.0.10";
30
+        public $block_code;
31
+        public $options;
32
+        public $base_id;
33
+        public $arguments = array();
34
+        public $instance = array();
35
+        private $class_name;
36
+
37
+        /**
38
+         * Take the array options and use them to build.
39
+         */
40
+        public function __construct( $options ) {
41
+            global $sd_widgets;
42
+
43
+            $sd_widgets[ $options['base_id'] ] = array(
44
+                'name'       => $options['name'],
45
+                'class_name' => $options['class_name']
46
+            );
47
+            $this->base_id                     = $options['base_id'];
48
+            // lets filter the options before we do anything
49
+            $options       = apply_filters( "wp_super_duper_options", $options );
50
+            $options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
51
+            $options       = $this->add_name_from_key( $options );
52
+            $this->options = $options;
53
+
54
+            $this->base_id   = $options['base_id'];
55
+            $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
56
+
57
+            // init parent
58
+            parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
59
+
60
+            if ( isset( $options['class_name'] ) ) {
61
+                // register widget
62
+                $this->class_name = $options['class_name'];
63
+
64
+                // register shortcode
65
+                $this->register_shortcode();
66
+
67
+                // register block
68
+                add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
69
+            }
70
+
71
+            // add the CSS and JS we need ONCE
72
+            global $sd_widget_scripts;
73
+
74
+            if ( ! $sd_widget_scripts ) {
75
+                wp_add_inline_script( 'admin-widgets', $this->widget_js() );
76
+                wp_add_inline_script( 'customize-controls', $this->widget_js() );
77
+                wp_add_inline_style( 'widgets', $this->widget_css() );
78
+
79
+                $sd_widget_scripts = true;
80
+
81
+                // add shortcode insert button once
82
+                add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
83
+                if ( $this->is_preview() ) {
84
+                    add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
85
+                    // this makes the insert button work for elementor
86
+                    add_action( 'elementor/editor/after_enqueue_scripts', array(
87
+                        $this,
88
+                        'shortcode_insert_button_script'
89
+                    ) ); // for elementor
90
+                }
91
+                // this makes the insert button work for cornerstone
92
+                add_action( 'cornerstone_load_builder', array(
93
+                    $this,
94
+                    'shortcode_insert_button_script'
95
+                ) ); // for cornerstone builder (this is the preview)
96
+
97
+                add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
98
+                add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
99
+
100
+                // add generator text to admin head
101
+                add_action( 'admin_head', array( $this, 'generator' ) );
102
+            }
103
+
104
+            do_action( 'wp_super_duper_widget_init', $options, $this );
105
+        }
106
+
107
+        /**
108
+         * A function to ge the shortcode builder picker html.
109
+         *
110
+         * @param string $editor_id
111
+         *
112
+         * @return string
113
+         */
114
+        public static function get_picker( $editor_id = '' ) {
115
+
116
+            ob_start();
117
+            if ( isset( $_POST['editor_id'] ) ) {
118
+                $editor_id = esc_attr( $_POST['editor_id'] );
119
+            } elseif ( isset( $_REQUEST['et_fb'] ) ) {
120
+                $editor_id = 'main_content_content_vb_tiny_mce';
121
+            }
122
+
123
+            global $sd_widgets;
124
+            ?>
125 125
 
126 126
 			<div class="sd-shortcode-left-wrap">
127 127
 				<?php
128
-				asort( $sd_widgets );
129
-				if ( ! empty( $sd_widgets ) ) {
130
-					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
131
-					echo "<option>" . __( 'Select shortcode' ) . "</option>";
132
-					foreach ( $sd_widgets as $shortcode => $class ) {
133
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
134
-					}
135
-					echo "</select>";
136
-
137
-				}
138
-				?>
128
+                asort( $sd_widgets );
129
+                if ( ! empty( $sd_widgets ) ) {
130
+                    echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
131
+                    echo "<option>" . __( 'Select shortcode' ) . "</option>";
132
+                    foreach ( $sd_widgets as $shortcode => $class ) {
133
+                        echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
134
+                    }
135
+                    echo "</select>";
136
+
137
+                }
138
+                ?>
139 139
 				<div class="sd-shortcode-settings"></div>
140 140
 
141 141
 			</div>
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 					<?php if ( $editor_id != '' ) { ?>
147 147
 						<button class="button sd-insert-shortcode-button"
148 148
 						        onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
149
-							        echo "'" . $editor_id . "'";
150
-						        } ?>)"><?php _e( 'Insert shortcode' ); ?></button>
149
+                                    echo "'" . $editor_id . "'";
150
+                                } ?>)"><?php _e( 'Insert shortcode' ); ?></button>
151 151
 					<?php } ?>
152 152
 					<button class="button"
153 153
 					        onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
@@ -155,129 +155,129 @@  discard block
 block discarded – undo
155 155
 			</div>
156 156
 			<?php
157 157
 
158
-			$html = ob_get_clean();
159
-
160
-			if ( wp_doing_ajax() ) {
161
-				echo $html;
162
-				$should_die = true;
163
-
164
-				// some builder get the editor via ajax so we should not die on those ocasions
165
-				$dont_die = array(
166
-					'parent_tag',// WP Bakery
167
-					'avia_request' // enfold
168
-				);
169
-
170
-				foreach ( $dont_die as $request ) {
171
-					if ( isset( $_REQUEST[ $request ] ) ) {
172
-						$should_die = false;
173
-					}
174
-				}
175
-
176
-				if ( $should_die ) {
177
-					wp_die();
178
-				}
179
-
180
-			} else {
181
-				return $html;
182
-			}
183
-
184
-			return '';
185
-
186
-		}
187
-
188
-		/**
189
-		 * Output the version in the admin header.
190
-		 */
191
-		public function generator() {
192
-			echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />';
193
-		}
194
-
195
-		/**
196
-		 * Get widget settings.
197
-		 *
198
-		 * @since 1.0.0
199
-		 */
200
-		public static function get_widget_settings() {
201
-			global $sd_widgets;
202
-
203
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
204
-			if ( ! $shortcode ) {
205
-				wp_die();
206
-			}
207
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
208
-			if ( ! $widget_args ) {
209
-				wp_die();
210
-			}
211
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
212
-			if ( ! $class_name ) {
213
-				wp_die();
214
-			}
215
-
216
-			// invoke an instance method
217
-			$widget = new $class_name;
218
-
219
-			ob_start();
220
-			$widget->form( array() );
221
-			$form = ob_get_clean();
222
-			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
223
-			echo "<style>" . $widget->widget_css() . "</style>";
224
-			echo "<script>" . $widget->widget_js() . "</script>";
225
-			?>
158
+            $html = ob_get_clean();
159
+
160
+            if ( wp_doing_ajax() ) {
161
+                echo $html;
162
+                $should_die = true;
163
+
164
+                // some builder get the editor via ajax so we should not die on those ocasions
165
+                $dont_die = array(
166
+                    'parent_tag',// WP Bakery
167
+                    'avia_request' // enfold
168
+                );
169
+
170
+                foreach ( $dont_die as $request ) {
171
+                    if ( isset( $_REQUEST[ $request ] ) ) {
172
+                        $should_die = false;
173
+                    }
174
+                }
175
+
176
+                if ( $should_die ) {
177
+                    wp_die();
178
+                }
179
+
180
+            } else {
181
+                return $html;
182
+            }
183
+
184
+            return '';
185
+
186
+        }
187
+
188
+        /**
189
+         * Output the version in the admin header.
190
+         */
191
+        public function generator() {
192
+            echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />';
193
+        }
194
+
195
+        /**
196
+         * Get widget settings.
197
+         *
198
+         * @since 1.0.0
199
+         */
200
+        public static function get_widget_settings() {
201
+            global $sd_widgets;
202
+
203
+            $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
204
+            if ( ! $shortcode ) {
205
+                wp_die();
206
+            }
207
+            $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
208
+            if ( ! $widget_args ) {
209
+                wp_die();
210
+            }
211
+            $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
212
+            if ( ! $class_name ) {
213
+                wp_die();
214
+            }
215
+
216
+            // invoke an instance method
217
+            $widget = new $class_name;
218
+
219
+            ob_start();
220
+            $widget->form( array() );
221
+            $form = ob_get_clean();
222
+            echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
223
+            echo "<style>" . $widget->widget_css() . "</style>";
224
+            echo "<script>" . $widget->widget_js() . "</script>";
225
+            ?>
226 226
 			<?php
227
-			wp_die();
228
-		}
229
-
230
-		/**
231
-		 * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
232
-		 *
233
-		 * @since 1.0.0
234
-		 *
235
-		 * @param string $editor_id Optional. Shortcode editor id. Default null.
236
-		 * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
237
-		 */
238
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
239
-			global $sd_widgets, $shortcode_insert_button_once;
240
-			if ( $shortcode_insert_button_once ) {
241
-				return;
242
-			}
243
-			add_thickbox();
244
-
245
-
246
-			/**
247
-			 * Cornerstone makes us play dirty tricks :/
248
-			 * 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.
249
-			 */
250
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
251
-				echo '<span id="insert-media-button">';
252
-			}
253
-
254
-			echo self::shortcode_button( 'this', 'true' );
255
-
256
-			// see opening note
257
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
258
-				echo '</span>'; // end #insert-media-button
259
-			}
260
-
261
-			self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
262
-			$shortcode_insert_button_once = true;
263
-		}
264
-
265
-		/**
266
-		 * Gets the shortcode insert button html.
267
-		 *
268
-		 * @param string $id
269
-		 * @param string $search_for_id
270
-		 *
271
-		 * @return mixed
272
-		 */
273
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
274
-			ob_start();
275
-			?>
227
+            wp_die();
228
+        }
229
+
230
+        /**
231
+         * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
232
+         *
233
+         * @since 1.0.0
234
+         *
235
+         * @param string $editor_id Optional. Shortcode editor id. Default null.
236
+         * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
237
+         */
238
+        public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
239
+            global $sd_widgets, $shortcode_insert_button_once;
240
+            if ( $shortcode_insert_button_once ) {
241
+                return;
242
+            }
243
+            add_thickbox();
244
+
245
+
246
+            /**
247
+             * Cornerstone makes us play dirty tricks :/
248
+             * 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.
249
+             */
250
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
251
+                echo '<span id="insert-media-button">';
252
+            }
253
+
254
+            echo self::shortcode_button( 'this', 'true' );
255
+
256
+            // see opening note
257
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
258
+                echo '</span>'; // end #insert-media-button
259
+            }
260
+
261
+            self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
262
+            $shortcode_insert_button_once = true;
263
+        }
264
+
265
+        /**
266
+         * Gets the shortcode insert button html.
267
+         *
268
+         * @param string $id
269
+         * @param string $search_for_id
270
+         *
271
+         * @return mixed
272
+         */
273
+        public static function shortcode_button( $id = '', $search_for_id = '' ) {
274
+            ob_start();
275
+            ?>
276 276
 			<span class="sd-lable-shortcode-inserter">
277 277
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
278
-				if ( $search_for_id ) {
279
-					echo "," . $search_for_id;
280
-				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
278
+                if ( $search_for_id ) {
279
+                    echo "," . $search_for_id;
280
+                } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
281 281
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
282 282
 					<span style="vertical-align: middle;line-height: 18px;font-size: 20px;"
283 283
 					      class="dashicons dashicons-screenoptions"></span>
@@ -288,21 +288,21 @@  discard block
 block discarded – undo
288 288
 			</span>
289 289
 
290 290
 			<?php
291
-			$html = ob_get_clean();
292
-
293
-			// remove line breaks so we can use it in js
294
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
295
-		}
296
-
297
-		/**
298
-		 * Makes SD work with the siteOrigin page builder.
299
-		 *
300
-		 * @since 1.0.6
301
-		 * @return mixed
302
-		 */
303
-		public static function siteorigin_js() {
304
-			ob_start();
305
-			?>
291
+            $html = ob_get_clean();
292
+
293
+            // remove line breaks so we can use it in js
294
+            return preg_replace( "/\r|\n/", "", trim( $html ) );
295
+        }
296
+
297
+        /**
298
+         * Makes SD work with the siteOrigin page builder.
299
+         *
300
+         * @since 1.0.6
301
+         * @return mixed
302
+         */
303
+        public static function siteorigin_js() {
304
+            ob_start();
305
+            ?>
306 306
 			<script>
307 307
 				/**
308 308
 				 * Check a form to see what items shoudl be shown or hidden.
@@ -380,28 +380,28 @@  discard block
 block discarded – undo
380 380
 				});
381 381
 			</script>
382 382
 			<?php
383
-			$output = ob_get_clean();
383
+            $output = ob_get_clean();
384 384
 
385
-			/*
385
+            /*
386 386
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
387 387
 			 */
388 388
 
389
-			return str_replace( array(
390
-				'<script>',
391
-				'</script>'
392
-			), '', $output );
393
-		}
394
-
395
-		/**
396
-		 * Output the JS and CSS for the shortcode insert button.
397
-		 *
398
-		 * @since 1.0.6
399
-		 *
400
-		 * @param string $editor_id
401
-		 * @param string $insert_shortcode_function
402
-		 */
403
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
404
-			?>
389
+            return str_replace( array(
390
+                '<script>',
391
+                '</script>'
392
+            ), '', $output );
393
+        }
394
+
395
+        /**
396
+         * Output the JS and CSS for the shortcode insert button.
397
+         *
398
+         * @since 1.0.6
399
+         *
400
+         * @param string $editor_id
401
+         * @param string $insert_shortcode_function
402
+         */
403
+        public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
404
+            ?>
405 405
 			<style>
406 406
 				.sd-shortcode-left-wrap {
407 407
 					float: left;
@@ -520,22 +520,22 @@  discard block
 block discarded – undo
520 520
 				}
521 521
 			</style>
522 522
 			<?php
523
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
524
-				echo "<script>" . self::siteorigin_js() . "</script>";
525
-			}
526
-			?>
523
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
524
+                echo "<script>" . self::siteorigin_js() . "</script>";
525
+            }
526
+            ?>
527 527
 			<script>
528 528
 				<?php
529
-				if(! empty( $insert_shortcode_function )){
530
-					echo $insert_shortcode_function;
531
-				}else{
532
-
533
-				/**
534
-				 * Function for super duper insert shortcode.
535
-				 *
536
-				 * @since 1.0.0
537
-				 */
538
-				?>
529
+                if(! empty( $insert_shortcode_function )){
530
+                    echo $insert_shortcode_function;
531
+                }else{
532
+
533
+                /**
534
+                 * Function for super duper insert shortcode.
535
+                 *
536
+                 * @since 1.0.0
537
+                 */
538
+                ?>
539 539
 				function sd_insert_shortcode($editor_id) {
540 540
 					$shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val();
541 541
 					if ($shortcode) {
@@ -543,14 +543,14 @@  discard block
 block discarded – undo
543 543
 						if (!$editor_id) {
544 544
 
545 545
 							<?php
546
-							if ( isset( $_REQUEST['et_fb'] ) ) {
547
-								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
548
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
549
-								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
550
-							} else {
551
-								echo '$editor_id = "#wp-content-editor-container textarea";';
552
-							}
553
-							?>
546
+                            if ( isset( $_REQUEST['et_fb'] ) ) {
547
+                                echo '$editor_id = "#main_content_content_vb_tiny_mce";';
548
+                            } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
549
+                                echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
550
+                            } else {
551
+                                echo '$editor_id = "#wp-content-editor-container textarea";';
552
+                            }
553
+                            ?>
554 554
 						} else {
555 555
 							$editor_id = '#' + $editor_id;
556 556
 						}
@@ -852,16 +852,16 @@  discard block
 block discarded – undo
852 852
 			</script>
853 853
 
854 854
 			<?php
855
-		}
856
-
857
-		/**
858
-		 * Gets some CSS for the widgets screen.
859
-		 *
860
-		 * @return mixed
861
-		 */
862
-		public function widget_css() {
863
-			ob_start();
864
-			?>
855
+        }
856
+
857
+        /**
858
+         * Gets some CSS for the widgets screen.
859
+         *
860
+         * @return mixed
861
+         */
862
+        public function widget_css() {
863
+            ob_start();
864
+            ?>
865 865
 			<style>
866 866
 				.sd-advanced-setting {
867 867
 					display: none;
@@ -882,26 +882,26 @@  discard block
 block discarded – undo
882 882
 				}
883 883
 			</style>
884 884
 			<?php
885
-			$output = ob_get_clean();
885
+            $output = ob_get_clean();
886 886
 
887
-			/*
887
+            /*
888 888
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
889 889
 			 */
890 890
 
891
-			return str_replace( array(
892
-				'<style>',
893
-				'</style>'
894
-			), '', $output );
895
-		}
896
-
897
-		/**
898
-		 * Gets some JS for the widgets screen.
899
-		 *
900
-		 * @return mixed
901
-		 */
902
-		public function widget_js() {
903
-			ob_start();
904
-			?>
891
+            return str_replace( array(
892
+                '<style>',
893
+                '</style>'
894
+            ), '', $output );
895
+        }
896
+
897
+        /**
898
+         * Gets some JS for the widgets screen.
899
+         *
900
+         * @return mixed
901
+         */
902
+        public function widget_js() {
903
+            ob_start();
904
+            ?>
905 905
 			<script>
906 906
 
907 907
 				/**
@@ -1056,302 +1056,302 @@  discard block
 block discarded – undo
1056 1056
 				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1057 1057
 			</script>
1058 1058
 			<?php
1059
-			$output = ob_get_clean();
1059
+            $output = ob_get_clean();
1060 1060
 
1061
-			/*
1061
+            /*
1062 1062
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1063 1063
 			 */
1064 1064
 
1065
-			return str_replace( array(
1066
-				'<script>',
1067
-				'</script>'
1068
-			), '', $output );
1069
-		}
1070
-
1071
-
1072
-		/**
1073
-		 * Set the name from the argument key.
1074
-		 *
1075
-		 * @param $options
1076
-		 *
1077
-		 * @return mixed
1078
-		 */
1079
-		private function add_name_from_key( $options, $arguments = false ) {
1080
-			if ( ! empty( $options['arguments'] ) ) {
1081
-				foreach ( $options['arguments'] as $key => $val ) {
1082
-					$options['arguments'][ $key ]['name'] = $key;
1083
-				}
1084
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1085
-				foreach ( $options as $key => $val ) {
1086
-					$options[ $key ]['name'] = $key;
1087
-				}
1088
-			}
1089
-
1090
-			return $options;
1091
-		}
1092
-
1093
-		/**
1094
-		 * Register the parent shortcode.
1095
-		 *
1096
-		 * @since 1.0.0
1097
-		 */
1098
-		public function register_shortcode() {
1099
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1100
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
1101
-		}
1102
-
1103
-		/**
1104
-		 * Render the shortcode via ajax so we can return it to Gutenberg.
1105
-		 *
1106
-		 * @since 1.0.0
1107
-		 */
1108
-		public static function render_shortcode() {
1109
-
1110
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1111
-			if ( ! current_user_can( 'manage_options' ) ) {
1112
-				wp_die();
1113
-			}
1114
-
1115
-			// we might need the $post value here so lets set it.
1116
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1117
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1118
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1119
-					global $post;
1120
-					$post = $post_obj;
1121
-				}
1122
-			}
1123
-
1124
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1125
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1126
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1127
-				$attributes       = '';
1128
-				if ( ! empty( $attributes_array ) ) {
1129
-					foreach ( $attributes_array as $key => $value ) {
1130
-						$attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
1131
-					}
1132
-				}
1133
-
1134
-				$shortcode = "[" . $shortcode_name . " " . $attributes . "]";
1135
-
1136
-				echo do_shortcode( $shortcode );
1137
-
1138
-			}
1139
-			wp_die();
1140
-		}
1141
-
1142
-		/**
1143
-		 * Output the shortcode.
1144
-		 *
1145
-		 * @param array $args
1146
-		 * @param string $content
1147
-		 *
1148
-		 * @return string
1149
-		 */
1150
-		public function shortcode_output( $args = array(), $content = '' ) {
1151
-			$args = self::argument_values( $args );
1152
-
1153
-			// add extra argument so we know its a output to gutenberg
1154
-			//$args
1155
-			$args = $this->string_to_bool( $args );
1156
-
1157
-
1158
-			$calss = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1159
-
1160
-			$calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this );
1161
-			$calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this );
1162
-
1163
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1164
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1165
-
1166
-			$shortcode_args = array();
1167
-			$output         = '';
1168
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1169
-			$main_content   = $this->output( $args, $shortcode_args, $content );
1170
-			if ( $main_content && ! $no_wrap ) {
1171
-				// wrap the shortcode in a dive with the same class as the widget
1172
-				$output .= '<div class="' . $calss . '" ' . $attrs . '>';
1173
-				if ( ! empty( $args['title'] ) ) {
1174
-					// if its a shortcode and there is a title try to grab the title wrappers
1175
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1176
-					if ( empty( $instance ) ) {
1177
-						global $wp_registered_sidebars;
1178
-						if ( ! empty( $wp_registered_sidebars ) ) {
1179
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1180
-								if ( ! empty( $sidebar['before_title'] ) ) {
1181
-									$shortcode_args['before_title'] = $sidebar['before_title'];
1182
-									$shortcode_args['after_title']  = $sidebar['after_title'];
1183
-									break;
1184
-								}
1185
-							}
1186
-						}
1187
-					}
1188
-					$output .= $this->output_title( $shortcode_args, $args );
1189
-				}
1190
-				$output .= $main_content;
1191
-				$output .= '</div>';
1192
-			} elseif ( $main_content && $no_wrap ) {
1193
-				$output .= $main_content;
1194
-			}
1195
-
1196
-			// if preview show a placeholder if empty
1197
-			if ( $this->is_preview() && $output == '' ) {
1198
-				$output = $this->preview_placeholder_text( "[{" . $this->base_id . "}]" );
1199
-			}
1200
-
1201
-			return $output;
1202
-		}
1203
-
1204
-		/**
1205
-		 * Placeholder text to show if output is empty and we are on a preview/builder page.
1206
-		 *
1207
-		 * @param string $name
1208
-		 *
1209
-		 * @return string
1210
-		 */
1211
-		public function preview_placeholder_text( $name = '' ) {
1212
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>";
1213
-		}
1214
-
1215
-		/**
1216
-		 * Sometimes booleans values can be turned to strings, so we fix that.
1217
-		 *
1218
-		 * @param $options
1219
-		 *
1220
-		 * @return mixed
1221
-		 */
1222
-		public function string_to_bool( $options ) {
1223
-			// convert bool strings to booleans
1224
-			foreach ( $options as $key => $val ) {
1225
-				if ( $val == 'false' ) {
1226
-					$options[ $key ] = false;
1227
-				} elseif ( $val == 'true' ) {
1228
-					$options[ $key ] = true;
1229
-				}
1230
-			}
1231
-
1232
-			return $options;
1233
-		}
1234
-
1235
-		/**
1236
-		 * Get the argument values that are also filterable.
1237
-		 *
1238
-		 * @param $instance
1239
-		 *
1240
-		 * @return array
1241
-		 */
1242
-		public function argument_values( $instance ) {
1243
-			$argument_values = array();
1244
-
1245
-			// set widget instance
1246
-			$this->instance = $instance;
1247
-
1248
-			if ( empty( $this->arguments ) ) {
1249
-				$this->arguments = $this->get_arguments();
1250
-			}
1251
-
1252
-			if ( ! empty( $this->arguments ) ) {
1253
-				foreach ( $this->arguments as $key => $args ) {
1254
-					// set the input name from the key
1255
-					$args['name'] = $key;
1256
-					//
1257
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1258
-					if ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1259
-						$argument_values[ $key ] = $args['default'];
1260
-					}
1261
-				}
1262
-			}
1263
-
1264
-			return $argument_values;
1265
-		}
1266
-
1267
-		/**
1268
-		 * Set arguments in super duper.
1269
-		 *
1270
-		 * @since 1.0.0
1271
-		 *
1272
-		 * @return array Set arguments.
1273
-		 */
1274
-		public function set_arguments() {
1275
-			return $this->arguments;
1276
-		}
1277
-
1278
-		/**
1279
-		 * Get arguments in super duper.
1280
-		 *
1281
-		 * @since 1.0.0
1282
-		 *
1283
-		 * @return array Get arguments.
1284
-		 */
1285
-		public function get_arguments() {
1286
-			if ( empty( $this->arguments ) ) {
1287
-				$this->arguments = $this->set_arguments();
1288
-			}
1289
-
1290
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1291
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1292
-
1293
-			return $this->arguments;
1294
-		}
1295
-
1296
-		/**
1297
-		 * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1298
-		 *
1299
-		 * @param array $args
1300
-		 * @param array $widget_args
1301
-		 * @param string $content
1302
-		 */
1303
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1304
-
1305
-		}
1306
-
1307
-		/**
1308
-		 * Add the dynamic block code inline when the wp-block in enqueued.
1309
-		 */
1310
-		public function register_block() {
1311
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1312
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1313
-
1314
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1315
-
1316
-			}
1317
-		}
1318
-
1319
-		/**
1320
-		 * Check if we need to show advanced options.
1321
-		 *
1322
-		 * @return bool
1323
-		 */
1324
-		public function block_show_advanced() {
1325
-
1326
-			$show      = false;
1327
-			$arguments = $this->arguments;
1328
-
1329
-			if ( empty( $arguments ) ) {
1330
-				$arguments = $this->get_arguments();
1331
-			}
1332
-
1333
-			if ( ! empty( $arguments ) ) {
1334
-				foreach ( $arguments as $argument ) {
1335
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1336
-						$show = true;
1337
-					}
1338
-				}
1339
-			}
1340
-
1341
-			return $show;
1342
-		}
1343
-
1344
-
1345
-		/**
1346
-		 * Output the JS for building the dynamic Guntenberg block.
1347
-		 *
1348
-		 * @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.
1349
-		 * @since 1.0.9 Save numbers as numbers and not strings.
1350
-		 * @return mixed
1351
-		 */
1352
-		public function block() {
1353
-			ob_start();
1354
-			?>
1065
+            return str_replace( array(
1066
+                '<script>',
1067
+                '</script>'
1068
+            ), '', $output );
1069
+        }
1070
+
1071
+
1072
+        /**
1073
+         * Set the name from the argument key.
1074
+         *
1075
+         * @param $options
1076
+         *
1077
+         * @return mixed
1078
+         */
1079
+        private function add_name_from_key( $options, $arguments = false ) {
1080
+            if ( ! empty( $options['arguments'] ) ) {
1081
+                foreach ( $options['arguments'] as $key => $val ) {
1082
+                    $options['arguments'][ $key ]['name'] = $key;
1083
+                }
1084
+            } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1085
+                foreach ( $options as $key => $val ) {
1086
+                    $options[ $key ]['name'] = $key;
1087
+                }
1088
+            }
1089
+
1090
+            return $options;
1091
+        }
1092
+
1093
+        /**
1094
+         * Register the parent shortcode.
1095
+         *
1096
+         * @since 1.0.0
1097
+         */
1098
+        public function register_shortcode() {
1099
+            add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1100
+            add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
1101
+        }
1102
+
1103
+        /**
1104
+         * Render the shortcode via ajax so we can return it to Gutenberg.
1105
+         *
1106
+         * @since 1.0.0
1107
+         */
1108
+        public static function render_shortcode() {
1109
+
1110
+            check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1111
+            if ( ! current_user_can( 'manage_options' ) ) {
1112
+                wp_die();
1113
+            }
1114
+
1115
+            // we might need the $post value here so lets set it.
1116
+            if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1117
+                $post_obj = get_post( absint( $_POST['post_id'] ) );
1118
+                if ( ! empty( $post_obj ) && empty( $post ) ) {
1119
+                    global $post;
1120
+                    $post = $post_obj;
1121
+                }
1122
+            }
1123
+
1124
+            if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1125
+                $shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1126
+                $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1127
+                $attributes       = '';
1128
+                if ( ! empty( $attributes_array ) ) {
1129
+                    foreach ( $attributes_array as $key => $value ) {
1130
+                        $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
1131
+                    }
1132
+                }
1133
+
1134
+                $shortcode = "[" . $shortcode_name . " " . $attributes . "]";
1135
+
1136
+                echo do_shortcode( $shortcode );
1137
+
1138
+            }
1139
+            wp_die();
1140
+        }
1141
+
1142
+        /**
1143
+         * Output the shortcode.
1144
+         *
1145
+         * @param array $args
1146
+         * @param string $content
1147
+         *
1148
+         * @return string
1149
+         */
1150
+        public function shortcode_output( $args = array(), $content = '' ) {
1151
+            $args = self::argument_values( $args );
1152
+
1153
+            // add extra argument so we know its a output to gutenberg
1154
+            //$args
1155
+            $args = $this->string_to_bool( $args );
1156
+
1157
+
1158
+            $calss = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1159
+
1160
+            $calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this );
1161
+            $calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this );
1162
+
1163
+            $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1164
+            $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1165
+
1166
+            $shortcode_args = array();
1167
+            $output         = '';
1168
+            $no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1169
+            $main_content   = $this->output( $args, $shortcode_args, $content );
1170
+            if ( $main_content && ! $no_wrap ) {
1171
+                // wrap the shortcode in a dive with the same class as the widget
1172
+                $output .= '<div class="' . $calss . '" ' . $attrs . '>';
1173
+                if ( ! empty( $args['title'] ) ) {
1174
+                    // if its a shortcode and there is a title try to grab the title wrappers
1175
+                    $shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1176
+                    if ( empty( $instance ) ) {
1177
+                        global $wp_registered_sidebars;
1178
+                        if ( ! empty( $wp_registered_sidebars ) ) {
1179
+                            foreach ( $wp_registered_sidebars as $sidebar ) {
1180
+                                if ( ! empty( $sidebar['before_title'] ) ) {
1181
+                                    $shortcode_args['before_title'] = $sidebar['before_title'];
1182
+                                    $shortcode_args['after_title']  = $sidebar['after_title'];
1183
+                                    break;
1184
+                                }
1185
+                            }
1186
+                        }
1187
+                    }
1188
+                    $output .= $this->output_title( $shortcode_args, $args );
1189
+                }
1190
+                $output .= $main_content;
1191
+                $output .= '</div>';
1192
+            } elseif ( $main_content && $no_wrap ) {
1193
+                $output .= $main_content;
1194
+            }
1195
+
1196
+            // if preview show a placeholder if empty
1197
+            if ( $this->is_preview() && $output == '' ) {
1198
+                $output = $this->preview_placeholder_text( "[{" . $this->base_id . "}]" );
1199
+            }
1200
+
1201
+            return $output;
1202
+        }
1203
+
1204
+        /**
1205
+         * Placeholder text to show if output is empty and we are on a preview/builder page.
1206
+         *
1207
+         * @param string $name
1208
+         *
1209
+         * @return string
1210
+         */
1211
+        public function preview_placeholder_text( $name = '' ) {
1212
+            return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>";
1213
+        }
1214
+
1215
+        /**
1216
+         * Sometimes booleans values can be turned to strings, so we fix that.
1217
+         *
1218
+         * @param $options
1219
+         *
1220
+         * @return mixed
1221
+         */
1222
+        public function string_to_bool( $options ) {
1223
+            // convert bool strings to booleans
1224
+            foreach ( $options as $key => $val ) {
1225
+                if ( $val == 'false' ) {
1226
+                    $options[ $key ] = false;
1227
+                } elseif ( $val == 'true' ) {
1228
+                    $options[ $key ] = true;
1229
+                }
1230
+            }
1231
+
1232
+            return $options;
1233
+        }
1234
+
1235
+        /**
1236
+         * Get the argument values that are also filterable.
1237
+         *
1238
+         * @param $instance
1239
+         *
1240
+         * @return array
1241
+         */
1242
+        public function argument_values( $instance ) {
1243
+            $argument_values = array();
1244
+
1245
+            // set widget instance
1246
+            $this->instance = $instance;
1247
+
1248
+            if ( empty( $this->arguments ) ) {
1249
+                $this->arguments = $this->get_arguments();
1250
+            }
1251
+
1252
+            if ( ! empty( $this->arguments ) ) {
1253
+                foreach ( $this->arguments as $key => $args ) {
1254
+                    // set the input name from the key
1255
+                    $args['name'] = $key;
1256
+                    //
1257
+                    $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1258
+                    if ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1259
+                        $argument_values[ $key ] = $args['default'];
1260
+                    }
1261
+                }
1262
+            }
1263
+
1264
+            return $argument_values;
1265
+        }
1266
+
1267
+        /**
1268
+         * Set arguments in super duper.
1269
+         *
1270
+         * @since 1.0.0
1271
+         *
1272
+         * @return array Set arguments.
1273
+         */
1274
+        public function set_arguments() {
1275
+            return $this->arguments;
1276
+        }
1277
+
1278
+        /**
1279
+         * Get arguments in super duper.
1280
+         *
1281
+         * @since 1.0.0
1282
+         *
1283
+         * @return array Get arguments.
1284
+         */
1285
+        public function get_arguments() {
1286
+            if ( empty( $this->arguments ) ) {
1287
+                $this->arguments = $this->set_arguments();
1288
+            }
1289
+
1290
+            $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1291
+            $this->arguments = $this->add_name_from_key( $this->arguments, true );
1292
+
1293
+            return $this->arguments;
1294
+        }
1295
+
1296
+        /**
1297
+         * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1298
+         *
1299
+         * @param array $args
1300
+         * @param array $widget_args
1301
+         * @param string $content
1302
+         */
1303
+        public function output( $args = array(), $widget_args = array(), $content = '' ) {
1304
+
1305
+        }
1306
+
1307
+        /**
1308
+         * Add the dynamic block code inline when the wp-block in enqueued.
1309
+         */
1310
+        public function register_block() {
1311
+            wp_add_inline_script( 'wp-blocks', $this->block() );
1312
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
1313
+
1314
+                wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1315
+
1316
+            }
1317
+        }
1318
+
1319
+        /**
1320
+         * Check if we need to show advanced options.
1321
+         *
1322
+         * @return bool
1323
+         */
1324
+        public function block_show_advanced() {
1325
+
1326
+            $show      = false;
1327
+            $arguments = $this->arguments;
1328
+
1329
+            if ( empty( $arguments ) ) {
1330
+                $arguments = $this->get_arguments();
1331
+            }
1332
+
1333
+            if ( ! empty( $arguments ) ) {
1334
+                foreach ( $arguments as $argument ) {
1335
+                    if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1336
+                        $show = true;
1337
+                    }
1338
+                }
1339
+            }
1340
+
1341
+            return $show;
1342
+        }
1343
+
1344
+
1345
+        /**
1346
+         * Output the JS for building the dynamic Guntenberg block.
1347
+         *
1348
+         * @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.
1349
+         * @since 1.0.9 Save numbers as numbers and not strings.
1350
+         * @return mixed
1351
+         */
1352
+        public function block() {
1353
+            ob_start();
1354
+            ?>
1355 1355
 			<script>
1356 1356
 				/**
1357 1357
 				 * BLOCK: Basic
@@ -1390,76 +1390,76 @@  discard block
 block discarded – undo
1390 1390
 						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/.
1391 1391
 						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.
1392 1392
 						<?php if ( isset( $this->options['block-keywords'] ) ) {
1393
-						echo "keywords : " . $this->options['block-keywords'] . ",";
1394
-					}?>
1393
+                        echo "keywords : " . $this->options['block-keywords'] . ",";
1394
+                    }?>
1395 1395
 
1396 1396
 						<?php
1397 1397
 
1398
-						$show_advanced = $this->block_show_advanced();
1399
-
1400
-						$show_alignment = false;
1401
-
1402
-						if ( ! empty( $this->arguments ) ) {
1403
-							echo "attributes : {";
1404
-
1405
-							if ( $show_advanced ) {
1406
-								echo "show_advanced: {";
1407
-								echo "	type: 'boolean',";
1408
-								echo "  default: false,";
1409
-								echo "},";
1410
-							}
1411
-
1412
-							// block wrap element
1413
-							if ( isset( $this->options['block-wrap'] ) ) { //@todo we should validate this?
1414
-								echo "block_wrap: {";
1415
-								echo "	type: 'string',";
1416
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
1417
-								echo "},";
1418
-							}
1419
-
1420
-
1421
-							foreach ( $this->arguments as $key => $args ) {
1422
-
1423
-								// set if we should show alignment
1424
-								if ( $key == 'alignment' ) {
1425
-									$show_alignment = true;
1426
-								}
1427
-
1428
-								$extra = '';
1429
-
1430
-								if ( $args['type'] == 'checkbox' ) {
1431
-									$type    = 'boolean';
1432
-									$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
1433
-								} elseif ( $args['type'] == 'number' ) {
1434
-									$type    = 'number';
1435
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1436
-								} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
1437
-									$type = 'array';
1438
-									if ( is_array( $args['default'] ) ) {
1439
-										$default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
1440
-									} else {
1441
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1442
-									}
1443
-								} elseif ( $args['type'] == 'multiselect' ) {
1444
-									$type    = 'array';
1445
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1446
-								} else {
1447
-									$type    = 'string';
1448
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1449
-								}
1450
-								echo $key . " : {";
1451
-								echo "type : '$type',";
1452
-								echo "default : $default,";
1453
-								echo "},";
1454
-							}
1455
-
1456
-							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
1457
-
1458
-							echo "},";
1459
-
1460
-						}
1461
-
1462
-						?>
1398
+                        $show_advanced = $this->block_show_advanced();
1399
+
1400
+                        $show_alignment = false;
1401
+
1402
+                        if ( ! empty( $this->arguments ) ) {
1403
+                            echo "attributes : {";
1404
+
1405
+                            if ( $show_advanced ) {
1406
+                                echo "show_advanced: {";
1407
+                                echo "	type: 'boolean',";
1408
+                                echo "  default: false,";
1409
+                                echo "},";
1410
+                            }
1411
+
1412
+                            // block wrap element
1413
+                            if ( isset( $this->options['block-wrap'] ) ) { //@todo we should validate this?
1414
+                                echo "block_wrap: {";
1415
+                                echo "	type: 'string',";
1416
+                                echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
1417
+                                echo "},";
1418
+                            }
1419
+
1420
+
1421
+                            foreach ( $this->arguments as $key => $args ) {
1422
+
1423
+                                // set if we should show alignment
1424
+                                if ( $key == 'alignment' ) {
1425
+                                    $show_alignment = true;
1426
+                                }
1427
+
1428
+                                $extra = '';
1429
+
1430
+                                if ( $args['type'] == 'checkbox' ) {
1431
+                                    $type    = 'boolean';
1432
+                                    $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
1433
+                                } elseif ( $args['type'] == 'number' ) {
1434
+                                    $type    = 'number';
1435
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1436
+                                } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
1437
+                                    $type = 'array';
1438
+                                    if ( is_array( $args['default'] ) ) {
1439
+                                        $default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
1440
+                                    } else {
1441
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1442
+                                    }
1443
+                                } elseif ( $args['type'] == 'multiselect' ) {
1444
+                                    $type    = 'array';
1445
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1446
+                                } else {
1447
+                                    $type    = 'string';
1448
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1449
+                                }
1450
+                                echo $key . " : {";
1451
+                                echo "type : '$type',";
1452
+                                echo "default : $default,";
1453
+                                echo "},";
1454
+                            }
1455
+
1456
+                            echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
1457
+
1458
+                            echo "},";
1459
+
1460
+                        }
1461
+
1462
+                        ?>
1463 1463
 
1464 1464
 						// The "edit" property must be a valid function.
1465 1465
 						edit: function (props) {
@@ -1478,8 +1478,8 @@  discard block
 block discarded – undo
1478 1478
 										'shortcode': '<?php echo $this->options['base_id'];?>',
1479 1479
 										'attributes': props.attributes,
1480 1480
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
1481
-										echo $post->ID;
1482
-									}?>,
1481
+                                        echo $post->ID;
1482
+                                    }?>,
1483 1483
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
1484 1484
 									};
1485 1485
 
@@ -1526,10 +1526,10 @@  discard block
 block discarded – undo
1526 1526
 
1527 1527
 									<?php
1528 1528
 
1529
-									if(! empty( $this->arguments )){
1529
+                                    if(! empty( $this->arguments )){
1530 1530
 
1531
-									if ( $show_advanced ) {
1532
-									?>
1531
+                                    if ( $show_advanced ) {
1532
+                                    ?>
1533 1533
 									el(
1534 1534
 										wp.components.ToggleControl,
1535 1535
 										{
@@ -1542,73 +1542,73 @@  discard block
 block discarded – undo
1542 1542
 									),
1543 1543
 									<?php
1544 1544
 
1545
-									}
1546
-
1547
-									foreach($this->arguments as $key => $args){
1548
-									$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
1549
-									$options = '';
1550
-									$extra = '';
1551
-									$require = '';
1552
-									$onchange = "props.setAttributes({ $key: $key } )";
1553
-									$value = "props.attributes.$key";
1554
-									$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' );
1555
-									if ( in_array( $args['type'], $text_type ) ) {
1556
-										$type = 'TextControl';
1557
-										// Save numbers as numbers and not strings
1558
-										if ( $args['type'] == 'number' ) {
1559
-											$onchange = "props.setAttributes({ $key: Number($key) } )";
1560
-										}
1561
-									}
1545
+                                    }
1546
+
1547
+                                    foreach($this->arguments as $key => $args){
1548
+                                    $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
1549
+                                    $options = '';
1550
+                                    $extra = '';
1551
+                                    $require = '';
1552
+                                    $onchange = "props.setAttributes({ $key: $key } )";
1553
+                                    $value = "props.attributes.$key";
1554
+                                    $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' );
1555
+                                    if ( in_array( $args['type'], $text_type ) ) {
1556
+                                        $type = 'TextControl';
1557
+                                        // Save numbers as numbers and not strings
1558
+                                        if ( $args['type'] == 'number' ) {
1559
+                                            $onchange = "props.setAttributes({ $key: Number($key) } )";
1560
+                                        }
1561
+                                    }
1562 1562
 //									elseif ( $args['type'] == 'color' ) { //@todo ColorPicker labels are not shown yet, we may have to add our own https://github.com/WordPress/gutenberg/issues/14378
1563 1563
 //										$type = 'ColorPicker';
1564 1564
 //									}
1565
-									elseif ( $args['type'] == 'checkbox' ) {
1566
-										$type = 'CheckboxControl';
1567
-										$extra .= "checked: props.attributes.$key,";
1568
-										$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
1569
-									} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
1570
-										$type = 'SelectControl';
1571
-										if ( ! empty( $args['options'] ) ) {
1572
-											$options .= "options  : [";
1573
-											foreach ( $args['options'] as $option_val => $option_label ) {
1574
-												$options .= "{ value : '" . esc_attr( $option_val ) . "',     label : '" . esc_attr( $option_label ) . "'     },";
1575
-											}
1576
-											$options .= "],";
1577
-										}
1578
-										if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1579
-											$extra .= ' multiple: true, ';
1580
-											//$onchange = "props.setAttributes({ $key: ['edit'] } )";
1581
-											//$value = "['edit', 'delete']";
1582
-										}
1583
-									} elseif ( $args['type'] == 'alignment' ) {
1584
-										$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
1585
-									} else {
1586
-										continue;// if we have not implemented the control then don't break the JS.
1587
-									}
1588
-
1589
-									// add show only if advanced
1590
-									if ( ! empty( $args['advanced'] ) ) {
1591
-										echo "props.attributes.show_advanced && ";
1592
-									}
1593
-									// add setting require if defined
1594
-									if ( ! empty( $args['element_require'] ) ) {
1595
-										echo $this->block_props_replace( $args['element_require'], true ) . " && ";
1596
-									}
1597
-									?>
1565
+                                    elseif ( $args['type'] == 'checkbox' ) {
1566
+                                        $type = 'CheckboxControl';
1567
+                                        $extra .= "checked: props.attributes.$key,";
1568
+                                        $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
1569
+                                    } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
1570
+                                        $type = 'SelectControl';
1571
+                                        if ( ! empty( $args['options'] ) ) {
1572
+                                            $options .= "options  : [";
1573
+                                            foreach ( $args['options'] as $option_val => $option_label ) {
1574
+                                                $options .= "{ value : '" . esc_attr( $option_val ) . "',     label : '" . esc_attr( $option_label ) . "'     },";
1575
+                                            }
1576
+                                            $options .= "],";
1577
+                                        }
1578
+                                        if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1579
+                                            $extra .= ' multiple: true, ';
1580
+                                            //$onchange = "props.setAttributes({ $key: ['edit'] } )";
1581
+                                            //$value = "['edit', 'delete']";
1582
+                                        }
1583
+                                    } elseif ( $args['type'] == 'alignment' ) {
1584
+                                        $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
1585
+                                    } else {
1586
+                                        continue;// if we have not implemented the control then don't break the JS.
1587
+                                    }
1588
+
1589
+                                    // add show only if advanced
1590
+                                    if ( ! empty( $args['advanced'] ) ) {
1591
+                                        echo "props.attributes.show_advanced && ";
1592
+                                    }
1593
+                                    // add setting require if defined
1594
+                                    if ( ! empty( $args['element_require'] ) ) {
1595
+                                        echo $this->block_props_replace( $args['element_require'], true ) . " && ";
1596
+                                    }
1597
+                                    ?>
1598 1598
 									el(
1599 1599
 										wp.components.<?php echo esc_attr( $type );?>,
1600 1600
 										{
1601 1601
 											label: '<?php echo esc_attr( $args['title'] );?>',
1602 1602
 											help: '<?php if ( isset( $args['desc'] ) ) {
1603
-												echo esc_attr( $args['desc'] );
1604
-											}?>',
1603
+                                                echo esc_attr( $args['desc'] );
1604
+                                            }?>',
1605 1605
 											value: <?php echo $value;?>,
1606 1606
 											<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
1607
-											echo "type: '" . esc_attr( $args['type'] ) . "',";
1608
-										}?>
1607
+                                            echo "type: '" . esc_attr( $args['type'] ) . "',";
1608
+                                        }?>
1609 1609
 											<?php if ( ! empty( $args['placeholder'] ) ) {
1610
-											echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',";
1611
-										}?>
1610
+                                            echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',";
1611
+                                        }?>
1612 1612
 											<?php echo $options;?>
1613 1613
 											<?php echo $extra;?>
1614 1614
 											<?php echo $custom_attributes;?>
@@ -1618,27 +1618,27 @@  discard block
 block discarded – undo
1618 1618
 										}
1619 1619
 									),
1620 1620
 									<?php
1621
-									}
1622
-									}
1623
-									?>
1621
+                                    }
1622
+                                    }
1623
+                                    ?>
1624 1624
 
1625 1625
 								),
1626 1626
 
1627 1627
 								<?php
1628
-								// If the user sets block-output array then build it
1629
-								if ( ! empty( $this->options['block-output'] ) ) {
1630
-								$this->block_element( $this->options['block-output'] );
1631
-							}else{
1632
-								// if no block-output is set then we try and get the shortcode html output via ajax.
1633
-								?>
1628
+                                // If the user sets block-output array then build it
1629
+                                if ( ! empty( $this->options['block-output'] ) ) {
1630
+                                $this->block_element( $this->options['block-output'] );
1631
+                            }else{
1632
+                                // if no block-output is set then we try and get the shortcode html output via ajax.
1633
+                                ?>
1634 1634
 								el('div', {
1635 1635
 									dangerouslySetInnerHTML: {__html: onChangeContent()},
1636 1636
 									className: props.className,
1637 1637
 									style: {'min-height': '30px'}
1638 1638
 								})
1639 1639
 								<?php
1640
-								}
1641
-								?>
1640
+                                }
1641
+                                ?>
1642 1642
 							]; // end return
1643 1643
 						},
1644 1644
 
@@ -1655,17 +1655,17 @@  discard block
 block discarded – undo
1655 1655
 							var content = "[<?php echo $this->options['base_id'];?>";
1656 1656
 							<?php
1657 1657
 
1658
-							if(! empty( $this->arguments )){
1659
-							foreach($this->arguments as $key => $args){
1660
-							?>
1658
+                            if(! empty( $this->arguments )){
1659
+                            foreach($this->arguments as $key => $args){
1660
+                            ?>
1661 1661
 							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
1662 1662
 								content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' ";
1663 1663
 							}
1664 1664
 							<?php
1665
-							}
1666
-							}
1665
+                            }
1666
+                            }
1667 1667
 
1668
-							?>
1668
+                            ?>
1669 1669
 							content += "]";
1670 1670
 
1671 1671
 
@@ -1694,456 +1694,456 @@  discard block
 block discarded – undo
1694 1694
 				})();
1695 1695
 			</script>
1696 1696
 			<?php
1697
-			$output = ob_get_clean();
1697
+            $output = ob_get_clean();
1698 1698
 
1699
-			/*
1699
+            /*
1700 1700
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1701 1701
 			 */
1702 1702
 
1703
-			return str_replace( array(
1704
-				'<script>',
1705
-				'</script>'
1706
-			), '', $output );
1707
-		}
1708
-
1709
-		/**
1710
-		 * Convert an array of attributes to block string.
1711
-		 *
1712
-		 * @todo there is prob a faster way to do this, also we could add some validation here.
1713
-		 *
1714
-		 * @param $custom_attributes
1715
-		 *
1716
-		 * @return string
1717
-		 */
1718
-		public function array_to_attributes( $custom_attributes, $html = false ) {
1719
-			$attributes = '';
1720
-			if ( ! empty( $custom_attributes ) ) {
1721
-
1722
-				if ( $html ) {
1723
-					foreach ( $custom_attributes as $key => $val ) {
1724
-						$attributes .= " $key='$val' ";
1725
-					}
1726
-				} else {
1727
-					foreach ( $custom_attributes as $key => $val ) {
1728
-						$attributes .= "'$key': '$val',";
1729
-					}
1730
-				}
1731
-			}
1732
-
1733
-			return $attributes;
1734
-		}
1735
-
1736
-		/**
1737
-		 * A self looping function to create the output for JS block elements.
1738
-		 *
1739
-		 * This is what is output in the WP Editor visual view.
1740
-		 *
1741
-		 * @param $args
1742
-		 */
1743
-		public function block_element( $args ) {
1744
-
1745
-
1746
-			if ( ! empty( $args ) ) {
1747
-				foreach ( $args as $element => $new_args ) {
1748
-
1749
-					if ( is_array( $new_args ) ) { // its an element
1750
-
1751
-
1752
-						if ( isset( $new_args['element'] ) ) {
1753
-
1754
-							if ( isset( $new_args['element_require'] ) ) {
1755
-								echo str_replace( array(
1756
-										"'+",
1757
-										"+'"
1758
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
1759
-								unset( $new_args['element_require'] );
1760
-							}
1761
-
1762
-							echo "\n el( '" . $new_args['element'] . "', {";
1763
-
1764
-							// get the attributes
1765
-							foreach ( $new_args as $new_key => $new_value ) {
1766
-
1767
-
1768
-								if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
1769
-									// do nothing
1770
-								} else {
1771
-									echo $this->block_element( array( $new_key => $new_value ) );
1772
-								}
1773
-							}
1774
-
1775
-							echo "},";// end attributes
1776
-
1777
-							// get the content
1778
-							$first_item = 0;
1779
-							foreach ( $new_args as $new_key => $new_value ) {
1780
-								if ( $new_key === 'content' || is_array( $new_value ) ) {
1781
-
1782
-									if ( $new_key === 'content' ) {
1783
-										echo "'" . $this->block_props_replace( $new_value ) . "'";
1784
-									}
1785
-
1786
-									if ( is_array( $new_value ) ) {
1787
-
1788
-										if ( isset( $new_value['element_require'] ) ) {
1789
-											echo str_replace( array(
1790
-													"'+",
1791
-													"+'"
1792
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
1793
-											unset( $new_value['element_require'] );
1794
-										}
1795
-
1796
-										if ( isset( $new_value['element_repeat'] ) ) {
1797
-											$x = 1;
1798
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
1799
-												$this->block_element( array( '' => $new_value ) );
1800
-												$x ++;
1801
-											}
1802
-										} else {
1803
-											$this->block_element( array( '' => $new_value ) );
1804
-										}
1805
-									}
1806
-									$first_item ++;
1807
-								}
1808
-							}
1809
-
1810
-							echo ")";// end content
1811
-
1812
-							echo ", \n";
1813
-
1814
-						}
1815
-					} else {
1816
-
1817
-						if ( substr( $element, 0, 3 ) === "if_" ) {
1818
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
1819
-						} elseif ( $element == 'style' ) {
1820
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
1821
-						} else {
1822
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
1823
-						}
1824
-
1825
-					}
1826
-				}
1827
-			}
1828
-		}
1829
-
1830
-		/**
1831
-		 * Replace block attributes placeholders with the proper naming.
1832
-		 *
1833
-		 * @param $string
1834
-		 *
1835
-		 * @return mixed
1836
-		 */
1837
-		public function block_props_replace( $string, $no_wrap = false ) {
1838
-
1839
-			if ( $no_wrap ) {
1840
-				$string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
1841
-			} else {
1842
-				$string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
1843
-			}
1844
-
1845
-			return $string;
1846
-		}
1847
-
1848
-		/**
1849
-		 * Outputs the content of the widget
1850
-		 *
1851
-		 * @param array $args
1852
-		 * @param array $instance
1853
-		 */
1854
-		public function widget( $args, $instance ) {
1855
-
1856
-			// get the filtered values
1857
-			$argument_values = $this->argument_values( $instance );
1858
-			$argument_values = $this->string_to_bool( $argument_values );
1859
-			$output          = $this->output( $argument_values, $args );
1860
-
1861
-			if ( $output ) {
1862
-				// Before widget
1863
-				$before_widget = $args['before_widget'];
1864
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
1865
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
1866
-
1867
-				// After widget
1868
-				$after_widget = $args['after_widget'];
1869
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
1870
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
1871
-
1872
-				echo $before_widget;
1873
-				// elementor strips the widget wrapping div so we check for and add it back if needed
1874
-				if ( $this->is_elementor_widget_output() ) {
1875
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $this->options['widget_ops']['classname'] ) . "'>" : '';
1876
-				}
1877
-				echo $this->output_title( $args, $instance );
1878
-				echo $output;
1879
-				if ( $this->is_elementor_widget_output() ) {
1880
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : '';
1881
-				}
1882
-				echo $after_widget;
1883
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
1884
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1885
-				echo $output;
1886
-			}
1887
-		}
1888
-
1889
-		/**
1890
-		 * Tests if the current output is inside a elementor container.
1891
-		 *
1892
-		 * @since 1.0.4
1893
-		 * @return bool
1894
-		 */
1895
-		public function is_elementor_widget_output() {
1896
-			$result = false;
1897
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
1898
-				$result = true;
1899
-			}
1900
-
1901
-			return $result;
1902
-		}
1903
-
1904
-		/**
1905
-		 * Tests if the current output is inside a elementor preview.
1906
-		 *
1907
-		 * @since 1.0.4
1908
-		 * @return bool
1909
-		 */
1910
-		public function is_elementor_preview() {
1911
-			$result = false;
1912
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
1913
-				$result = true;
1914
-			}
1915
-
1916
-			return $result;
1917
-		}
1918
-
1919
-		/**
1920
-		 * Tests if the current output is inside a Divi preview.
1921
-		 *
1922
-		 * @since 1.0.6
1923
-		 * @return bool
1924
-		 */
1925
-		public function is_divi_preview() {
1926
-			$result = false;
1927
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
1928
-				$result = true;
1929
-			}
1930
-
1931
-			return $result;
1932
-		}
1933
-
1934
-		/**
1935
-		 * Tests if the current output is inside a Beaver builder preview.
1936
-		 *
1937
-		 * @since 1.0.6
1938
-		 * @return bool
1939
-		 */
1940
-		public function is_beaver_preview() {
1941
-			$result = false;
1942
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
1943
-				$result = true;
1944
-			}
1945
-
1946
-			return $result;
1947
-		}
1948
-
1949
-		/**
1950
-		 * Tests if the current output is inside a siteorigin builder preview.
1951
-		 *
1952
-		 * @since 1.0.6
1953
-		 * @return bool
1954
-		 */
1955
-		public function is_siteorigin_preview() {
1956
-			$result = false;
1957
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
1958
-				$result = true;
1959
-			}
1960
-
1961
-			return $result;
1962
-		}
1963
-
1964
-		/**
1965
-		 * Tests if the current output is inside a cornerstone builder preview.
1966
-		 *
1967
-		 * @since 1.0.8
1968
-		 * @return bool
1969
-		 */
1970
-		public function is_cornerstone_preview() {
1971
-			$result = false;
1972
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
1973
-				$result = true;
1974
-			}
1975
-
1976
-			return $result;
1977
-		}
1978
-
1979
-		/**
1980
-		 * General function to check if we are in a preview situation.
1981
-		 *
1982
-		 * @since 1.0.6
1983
-		 * @return bool
1984
-		 */
1985
-		public function is_preview() {
1986
-			$preview = false;
1987
-			if ( $this->is_divi_preview() ) {
1988
-				$preview = true;
1989
-			} elseif ( $this->is_elementor_preview() ) {
1990
-				$preview = true;
1991
-			} elseif ( $this->is_beaver_preview() ) {
1992
-				$preview = true;
1993
-			} elseif ( $this->is_siteorigin_preview() ) {
1994
-				$preview = true;
1995
-			} elseif ( $this->is_cornerstone_preview() ) {
1996
-				$preview = true;
1997
-			}
1998
-
1999
-			return $preview;
2000
-		}
2001
-
2002
-		/**
2003
-		 * Output the super title.
2004
-		 *
2005
-		 * @param $args
2006
-		 * @param array $instance
2007
-		 *
2008
-		 * @return string
2009
-		 */
2010
-		public function output_title( $args, $instance = array() ) {
2011
-			$output = '';
2012
-			if ( ! empty( $instance['title'] ) ) {
2013
-				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
2014
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
2015
-				$output = $args['before_title'] . $title . $args['after_title'];
2016
-			}
2017
-
2018
-			return $output;
2019
-		}
2020
-
2021
-		/**
2022
-		 * Outputs the options form inputs for the widget.
2023
-		 *
2024
-		 * @param array $instance The widget options.
2025
-		 */
2026
-		public function form( $instance ) {
2027
-
2028
-			// set widget instance
2029
-			$this->instance = $instance;
2030
-
2031
-			// set it as a SD widget
2032
-			echo $this->widget_advanced_toggle();
2033
-
2034
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
2035
-			$arguments = $this->get_arguments();
2036
-
2037
-			if ( is_array( $arguments ) ) {
2038
-				foreach ( $arguments as $key => $args ) {
2039
-					$this->widget_inputs( $args, $instance );
2040
-				}
2041
-			}
2042
-		}
2043
-
2044
-		/**
2045
-		 * Get the hidden input that when added makes the advanced button show on widget settings.
2046
-		 *
2047
-		 * @return string
2048
-		 */
2049
-		public function widget_advanced_toggle() {
2050
-
2051
-			$output = '';
2052
-			if ( $this->block_show_advanced() ) {
2053
-				$val = 1;
2054
-			} else {
2055
-				$val = 0;
2056
-			}
2057
-
2058
-			$output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
2059
-
2060
-			return $output;
2061
-		}
2062
-
2063
-		/**
2064
-		 * Convert require element.
2065
-		 *
2066
-		 * @since 1.0.0
2067
-		 *
2068
-		 * @param string $input Input element.
2069
-		 *
2070
-		 * @return string $output
2071
-		 */
2072
-		public function convert_element_require( $input ) {
2073
-
2074
-			$input = str_replace( "'", '"', $input );// we only want double quotes
2075
-
2076
-			$output = esc_attr( str_replace( array( "[%", "%]" ), array(
2077
-				"jQuery(form).find('[data-argument=\"",
2078
-				"\"]').find('input,select').val()"
2079
-			), $input ) );
2080
-
2081
-			return $output;
2082
-		}
2083
-
2084
-		/**
2085
-		 * Builds the inputs for the widget options.
2086
-		 *
2087
-		 * @param $args
2088
-		 * @param $instance
2089
-		 */
2090
-		public function widget_inputs( $args, $instance ) {
2091
-
2092
-			$class             = "";
2093
-			$element_require   = "";
2094
-			$custom_attributes = "";
2095
-
2096
-			// get value
2097
-			if ( isset( $instance[ $args['name'] ] ) ) {
2098
-				$value = $instance[ $args['name'] ];
2099
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
2100
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
2101
-			} else {
2102
-				$value = '';
2103
-			}
2104
-
2105
-			// get placeholder
2106
-			if ( ! empty( $args['placeholder'] ) ) {
2107
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
2108
-			} else {
2109
-				$placeholder = '';
2110
-			}
2111
-
2112
-			// get if advanced
2113
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
2114
-				$class .= " sd-advanced-setting ";
2115
-			}
2116
-
2117
-			// element_require
2118
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
2119
-				$element_require = $args['element_require'];
2120
-			}
2121
-
2122
-			// custom_attributes
2123
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
2124
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
2125
-			}
2126
-
2127
-			// before wrapper
2128
-			?>
1703
+            return str_replace( array(
1704
+                '<script>',
1705
+                '</script>'
1706
+            ), '', $output );
1707
+        }
1708
+
1709
+        /**
1710
+         * Convert an array of attributes to block string.
1711
+         *
1712
+         * @todo there is prob a faster way to do this, also we could add some validation here.
1713
+         *
1714
+         * @param $custom_attributes
1715
+         *
1716
+         * @return string
1717
+         */
1718
+        public function array_to_attributes( $custom_attributes, $html = false ) {
1719
+            $attributes = '';
1720
+            if ( ! empty( $custom_attributes ) ) {
1721
+
1722
+                if ( $html ) {
1723
+                    foreach ( $custom_attributes as $key => $val ) {
1724
+                        $attributes .= " $key='$val' ";
1725
+                    }
1726
+                } else {
1727
+                    foreach ( $custom_attributes as $key => $val ) {
1728
+                        $attributes .= "'$key': '$val',";
1729
+                    }
1730
+                }
1731
+            }
1732
+
1733
+            return $attributes;
1734
+        }
1735
+
1736
+        /**
1737
+         * A self looping function to create the output for JS block elements.
1738
+         *
1739
+         * This is what is output in the WP Editor visual view.
1740
+         *
1741
+         * @param $args
1742
+         */
1743
+        public function block_element( $args ) {
1744
+
1745
+
1746
+            if ( ! empty( $args ) ) {
1747
+                foreach ( $args as $element => $new_args ) {
1748
+
1749
+                    if ( is_array( $new_args ) ) { // its an element
1750
+
1751
+
1752
+                        if ( isset( $new_args['element'] ) ) {
1753
+
1754
+                            if ( isset( $new_args['element_require'] ) ) {
1755
+                                echo str_replace( array(
1756
+                                        "'+",
1757
+                                        "+'"
1758
+                                    ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
1759
+                                unset( $new_args['element_require'] );
1760
+                            }
1761
+
1762
+                            echo "\n el( '" . $new_args['element'] . "', {";
1763
+
1764
+                            // get the attributes
1765
+                            foreach ( $new_args as $new_key => $new_value ) {
1766
+
1767
+
1768
+                                if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
1769
+                                    // do nothing
1770
+                                } else {
1771
+                                    echo $this->block_element( array( $new_key => $new_value ) );
1772
+                                }
1773
+                            }
1774
+
1775
+                            echo "},";// end attributes
1776
+
1777
+                            // get the content
1778
+                            $first_item = 0;
1779
+                            foreach ( $new_args as $new_key => $new_value ) {
1780
+                                if ( $new_key === 'content' || is_array( $new_value ) ) {
1781
+
1782
+                                    if ( $new_key === 'content' ) {
1783
+                                        echo "'" . $this->block_props_replace( $new_value ) . "'";
1784
+                                    }
1785
+
1786
+                                    if ( is_array( $new_value ) ) {
1787
+
1788
+                                        if ( isset( $new_value['element_require'] ) ) {
1789
+                                            echo str_replace( array(
1790
+                                                    "'+",
1791
+                                                    "+'"
1792
+                                                ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
1793
+                                            unset( $new_value['element_require'] );
1794
+                                        }
1795
+
1796
+                                        if ( isset( $new_value['element_repeat'] ) ) {
1797
+                                            $x = 1;
1798
+                                            while ( $x <= absint( $new_value['element_repeat'] ) ) {
1799
+                                                $this->block_element( array( '' => $new_value ) );
1800
+                                                $x ++;
1801
+                                            }
1802
+                                        } else {
1803
+                                            $this->block_element( array( '' => $new_value ) );
1804
+                                        }
1805
+                                    }
1806
+                                    $first_item ++;
1807
+                                }
1808
+                            }
1809
+
1810
+                            echo ")";// end content
1811
+
1812
+                            echo ", \n";
1813
+
1814
+                        }
1815
+                    } else {
1816
+
1817
+                        if ( substr( $element, 0, 3 ) === "if_" ) {
1818
+                            echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
1819
+                        } elseif ( $element == 'style' ) {
1820
+                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
1821
+                        } else {
1822
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
1823
+                        }
1824
+
1825
+                    }
1826
+                }
1827
+            }
1828
+        }
1829
+
1830
+        /**
1831
+         * Replace block attributes placeholders with the proper naming.
1832
+         *
1833
+         * @param $string
1834
+         *
1835
+         * @return mixed
1836
+         */
1837
+        public function block_props_replace( $string, $no_wrap = false ) {
1838
+
1839
+            if ( $no_wrap ) {
1840
+                $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
1841
+            } else {
1842
+                $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
1843
+            }
1844
+
1845
+            return $string;
1846
+        }
1847
+
1848
+        /**
1849
+         * Outputs the content of the widget
1850
+         *
1851
+         * @param array $args
1852
+         * @param array $instance
1853
+         */
1854
+        public function widget( $args, $instance ) {
1855
+
1856
+            // get the filtered values
1857
+            $argument_values = $this->argument_values( $instance );
1858
+            $argument_values = $this->string_to_bool( $argument_values );
1859
+            $output          = $this->output( $argument_values, $args );
1860
+
1861
+            if ( $output ) {
1862
+                // Before widget
1863
+                $before_widget = $args['before_widget'];
1864
+                $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
1865
+                $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
1866
+
1867
+                // After widget
1868
+                $after_widget = $args['after_widget'];
1869
+                $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
1870
+                $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
1871
+
1872
+                echo $before_widget;
1873
+                // elementor strips the widget wrapping div so we check for and add it back if needed
1874
+                if ( $this->is_elementor_widget_output() ) {
1875
+                    echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $this->options['widget_ops']['classname'] ) . "'>" : '';
1876
+                }
1877
+                echo $this->output_title( $args, $instance );
1878
+                echo $output;
1879
+                if ( $this->is_elementor_widget_output() ) {
1880
+                    echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : '';
1881
+                }
1882
+                echo $after_widget;
1883
+            } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
1884
+                $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1885
+                echo $output;
1886
+            }
1887
+        }
1888
+
1889
+        /**
1890
+         * Tests if the current output is inside a elementor container.
1891
+         *
1892
+         * @since 1.0.4
1893
+         * @return bool
1894
+         */
1895
+        public function is_elementor_widget_output() {
1896
+            $result = false;
1897
+            if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
1898
+                $result = true;
1899
+            }
1900
+
1901
+            return $result;
1902
+        }
1903
+
1904
+        /**
1905
+         * Tests if the current output is inside a elementor preview.
1906
+         *
1907
+         * @since 1.0.4
1908
+         * @return bool
1909
+         */
1910
+        public function is_elementor_preview() {
1911
+            $result = false;
1912
+            if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
1913
+                $result = true;
1914
+            }
1915
+
1916
+            return $result;
1917
+        }
1918
+
1919
+        /**
1920
+         * Tests if the current output is inside a Divi preview.
1921
+         *
1922
+         * @since 1.0.6
1923
+         * @return bool
1924
+         */
1925
+        public function is_divi_preview() {
1926
+            $result = false;
1927
+            if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
1928
+                $result = true;
1929
+            }
1930
+
1931
+            return $result;
1932
+        }
1933
+
1934
+        /**
1935
+         * Tests if the current output is inside a Beaver builder preview.
1936
+         *
1937
+         * @since 1.0.6
1938
+         * @return bool
1939
+         */
1940
+        public function is_beaver_preview() {
1941
+            $result = false;
1942
+            if ( isset( $_REQUEST['fl_builder'] ) ) {
1943
+                $result = true;
1944
+            }
1945
+
1946
+            return $result;
1947
+        }
1948
+
1949
+        /**
1950
+         * Tests if the current output is inside a siteorigin builder preview.
1951
+         *
1952
+         * @since 1.0.6
1953
+         * @return bool
1954
+         */
1955
+        public function is_siteorigin_preview() {
1956
+            $result = false;
1957
+            if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
1958
+                $result = true;
1959
+            }
1960
+
1961
+            return $result;
1962
+        }
1963
+
1964
+        /**
1965
+         * Tests if the current output is inside a cornerstone builder preview.
1966
+         *
1967
+         * @since 1.0.8
1968
+         * @return bool
1969
+         */
1970
+        public function is_cornerstone_preview() {
1971
+            $result = false;
1972
+            if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
1973
+                $result = true;
1974
+            }
1975
+
1976
+            return $result;
1977
+        }
1978
+
1979
+        /**
1980
+         * General function to check if we are in a preview situation.
1981
+         *
1982
+         * @since 1.0.6
1983
+         * @return bool
1984
+         */
1985
+        public function is_preview() {
1986
+            $preview = false;
1987
+            if ( $this->is_divi_preview() ) {
1988
+                $preview = true;
1989
+            } elseif ( $this->is_elementor_preview() ) {
1990
+                $preview = true;
1991
+            } elseif ( $this->is_beaver_preview() ) {
1992
+                $preview = true;
1993
+            } elseif ( $this->is_siteorigin_preview() ) {
1994
+                $preview = true;
1995
+            } elseif ( $this->is_cornerstone_preview() ) {
1996
+                $preview = true;
1997
+            }
1998
+
1999
+            return $preview;
2000
+        }
2001
+
2002
+        /**
2003
+         * Output the super title.
2004
+         *
2005
+         * @param $args
2006
+         * @param array $instance
2007
+         *
2008
+         * @return string
2009
+         */
2010
+        public function output_title( $args, $instance = array() ) {
2011
+            $output = '';
2012
+            if ( ! empty( $instance['title'] ) ) {
2013
+                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
2014
+                $title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
2015
+                $output = $args['before_title'] . $title . $args['after_title'];
2016
+            }
2017
+
2018
+            return $output;
2019
+        }
2020
+
2021
+        /**
2022
+         * Outputs the options form inputs for the widget.
2023
+         *
2024
+         * @param array $instance The widget options.
2025
+         */
2026
+        public function form( $instance ) {
2027
+
2028
+            // set widget instance
2029
+            $this->instance = $instance;
2030
+
2031
+            // set it as a SD widget
2032
+            echo $this->widget_advanced_toggle();
2033
+
2034
+            echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
2035
+            $arguments = $this->get_arguments();
2036
+
2037
+            if ( is_array( $arguments ) ) {
2038
+                foreach ( $arguments as $key => $args ) {
2039
+                    $this->widget_inputs( $args, $instance );
2040
+                }
2041
+            }
2042
+        }
2043
+
2044
+        /**
2045
+         * Get the hidden input that when added makes the advanced button show on widget settings.
2046
+         *
2047
+         * @return string
2048
+         */
2049
+        public function widget_advanced_toggle() {
2050
+
2051
+            $output = '';
2052
+            if ( $this->block_show_advanced() ) {
2053
+                $val = 1;
2054
+            } else {
2055
+                $val = 0;
2056
+            }
2057
+
2058
+            $output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
2059
+
2060
+            return $output;
2061
+        }
2062
+
2063
+        /**
2064
+         * Convert require element.
2065
+         *
2066
+         * @since 1.0.0
2067
+         *
2068
+         * @param string $input Input element.
2069
+         *
2070
+         * @return string $output
2071
+         */
2072
+        public function convert_element_require( $input ) {
2073
+
2074
+            $input = str_replace( "'", '"', $input );// we only want double quotes
2075
+
2076
+            $output = esc_attr( str_replace( array( "[%", "%]" ), array(
2077
+                "jQuery(form).find('[data-argument=\"",
2078
+                "\"]').find('input,select').val()"
2079
+            ), $input ) );
2080
+
2081
+            return $output;
2082
+        }
2083
+
2084
+        /**
2085
+         * Builds the inputs for the widget options.
2086
+         *
2087
+         * @param $args
2088
+         * @param $instance
2089
+         */
2090
+        public function widget_inputs( $args, $instance ) {
2091
+
2092
+            $class             = "";
2093
+            $element_require   = "";
2094
+            $custom_attributes = "";
2095
+
2096
+            // get value
2097
+            if ( isset( $instance[ $args['name'] ] ) ) {
2098
+                $value = $instance[ $args['name'] ];
2099
+            } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
2100
+                $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
2101
+            } else {
2102
+                $value = '';
2103
+            }
2104
+
2105
+            // get placeholder
2106
+            if ( ! empty( $args['placeholder'] ) ) {
2107
+                $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
2108
+            } else {
2109
+                $placeholder = '';
2110
+            }
2111
+
2112
+            // get if advanced
2113
+            if ( isset( $args['advanced'] ) && $args['advanced'] ) {
2114
+                $class .= " sd-advanced-setting ";
2115
+            }
2116
+
2117
+            // element_require
2118
+            if ( isset( $args['element_require'] ) && $args['element_require'] ) {
2119
+                $element_require = $args['element_require'];
2120
+            }
2121
+
2122
+            // custom_attributes
2123
+            if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
2124
+                $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
2125
+            }
2126
+
2127
+            // before wrapper
2128
+            ?>
2129 2129
 			<p class="sd-argument <?php echo esc_attr( $class ); ?>"
2130 2130
 			   data-argument='<?php echo esc_attr( $args['name'] ); ?>'
2131 2131
 			   data-element_require='<?php if ( $element_require ) {
2132
-				   echo $this->convert_element_require( $element_require );
2133
-			   } ?>'
2132
+                    echo $this->convert_element_require( $element_require );
2133
+                } ?>'
2134 2134
 			>
2135 2135
 				<?php
2136 2136
 
2137
-				switch ( $args['type'] ) {
2138
-					//array('text','password','number','email','tel','url','color')
2139
-					case "text":
2140
-					case "password":
2141
-					case "number":
2142
-					case "email":
2143
-					case "tel":
2144
-					case "url":
2145
-					case "color":
2146
-						?>
2137
+                switch ( $args['type'] ) {
2138
+                    //array('text','password','number','email','tel','url','color')
2139
+                    case "text":
2140
+                    case "password":
2141
+                    case "number":
2142
+                    case "email":
2143
+                    case "tel":
2144
+                    case "url":
2145
+                    case "color":
2146
+                        ?>
2147 2147
 						<label
2148 2148
 							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2149 2149
 						<input <?php echo $placeholder; ?> class="widefat"
@@ -2154,47 +2154,47 @@  discard block
 block discarded – undo
2154 2154
 							                               value="<?php echo esc_attr( $value ); ?>">
2155 2155
 						<?php
2156 2156
 
2157
-						break;
2158
-					case "select":
2159
-						$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
2160
-						if ( $multiple ) {
2161
-							if ( empty( $value ) ) {
2162
-								$value = array();
2163
-							}
2164
-						}
2165
-						?>
2157
+                        break;
2158
+                    case "select":
2159
+                        $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
2160
+                        if ( $multiple ) {
2161
+                            if ( empty( $value ) ) {
2162
+                                $value = array();
2163
+                            }
2164
+                        }
2165
+                        ?>
2166 2166
 						<label
2167 2167
 							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2168 2168
 						<select <?php echo $placeholder; ?> class="widefat"
2169 2169
 							<?php echo $custom_attributes; ?>
2170 2170
 							                                id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2171 2171
 							                                name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) );
2172
-							                                if ( $multiple ) {
2173
-								                                echo "[]";
2174
-							                                } ?>"
2172
+                                                            if ( $multiple ) {
2173
+                                                                echo "[]";
2174
+                                                            } ?>"
2175 2175
 							<?php if ( $multiple ) {
2176
-								echo "multiple";
2177
-							} //@todo not implemented yet due to gutenberg not supporting it
2178
-							?>
2176
+                                echo "multiple";
2177
+                            } //@todo not implemented yet due to gutenberg not supporting it
2178
+                            ?>
2179 2179
 						>
2180 2180
 							<?php
2181 2181
 
2182
-							if ( ! empty( $args['options'] ) ) {
2183
-								foreach ( $args['options'] as $val => $label ) {
2184
-									if ( $multiple ) {
2185
-										$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
2186
-									} else {
2187
-										$selected = selected( $value, $val, false );
2188
-									}
2189
-									echo "<option value='$val' " . $selected . ">$label</option>";
2190
-								}
2191
-							}
2192
-							?>
2182
+                            if ( ! empty( $args['options'] ) ) {
2183
+                                foreach ( $args['options'] as $val => $label ) {
2184
+                                    if ( $multiple ) {
2185
+                                        $selected = in_array( $val, $value ) ? 'selected="selected"' : '';
2186
+                                    } else {
2187
+                                        $selected = selected( $value, $val, false );
2188
+                                    }
2189
+                                    echo "<option value='$val' " . $selected . ">$label</option>";
2190
+                                }
2191
+                            }
2192
+                            ?>
2193 2193
 						</select>
2194 2194
 						<?php
2195
-						break;
2196
-					case "checkbox":
2197
-						?>
2195
+                        break;
2196
+                    case "checkbox":
2197
+                        ?>
2198 2198
 						<input <?php echo $placeholder; ?>
2199 2199
 							<?php checked( 1, $value, true ) ?>
2200 2200
 							<?php echo $custom_attributes; ?>
@@ -2204,136 +2204,136 @@  discard block
 block discarded – undo
2204 2204
 						<label
2205 2205
 							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2206 2206
 						<?php
2207
-						break;
2208
-					case "hidden":
2209
-						?>
2207
+                        break;
2208
+                    case "hidden":
2209
+                        ?>
2210 2210
 						<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2211 2211
 						       name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden"
2212 2212
 						       value="<?php echo esc_attr( $value ); ?>">
2213 2213
 						<?php
2214
-						break;
2215
-					default:
2216
-						echo "No input type found!"; // @todo we need to add more input types.
2217
-				}
2214
+                        break;
2215
+                    default:
2216
+                        echo "No input type found!"; // @todo we need to add more input types.
2217
+                }
2218 2218
 
2219
-				// after wrapper
2220
-				?>
2219
+                // after wrapper
2220
+                ?>
2221 2221
 			</p>
2222 2222
 			<?php
2223 2223
 
2224
-		}
2225
-
2226
-		/**
2227
-		 * Get the widget input description html.
2228
-		 *
2229
-		 * @param $args
2230
-		 *
2231
-		 * @return string
2232
-		 * @todo, need to make its own tooltip script
2233
-		 */
2234
-		public function widget_field_desc( $args ) {
2235
-
2236
-			$description = '';
2237
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
2238
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
2239
-					$description = $this->desc_tip( $args['desc'] );
2240
-				} else {
2241
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
2242
-				}
2243
-			}
2244
-
2245
-			return $description;
2246
-		}
2247
-
2248
-		/**
2249
-		 * Get the tool tip html.
2250
-		 *
2251
-		 * @param $tip
2252
-		 * @param bool $allow_html
2253
-		 *
2254
-		 * @return string
2255
-		 */
2256
-		function desc_tip( $tip, $allow_html = false ) {
2257
-			if ( $allow_html ) {
2258
-				$tip = $this->sanitize_tooltip( $tip );
2259
-			} else {
2260
-				$tip = esc_attr( $tip );
2261
-			}
2262
-
2263
-			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
2264
-		}
2265
-
2266
-		/**
2267
-		 * Sanitize a string destined to be a tooltip.
2268
-		 *
2269
-		 * @param string $var
2270
-		 *
2271
-		 * @return string
2272
-		 */
2273
-		public function sanitize_tooltip( $var ) {
2274
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
2275
-				'br'     => array(),
2276
-				'em'     => array(),
2277
-				'strong' => array(),
2278
-				'small'  => array(),
2279
-				'span'   => array(),
2280
-				'ul'     => array(),
2281
-				'li'     => array(),
2282
-				'ol'     => array(),
2283
-				'p'      => array(),
2284
-			) ) );
2285
-		}
2286
-
2287
-		/**
2288
-		 * Processing widget options on save
2289
-		 *
2290
-		 * @param array $new_instance The new options
2291
-		 * @param array $old_instance The previous options
2292
-		 *
2293
-		 * @return array
2294
-		 * @todo we should add some sanitation here.
2295
-		 */
2296
-		public function update( $new_instance, $old_instance ) {
2297
-
2298
-			//save the widget
2299
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
2300
-
2301
-			// set widget instance
2302
-			$this->instance = $instance;
2303
-
2304
-			if ( empty( $this->arguments ) ) {
2305
-				$this->get_arguments();
2306
-			}
2307
-
2308
-			// check for checkboxes
2309
-			if ( ! empty( $this->arguments ) ) {
2310
-				foreach ( $this->arguments as $argument ) {
2311
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
2312
-						$instance[ $argument['name'] ] = '0';
2313
-					}
2314
-				}
2315
-			}
2316
-
2317
-			return $instance;
2318
-		}
2319
-
2320
-		/**
2321
-		 * Checks if the current call is a ajax call to get the block content.
2322
-		 *
2323
-		 * This can be used in your widget to return different content as the block content.
2324
-		 *
2325
-		 * @since 1.0.3
2326
-		 * @return bool
2327
-		 */
2328
-		public function is_block_content_call() {
2329
-			$result = false;
2330
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
2331
-				$result = true;
2332
-			}
2333
-
2334
-			return $result;
2335
-		}
2336
-
2337
-	}
2224
+        }
2225
+
2226
+        /**
2227
+         * Get the widget input description html.
2228
+         *
2229
+         * @param $args
2230
+         *
2231
+         * @return string
2232
+         * @todo, need to make its own tooltip script
2233
+         */
2234
+        public function widget_field_desc( $args ) {
2235
+
2236
+            $description = '';
2237
+            if ( isset( $args['desc'] ) && $args['desc'] ) {
2238
+                if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
2239
+                    $description = $this->desc_tip( $args['desc'] );
2240
+                } else {
2241
+                    $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
2242
+                }
2243
+            }
2244
+
2245
+            return $description;
2246
+        }
2247
+
2248
+        /**
2249
+         * Get the tool tip html.
2250
+         *
2251
+         * @param $tip
2252
+         * @param bool $allow_html
2253
+         *
2254
+         * @return string
2255
+         */
2256
+        function desc_tip( $tip, $allow_html = false ) {
2257
+            if ( $allow_html ) {
2258
+                $tip = $this->sanitize_tooltip( $tip );
2259
+            } else {
2260
+                $tip = esc_attr( $tip );
2261
+            }
2262
+
2263
+            return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
2264
+        }
2265
+
2266
+        /**
2267
+         * Sanitize a string destined to be a tooltip.
2268
+         *
2269
+         * @param string $var
2270
+         *
2271
+         * @return string
2272
+         */
2273
+        public function sanitize_tooltip( $var ) {
2274
+            return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
2275
+                'br'     => array(),
2276
+                'em'     => array(),
2277
+                'strong' => array(),
2278
+                'small'  => array(),
2279
+                'span'   => array(),
2280
+                'ul'     => array(),
2281
+                'li'     => array(),
2282
+                'ol'     => array(),
2283
+                'p'      => array(),
2284
+            ) ) );
2285
+        }
2286
+
2287
+        /**
2288
+         * Processing widget options on save
2289
+         *
2290
+         * @param array $new_instance The new options
2291
+         * @param array $old_instance The previous options
2292
+         *
2293
+         * @return array
2294
+         * @todo we should add some sanitation here.
2295
+         */
2296
+        public function update( $new_instance, $old_instance ) {
2297
+
2298
+            //save the widget
2299
+            $instance = array_merge( (array) $old_instance, (array) $new_instance );
2300
+
2301
+            // set widget instance
2302
+            $this->instance = $instance;
2303
+
2304
+            if ( empty( $this->arguments ) ) {
2305
+                $this->get_arguments();
2306
+            }
2307
+
2308
+            // check for checkboxes
2309
+            if ( ! empty( $this->arguments ) ) {
2310
+                foreach ( $this->arguments as $argument ) {
2311
+                    if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
2312
+                        $instance[ $argument['name'] ] = '0';
2313
+                    }
2314
+                }
2315
+            }
2316
+
2317
+            return $instance;
2318
+        }
2319
+
2320
+        /**
2321
+         * Checks if the current call is a ajax call to get the block content.
2322
+         *
2323
+         * This can be used in your widget to return different content as the block content.
2324
+         *
2325
+         * @since 1.0.3
2326
+         * @return bool
2327
+         */
2328
+        public function is_block_content_call() {
2329
+            $result = false;
2330
+            if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
2331
+                $result = true;
2332
+            }
2333
+
2334
+            return $result;
2335
+        }
2336
+
2337
+    }
2338 2338
 
2339 2339
 }
2340 2340
\ No newline at end of file
Please login to merge, or discard this patch.