Passed
Push — master ( 8614dd...22bbb7 )
by Brian
18:27
created
includes/gateways/class-getpaid-paypal-gateway-ipn-handler.php 2 patches
Indentation   +391 added lines, -391 removed lines patch added patch discarded remove patch
@@ -12,473 +12,473 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Paypal_Gateway_IPN_Handler {
14 14
 
15
-	/**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
20
-	protected $id = 'paypal';
21
-
22
-	/**
23
-	 * Payment method object.
24
-	 *
25
-	 * @var GetPaid_Paypal_Gateway
26
-	 */
27
-	protected $gateway;
28
-
29
-	/**
30
-	 * Class constructor.
31
-	 *
32
-	 * @param GetPaid_Paypal_Gateway $gateway
33
-	 */
34
-	public function __construct( $gateway ) {
35
-		$this->gateway = $gateway;
36
-		$this->verify_ipn();
37
-	}
38
-
39
-	/**
40
-	 * Processes ipns and marks payments as complete.
41
-	 *
42
-	 * @return void
43
-	 */
44
-	public function verify_ipn() {
45
-
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
-
48
-		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
51
-		}
52
-
53
-		// Process the IPN.
54
-		$posted  = wp_unslash( $_POST );
55
-		$invoice = $this->get_ipn_invoice( $posted );
56
-
57
-		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 200 );
61
-		}
62
-
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
-
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
-
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
73
-		}
74
-
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
77
-
78
-	}
79
-
80
-	/**
81
-	 * Retrieves IPN Invoice.
82
-	 *
83
-	 * @param array $posted
84
-	 * @return WPInv_Invoice
85
-	 */
86
-	protected function get_ipn_invoice( $posted ) {
87
-
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
-
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
92
-
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
-				return $invoice;
96
-			}
97
-		}
98
-
99
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
100
-		wp_die( 'Could not retrieve the associated invoice.', 200 );
101
-	}
102
-
103
-	/**
104
-	 * Check PayPal IPN validity.
105
-	 */
106
-	protected function validate_ipn() {
107
-
108
-		wpinv_error_log( 'Validating PayPal IPN response', false );
109
-
110
-		// Retrieve the associated invoice.
111
-		$posted  = wp_unslash( $_POST );
112
-		$invoice = $this->get_ipn_invoice( $posted );
113
-
114
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
115
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
116
-		}
117
-
118
-		// Validate the IPN.
119
-		$posted['cmd'] = '_notify-validate';
120
-
121
-		// Send back post vars to paypal.
122
-		$params = array(
123
-			'body'        => $posted,
124
-			'timeout'     => 60,
125
-			'httpversion' => '1.1',
126
-			'compress'    => false,
127
-			'decompress'  => false,
128
-			'user-agent'  => 'GetPaid/' . WPINV_VERSION,
129
-		);
130
-
131
-		// Post back to get a response.
132
-		$response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
133
-
134
-		// Check to see if the request was valid.
135
-		if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
136
-			wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
137
-			return true;
138
-		}
139
-
140
-		if ( is_wp_error( $response ) ) {
141
-			wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
142
-			return false;
143
-		}
144
-
145
-		wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
146
-		return false;
147
-
148
-	}
149
-
150
-	/**
151
-	 * Check currency from IPN matches the invoice.
152
-	 *
153
-	 * @param WPInv_Invoice $invoice          Invoice object.
154
-	 * @param string   $currency currency to validate.
155
-	 */
156
-	protected function validate_ipn_currency( $invoice, $currency ) {
15
+    /**
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20
+    protected $id = 'paypal';
21
+
22
+    /**
23
+     * Payment method object.
24
+     *
25
+     * @var GetPaid_Paypal_Gateway
26
+     */
27
+    protected $gateway;
28
+
29
+    /**
30
+     * Class constructor.
31
+     *
32
+     * @param GetPaid_Paypal_Gateway $gateway
33
+     */
34
+    public function __construct( $gateway ) {
35
+        $this->gateway = $gateway;
36
+        $this->verify_ipn();
37
+    }
38
+
39
+    /**
40
+     * Processes ipns and marks payments as complete.
41
+     *
42
+     * @return void
43
+     */
44
+    public function verify_ipn() {
45
+
46
+        wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
+
48
+        // Validate the IPN.
49
+        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
+            wp_die( 'PayPal IPN Request Failure', 500 );
51
+        }
52
+
53
+        // Process the IPN.
54
+        $posted  = wp_unslash( $_POST );
55
+        $invoice = $this->get_ipn_invoice( $posted );
56
+
57
+        // Abort if it was not paid by our gateway.
58
+        if ( $this->id != $invoice->get_gateway() ) {
59
+            wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
+            wp_die( 'Invoice not paid via PayPal', 200 );
61
+        }
62
+
63
+        $posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
+        $posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
+
66
+        wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
+        wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
+
69
+        if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
+            call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
+            wpinv_error_log( 'Done processing IPN', false );
72
+            wp_die( 'Processed', 200 );
73
+        }
74
+
75
+        wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
+        wp_die( 'Unsupported IPN type', 200 );
77
+
78
+    }
79
+
80
+    /**
81
+     * Retrieves IPN Invoice.
82
+     *
83
+     * @param array $posted
84
+     * @return WPInv_Invoice
85
+     */
86
+    protected function get_ipn_invoice( $posted ) {
87
+
88
+        wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
+
90
+        if ( ! empty( $posted['custom'] ) ) {
91
+            $invoice = new WPInv_Invoice( $posted['custom'] );
92
+
93
+            if ( $invoice->exists() ) {
94
+                wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
+                return $invoice;
96
+            }
97
+        }
98
+
99
+        wpinv_error_log( 'Could not retrieve the associated invoice.', false );
100
+        wp_die( 'Could not retrieve the associated invoice.', 200 );
101
+    }
102
+
103
+    /**
104
+     * Check PayPal IPN validity.
105
+     */
106
+    protected function validate_ipn() {
107
+
108
+        wpinv_error_log( 'Validating PayPal IPN response', false );
109
+
110
+        // Retrieve the associated invoice.
111
+        $posted  = wp_unslash( $_POST );
112
+        $invoice = $this->get_ipn_invoice( $posted );
113
+
114
+        if ( $this->gateway->is_sandbox( $invoice ) ) {
115
+            wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
116
+        }
117
+
118
+        // Validate the IPN.
119
+        $posted['cmd'] = '_notify-validate';
120
+
121
+        // Send back post vars to paypal.
122
+        $params = array(
123
+            'body'        => $posted,
124
+            'timeout'     => 60,
125
+            'httpversion' => '1.1',
126
+            'compress'    => false,
127
+            'decompress'  => false,
128
+            'user-agent'  => 'GetPaid/' . WPINV_VERSION,
129
+        );
130
+
131
+        // Post back to get a response.
132
+        $response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
133
+
134
+        // Check to see if the request was valid.
135
+        if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
136
+            wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
137
+            return true;
138
+        }
139
+
140
+        if ( is_wp_error( $response ) ) {
141
+            wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
142
+            return false;
143
+        }
144
+
145
+        wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
146
+        return false;
147
+
148
+    }
149
+
150
+    /**
151
+     * Check currency from IPN matches the invoice.
152
+     *
153
+     * @param WPInv_Invoice $invoice          Invoice object.
154
+     * @param string   $currency currency to validate.
155
+     */
156
+    protected function validate_ipn_currency( $invoice, $currency ) {
157 157
 
158
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
158
+        if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
159 159
 
160
-			/* translators: %s: currency code. */
161
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
160
+            /* translators: %s: currency code. */
161
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
162 162
 
163
-			wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
164
-		}
163
+            wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
164
+        }
165 165
 
166
-		wpinv_error_log( $currency, 'Validated IPN Currency', false );
167
-	}
166
+        wpinv_error_log( $currency, 'Validated IPN Currency', false );
167
+    }
168 168
 
169
-	/**
170
-	 * Check payment amount from IPN matches the invoice.
171
-	 *
172
-	 * @param WPInv_Invoice $invoice          Invoice object.
173
-	 * @param float   $amount amount to validate.
174
-	 */
175
-	protected function validate_ipn_amount( $invoice, $amount ) {
176
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
169
+    /**
170
+     * Check payment amount from IPN matches the invoice.
171
+     *
172
+     * @param WPInv_Invoice $invoice          Invoice object.
173
+     * @param float   $amount amount to validate.
174
+     */
175
+    protected function validate_ipn_amount( $invoice, $amount ) {
176
+        if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
177 177
 
178
-			/* translators: %s: Amount. */
179
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
178
+            /* translators: %s: Amount. */
179
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
180 180
 
181
-			wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
182
-		}
181
+            wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
182
+        }
183 183
 
184
-		wpinv_error_log( $amount, 'Validated IPN Amount', false );
185
-	}
184
+        wpinv_error_log( $amount, 'Validated IPN Amount', false );
185
+    }
186 186
 
187
-	/**
188
-	 * Verify receiver email from PayPal.
189
-	 *
190
-	 * @param WPInv_Invoice $invoice          Invoice object.
191
-	 * @param string   $receiver_email Email to validate.
192
-	 */
193
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
194
-		$paypal_email = wpinv_get_option( 'paypal_email' );
187
+    /**
188
+     * Verify receiver email from PayPal.
189
+     *
190
+     * @param WPInv_Invoice $invoice          Invoice object.
191
+     * @param string   $receiver_email Email to validate.
192
+     */
193
+    protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
194
+        $paypal_email = wpinv_get_option( 'paypal_email' );
195 195
 
196
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
197
-			wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
196
+        if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
197
+            wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
198 198
 
199
-			/* translators: %s: email address . */
200
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
199
+            /* translators: %s: email address . */
200
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
201 201
 
202
-			return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
203
-		}
202
+            return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
203
+        }
204 204
 
205
-		wpinv_error_log( 'Validated PayPal Email', false );
206
-	}
205
+        wpinv_error_log( 'Validated PayPal Email', false );
206
+    }
207 207
 
208
-	/**
209
-	 * Handles one time payments.
210
-	 *
211
-	 * @param WPInv_Invoice $invoice  Invoice object.
212
-	 * @param array    $posted Posted data.
213
-	 */
214
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
208
+    /**
209
+     * Handles one time payments.
210
+     *
211
+     * @param WPInv_Invoice $invoice  Invoice object.
212
+     * @param array    $posted Posted data.
213
+     */
214
+    protected function ipn_txn_web_accept( $invoice, $posted ) {
215 215
 
216
-		// Collect payment details
217
-		$payment_status = strtolower( $posted['payment_status'] );
218
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
216
+        // Collect payment details
217
+        $payment_status = strtolower( $posted['payment_status'] );
218
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
219 219
 
220
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
221
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
220
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
221
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
222 222
 
223
-		// Update the transaction id.
224
-		if ( ! empty( $posted['txn_id'] ) ) {
225
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
226
-			$invoice->save();
227
-		}
223
+        // Update the transaction id.
224
+        if ( ! empty( $posted['txn_id'] ) ) {
225
+            $invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
226
+            $invoice->save();
227
+        }
228 228
 
229
-		$invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
229
+        $invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
230 230
 
231
-		// Process a refund.
232
-		if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
231
+        // Process a refund.
232
+        if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
233 233
 
234
-			update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
234
+            update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
235 235
 
236
-			if ( ! $invoice->is_refunded() ) {
237
-				$invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
238
-			}
236
+            if ( ! $invoice->is_refunded() ) {
237
+                $invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
238
+            }
239 239
 
240
-			return wpinv_error_log( $posted['reason_code'], false );
241
-		}
240
+            return wpinv_error_log( $posted['reason_code'], false );
241
+        }
242 242
 
243
-		// Process payments.
244
-		if ( $payment_status == 'completed' ) {
243
+        // Process payments.
244
+        if ( $payment_status == 'completed' ) {
245 245
 
246
-			if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
247
-				return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
248
-			}
246
+            if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
247
+                return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
248
+            }
249 249
 
250
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
250
+            $this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
251 251
 
252
-			$note = '';
252
+            $note = '';
253 253
 
254
-			if ( ! empty( $posted['mc_fee'] ) ) {
255
-				$note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
256
-			}
254
+            if ( ! empty( $posted['mc_fee'] ) ) {
255
+                $note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
256
+            }
257 257
 
258
-			if ( ! empty( $posted['payer_status'] ) ) {
259
-				$note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
260
-			}
258
+            if ( ! empty( $posted['payer_status'] ) ) {
259
+                $note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
260
+            }
261 261
 
262
-			$invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
263
-			return wpinv_error_log( 'Invoice marked as paid.', false );
262
+            $invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
263
+            return wpinv_error_log( 'Invoice marked as paid.', false );
264 264
 
265
-		}
265
+        }
266 266
 
267
-		// Pending payments.
268
-		if ( $payment_status == 'pending' ) {
267
+        // Pending payments.
268
+        if ( $payment_status == 'pending' ) {
269 269
 
270
-			/* translators: %s: pending reason. */
271
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
270
+            /* translators: %s: pending reason. */
271
+            $invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
272 272
 
273
-			return wpinv_error_log( 'Invoice marked as "payment held".', false );
274
-		}
273
+            return wpinv_error_log( 'Invoice marked as "payment held".', false );
274
+        }
275 275
 
276
-		/* translators: %s: payment status. */
277
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
276
+        /* translators: %s: payment status. */
277
+        $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
278 278
 
279
-	}
279
+    }
280 280
 
281
-	/**
282
-	 * Handles one time payments.
283
-	 *
284
-	 * @param WPInv_Invoice $invoice  Invoice object.
285
-	 * @param array    $posted Posted data.
286
-	 */
287
-	protected function ipn_txn_cart( $invoice, $posted ) {
288
-		$this->ipn_txn_web_accept( $invoice, $posted );
289
-	}
281
+    /**
282
+     * Handles one time payments.
283
+     *
284
+     * @param WPInv_Invoice $invoice  Invoice object.
285
+     * @param array    $posted Posted data.
286
+     */
287
+    protected function ipn_txn_cart( $invoice, $posted ) {
288
+        $this->ipn_txn_web_accept( $invoice, $posted );
289
+    }
290 290
 
291
-	/**
292
-	 * Handles subscription sign ups.
293
-	 *
294
-	 * @param WPInv_Invoice $invoice  Invoice object.
295
-	 * @param array    $posted Posted data.
296
-	 */
297
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
291
+    /**
292
+     * Handles subscription sign ups.
293
+     *
294
+     * @param WPInv_Invoice $invoice  Invoice object.
295
+     * @param array    $posted Posted data.
296
+     */
297
+    protected function ipn_txn_subscr_signup( $invoice, $posted ) {
298 298
 
299
-		wpinv_error_log( 'Processing subscription signup', false );
299
+        wpinv_error_log( 'Processing subscription signup', false );
300 300
 
301
-		// Make sure the invoice has a subscription.
302
-		$subscription = getpaid_get_invoice_subscription( $invoice );
301
+        // Make sure the invoice has a subscription.
302
+        $subscription = getpaid_get_invoice_subscription( $invoice );
303 303
 
304
-		if ( empty( $subscription ) ) {
305
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
306
-		}
304
+        if ( empty( $subscription ) ) {
305
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
306
+        }
307 307
 
308
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
308
+        wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
309 309
 
310
-		// Validate the IPN.
311
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
312
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
313
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
310
+        // Validate the IPN.
311
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
312
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
313
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
314 314
 
315
-		// Activate the subscription.
316
-		$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
317
-		$subscription->set_date_created( current_time( 'mysql' ) );
318
-		$subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
319
-		$subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
320
-		$subscription->activate();
315
+        // Activate the subscription.
316
+        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
317
+        $subscription->set_date_created( current_time( 'mysql' ) );
318
+        $subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
319
+        $subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
320
+        $subscription->activate();
321 321
 
322
-		// Set the transaction id.
323
-		if ( ! empty( $posted['txn_id'] ) ) {
324
-			$invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
325
-			$invoice->set_transaction_id( $posted['txn_id'] );
326
-		}
322
+        // Set the transaction id.
323
+        if ( ! empty( $posted['txn_id'] ) ) {
324
+            $invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
325
+            $invoice->set_transaction_id( $posted['txn_id'] );
326
+        }
327 327
 
328
-		// Update the payment status.
329
-		$invoice->mark_paid();
328
+        // Update the payment status.
329
+        $invoice->mark_paid();
330 330
 
331
-		$invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
331
+        $invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
332 332
 
333
-		wpinv_error_log( 'Subscription started.', false );
334
-	}
333
+        wpinv_error_log( 'Subscription started.', false );
334
+    }
335 335
 
336
-	/**
337
-	 * Handles subscription renewals.
338
-	 *
339
-	 * @param WPInv_Invoice $invoice  Invoice object.
340
-	 * @param array    $posted Posted data.
341
-	 */
342
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
336
+    /**
337
+     * Handles subscription renewals.
338
+     *
339
+     * @param WPInv_Invoice $invoice  Invoice object.
340
+     * @param array    $posted Posted data.
341
+     */
342
+    protected function ipn_txn_subscr_payment( $invoice, $posted ) {
343 343
 
344
-		// Make sure the invoice has a subscription.
345
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
344
+        // Make sure the invoice has a subscription.
345
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
346 346
 
347
-		if ( empty( $subscription ) ) {
348
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
349
-		}
347
+        if ( empty( $subscription ) ) {
348
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
349
+        }
350 350
 
351
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
351
+        wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
352 352
 
353
-		// PayPal sends a subscr_payment for the first payment too.
354
-		$date_completed = getpaid_format_date( $invoice->get_date_completed() );
355
-		$date_created   = getpaid_format_date( $invoice->get_date_created() );
356
-		$today_date     = getpaid_format_date( current_time( 'mysql' ) );
357
-		$payment_date   = getpaid_format_date( $posted['payment_date'] );
358
-		$subscribe_date = getpaid_format_date( $subscription->get_date_created() );
359
-		$dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
353
+        // PayPal sends a subscr_payment for the first payment too.
354
+        $date_completed = getpaid_format_date( $invoice->get_date_completed() );
355
+        $date_created   = getpaid_format_date( $invoice->get_date_created() );
356
+        $today_date     = getpaid_format_date( current_time( 'mysql' ) );
357
+        $payment_date   = getpaid_format_date( $posted['payment_date'] );
358
+        $subscribe_date = getpaid_format_date( $subscription->get_date_created() );
359
+        $dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
360 360
 
361
-		foreach ( $dates as $date ) {
361
+        foreach ( $dates as $date ) {
362 362
 
363
-			if ( $date !== $today_date && $date !== $payment_date ) {
364
-				continue;
365
-			}
363
+            if ( $date !== $today_date && $date !== $payment_date ) {
364
+                continue;
365
+            }
366 366
 
367
-			if ( ! empty( $posted['txn_id'] ) ) {
368
-				$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
369
-				$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
370
-			}
367
+            if ( ! empty( $posted['txn_id'] ) ) {
368
+                $invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
369
+                $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
370
+            }
371 371
 
372
-			return $invoice->mark_paid();
373
-
374
-		}
372
+            return $invoice->mark_paid();
373
+
374
+        }
375 375
 
376
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
377
-
378
-		// Abort if the payment is already recorded.
379
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
380
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false );
381
-		}
382
-
383
-		$args = array(
384
-			'transaction_id' => $posted['txn_id'],
385
-			'gateway'        => $this->id,
386
-		);
387
-
388
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
376
+        wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
377
+
378
+        // Abort if the payment is already recorded.
379
+        if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
380
+            return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false );
381
+        }
382
+
383
+        $args = array(
384
+            'transaction_id' => $posted['txn_id'],
385
+            'gateway'        => $this->id,
386
+        );
387
+
388
+        $invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
389 389
 
390
-		if ( empty( $invoice ) ) {
391
-			return;
392
-		}
390
+        if ( empty( $invoice ) ) {
391
+            return;
392
+        }
393 393
 
394
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
395
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
394
+        $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
395
+        $invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
396 396
 
397
-		$subscription->renew();
398
-		wpinv_error_log( 'Subscription renewed.', false );
397
+        $subscription->renew();
398
+        wpinv_error_log( 'Subscription renewed.', false );
399 399
 
400
-	}
400
+    }
401 401
 
402
-	/**
403
-	 * Handles subscription cancelations.
404
-	 *
405
-	 * @param WPInv_Invoice $invoice  Invoice object.
406
-	 */
407
-	protected function ipn_txn_subscr_cancel( $invoice ) {
402
+    /**
403
+     * Handles subscription cancelations.
404
+     *
405
+     * @param WPInv_Invoice $invoice  Invoice object.
406
+     */
407
+    protected function ipn_txn_subscr_cancel( $invoice ) {
408 408
 
409
-		// Make sure the invoice has a subscription.
410
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
411
-
412
-		if ( empty( $subscription ) ) {
413
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
414
-		}
415
-
416
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
417
-		$subscription->cancel();
418
-		wpinv_error_log( 'Subscription cancelled.', false );
409
+        // Make sure the invoice has a subscription.
410
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
411
+
412
+        if ( empty( $subscription ) ) {
413
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
414
+        }
415
+
416
+        wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
417
+        $subscription->cancel();
418
+        wpinv_error_log( 'Subscription cancelled.', false );
419 419
 
420
-	}
420
+    }
421 421
 
422
-	/**
423
-	 * Handles subscription completions.
424
-	 *
425
-	 * @param WPInv_Invoice $invoice  Invoice object.
426
-	 * @param array    $posted Posted data.
427
-	 */
428
-	protected function ipn_txn_subscr_eot( $invoice ) {
422
+    /**
423
+     * Handles subscription completions.
424
+     *
425
+     * @param WPInv_Invoice $invoice  Invoice object.
426
+     * @param array    $posted Posted data.
427
+     */
428
+    protected function ipn_txn_subscr_eot( $invoice ) {
429 429
 
430
-		// Make sure the invoice has a subscription.
431
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
430
+        // Make sure the invoice has a subscription.
431
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
432 432
 
433
-		if ( empty( $subscription ) ) {
434
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
435
-		}
433
+        if ( empty( $subscription ) ) {
434
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
435
+        }
436 436
 
437
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
438
-		$subscription->complete();
439
-		wpinv_error_log( 'Subscription completed.', false );
437
+        wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
438
+        $subscription->complete();
439
+        wpinv_error_log( 'Subscription completed.', false );
440 440
 
441
-	}
441
+    }
442 442
 
443
-	/**
444
-	 * Handles subscription fails.
445
-	 *
446
-	 * @param WPInv_Invoice $invoice  Invoice object.
447
-	 * @param array    $posted Posted data.
448
-	 */
449
-	protected function ipn_txn_subscr_failed( $invoice ) {
443
+    /**
444
+     * Handles subscription fails.
445
+     *
446
+     * @param WPInv_Invoice $invoice  Invoice object.
447
+     * @param array    $posted Posted data.
448
+     */
449
+    protected function ipn_txn_subscr_failed( $invoice ) {
450 450
 
451
-		// Make sure the invoice has a subscription.
452
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
451
+        // Make sure the invoice has a subscription.
452
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
453 453
 
454
-		if ( empty( $subscription ) ) {
455
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
456
-		}
454
+        if ( empty( $subscription ) ) {
455
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
456
+        }
457 457
 
458
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
459
-		$subscription->failing();
460
-		wpinv_error_log( 'Subscription marked as failing.', false );
458
+        wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
459
+        $subscription->failing();
460
+        wpinv_error_log( 'Subscription marked as failing.', false );
461 461
 
462
-	}
462
+    }
463 463
 
464
-	/**
465
-	 * Handles subscription suspensions.
466
-	 *
467
-	 * @param WPInv_Invoice $invoice  Invoice object.
468
-	 * @param array    $posted Posted data.
469
-	 */
470
-	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
464
+    /**
465
+     * Handles subscription suspensions.
466
+     *
467
+     * @param WPInv_Invoice $invoice  Invoice object.
468
+     * @param array    $posted Posted data.
469
+     */
470
+    protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
471 471
 
472
-		// Make sure the invoice has a subscription.
473
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
472
+        // Make sure the invoice has a subscription.
473
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
474 474
 
475
-		if ( empty( $subscription ) ) {
476
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
477
-		}
478
-
479
-		wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
480
-		$subscription->cancel();
481
-		wpinv_error_log( 'Subscription cancelled.', false );
482
-	}
475
+        if ( empty( $subscription ) ) {
476
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
477
+        }
478
+
479
+        wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
480
+        $subscription->cancel();
481
+        wpinv_error_log( 'Subscription cancelled.', false );
482
+    }
483 483
 
484 484
 }
Please login to merge, or discard this patch.
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Paypal Payment Gateway IPN handler class.
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param GetPaid_Paypal_Gateway $gateway
33 33
 	 */
34
-	public function __construct( $gateway ) {
34
+	public function __construct($gateway) {
35 35
 		$this->gateway = $gateway;
36 36
 		$this->verify_ipn();
37 37
 	}
@@ -43,37 +43,37 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function verify_ipn() {
45 45
 
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
46
+		wpinv_error_log('GetPaid PayPal IPN Handler', false);
47 47
 
48 48
 		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
49
+		if (empty($_POST) || !$this->validate_ipn()) {
50
+			wp_die('PayPal IPN Request Failure', 500);
51 51
 		}
52 52
 
53 53
 		// Process the IPN.
54
-		$posted  = wp_unslash( $_POST );
55
-		$invoice = $this->get_ipn_invoice( $posted );
54
+		$posted  = wp_unslash($_POST);
55
+		$invoice = $this->get_ipn_invoice($posted);
56 56
 
57 57
 		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 200 );
58
+		if ($this->id != $invoice->get_gateway()) {
59
+			wpinv_error_log('Aborting, Invoice was not paid via PayPal', false);
60
+			wp_die('Invoice not paid via PayPal', 200);
61 61
 		}
62 62
 
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
63
+		$posted['payment_status'] = isset($posted['payment_status']) ? sanitize_key(strtolower($posted['payment_status'])) : '';
64
+		$posted['txn_type']       = sanitize_key(strtolower($posted['txn_type']));
65 65
 
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
66
+		wpinv_error_log('Payment status:' . $posted['payment_status'], false);
67
+		wpinv_error_log('IPN Type:' . $posted['txn_type'], false);
68 68
 
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
69
+		if (method_exists($this, 'ipn_txn_' . $posted['txn_type'])) {
70
+			call_user_func(array($this, 'ipn_txn_' . $posted['txn_type']), $invoice, $posted);
71
+			wpinv_error_log('Done processing IPN', false);
72
+			wp_die('Processed', 200);
73 73
 		}
74 74
 
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
75
+		wpinv_error_log('Aborting, Unsupported IPN type:' . $posted['txn_type'], false);
76
+		wp_die('Unsupported IPN type', 200);
77 77
 
78 78
 	}
79 79
 
@@ -83,21 +83,21 @@  discard block
 block discarded – undo
83 83
 	 * @param array $posted
84 84
 	 * @return WPInv_Invoice
85 85
 	 */
86
-	protected function get_ipn_invoice( $posted ) {
86
+	protected function get_ipn_invoice($posted) {
87 87
 
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
88
+		wpinv_error_log('Retrieving PayPal IPN Response Invoice', false);
89 89
 
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
90
+		if (!empty($posted['custom'])) {
91
+			$invoice = new WPInv_Invoice($posted['custom']);
92 92
 
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
93
+			if ($invoice->exists()) {
94
+				wpinv_error_log('Found invoice #' . $invoice->get_number(), false);
95 95
 				return $invoice;
96 96
 			}
97 97
 		}
98 98
 
99
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
100
-		wp_die( 'Could not retrieve the associated invoice.', 200 );
99
+		wpinv_error_log('Could not retrieve the associated invoice.', false);
100
+		wp_die('Could not retrieve the associated invoice.', 200);
101 101
 	}
102 102
 
103 103
 	/**
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	protected function validate_ipn() {
107 107
 
108
-		wpinv_error_log( 'Validating PayPal IPN response', false );
108
+		wpinv_error_log('Validating PayPal IPN response', false);
109 109
 
110 110
 		// Retrieve the associated invoice.
111
-		$posted  = wp_unslash( $_POST );
112
-		$invoice = $this->get_ipn_invoice( $posted );
111
+		$posted  = wp_unslash($_POST);
112
+		$invoice = $this->get_ipn_invoice($posted);
113 113
 
114
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
115
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
114
+		if ($this->gateway->is_sandbox($invoice)) {
115
+			wpinv_error_log($posted, 'Invoice was processed in sandbox hence logging the posted data', false);
116 116
 		}
117 117
 
118 118
 		// Validate the IPN.
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 		);
130 130
 
131 131
 		// Post back to get a response.
132
-		$response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
132
+		$response = wp_safe_remote_post($this->gateway->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params);
133 133
 
134 134
 		// Check to see if the request was valid.
135
-		if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
136
-			wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
135
+		if (!is_wp_error($response) && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED')) {
136
+			wpinv_error_log('Received valid response from PayPal IPN: ' . $response['body'], false);
137 137
 			return true;
138 138
 		}
139 139
 
140
-		if ( is_wp_error( $response ) ) {
141
-			wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
140
+		if (is_wp_error($response)) {
141
+			wpinv_error_log($response->get_error_message(), 'Received invalid response from PayPal IPN');
142 142
 			return false;
143 143
 		}
144 144
 
145
-		wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
145
+		wpinv_error_log($response['body'], 'Received invalid response from PayPal IPN');
146 146
 		return false;
147 147
 
148 148
 	}
@@ -153,17 +153,17 @@  discard block
 block discarded – undo
153 153
 	 * @param WPInv_Invoice $invoice          Invoice object.
154 154
 	 * @param string   $currency currency to validate.
155 155
 	 */
156
-	protected function validate_ipn_currency( $invoice, $currency ) {
156
+	protected function validate_ipn_currency($invoice, $currency) {
157 157
 
158
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
158
+		if (strtolower($invoice->get_currency()) !== strtolower($currency)) {
159 159
 
160 160
 			/* translators: %s: currency code. */
161
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
161
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal currencies do not match (code %s).', 'invoicing'), $currency));
162 162
 
163
-			wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
163
+			wpinv_error_log("Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true);
164 164
 		}
165 165
 
166
-		wpinv_error_log( $currency, 'Validated IPN Currency', false );
166
+		wpinv_error_log($currency, 'Validated IPN Currency', false);
167 167
 	}
168 168
 
169 169
 	/**
@@ -172,16 +172,16 @@  discard block
 block discarded – undo
172 172
 	 * @param WPInv_Invoice $invoice          Invoice object.
173 173
 	 * @param float   $amount amount to validate.
174 174
 	 */
175
-	protected function validate_ipn_amount( $invoice, $amount ) {
176
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
175
+	protected function validate_ipn_amount($invoice, $amount) {
176
+		if (number_format($invoice->get_total(), 2, '.', '') !== number_format($amount, 2, '.', '')) {
177 177
 
178 178
 			/* translators: %s: Amount. */
179
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
179
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal amounts do not match (gross %s).', 'invoicing'), $amount));
180 180
 
181
-			wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
181
+			wpinv_error_log("Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true);
182 182
 		}
183 183
 
184
-		wpinv_error_log( $amount, 'Validated IPN Amount', false );
184
+		wpinv_error_log($amount, 'Validated IPN Amount', false);
185 185
 	}
186 186
 
187 187
 	/**
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
 	 * @param WPInv_Invoice $invoice          Invoice object.
191 191
 	 * @param string   $receiver_email Email to validate.
192 192
 	 */
193
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
194
-		$paypal_email = wpinv_get_option( 'paypal_email' );
193
+	protected function validate_ipn_receiver_email($invoice, $receiver_email) {
194
+		$paypal_email = wpinv_get_option('paypal_email');
195 195
 
196
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
197
-			wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
196
+		if (strcasecmp(trim($receiver_email), trim($paypal_email)) !== 0) {
197
+			wpinv_record_gateway_error('IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}");
198 198
 
199 199
 			/* translators: %s: email address . */
200
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
200
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal IPN response from a different email address (%s).', 'invoicing'), $receiver_email));
201 201
 
202
-			return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
202
+			return wpinv_error_log("IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true);
203 203
 		}
204 204
 
205
-		wpinv_error_log( 'Validated PayPal Email', false );
205
+		wpinv_error_log('Validated PayPal Email', false);
206 206
 	}
207 207
 
208 208
 	/**
@@ -211,70 +211,70 @@  discard block
 block discarded – undo
211 211
 	 * @param WPInv_Invoice $invoice  Invoice object.
212 212
 	 * @param array    $posted Posted data.
213 213
 	 */
214
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
214
+	protected function ipn_txn_web_accept($invoice, $posted) {
215 215
 
216 216
 		// Collect payment details
217
-		$payment_status = strtolower( $posted['payment_status'] );
218
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
217
+		$payment_status = strtolower($posted['payment_status']);
218
+		$business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']);
219 219
 
220
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
221
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
220
+		$this->validate_ipn_receiver_email($invoice, $business_email);
221
+		$this->validate_ipn_currency($invoice, $posted['mc_currency']);
222 222
 
223 223
 		// Update the transaction id.
224
-		if ( ! empty( $posted['txn_id'] ) ) {
225
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
224
+		if (!empty($posted['txn_id'])) {
225
+			$invoice->set_transaction_id(wpinv_clean($posted['txn_id']));
226 226
 			$invoice->save();
227 227
 		}
228 228
 
229
-		$invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
229
+		$invoice->add_system_note(__('Processing invoice IPN', 'invoicing'));
230 230
 
231 231
 		// Process a refund.
232
-		if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
232
+		if ($payment_status == 'refunded' || $payment_status == 'reversed') {
233 233
 
234
-			update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
234
+			update_post_meta($invoice->get_id(), 'refunded_remotely', 1);
235 235
 
236
-			if ( ! $invoice->is_refunded() ) {
237
-				$invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
236
+			if (!$invoice->is_refunded()) {
237
+				$invoice->update_status('wpi-refunded', $posted['reason_code']);
238 238
 			}
239 239
 
240
-			return wpinv_error_log( $posted['reason_code'], false );
240
+			return wpinv_error_log($posted['reason_code'], false);
241 241
 		}
242 242
 
243 243
 		// Process payments.
244
-		if ( $payment_status == 'completed' ) {
244
+		if ($payment_status == 'completed') {
245 245
 
246
-			if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
247
-				return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
246
+			if ($invoice->is_paid() && 'wpi_processing' != $invoice->get_status()) {
247
+				return wpinv_error_log('Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false);
248 248
 			}
249 249
 
250
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
250
+			$this->validate_ipn_amount($invoice, $posted['mc_gross']);
251 251
 
252 252
 			$note = '';
253 253
 
254
-			if ( ! empty( $posted['mc_fee'] ) ) {
255
-				$note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
254
+			if (!empty($posted['mc_fee'])) {
255
+				$note = sprintf(__('PayPal Transaction Fee %s.', 'invoicing'), sanitize_text_field($posted['mc_fee']));
256 256
 			}
257 257
 
258
-			if ( ! empty( $posted['payer_status'] ) ) {
259
-				$note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
258
+			if (!empty($posted['payer_status'])) {
259
+				$note = ' ' . sprintf(__('Buyer status %s.', 'invoicing'), sanitize_text_field($posted['payer_status']));
260 260
 			}
261 261
 
262
-			$invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
263
-			return wpinv_error_log( 'Invoice marked as paid.', false );
262
+			$invoice->mark_paid((!empty($posted['txn_id']) ? sanitize_text_field($posted['txn_id']) : ''), trim($note));
263
+			return wpinv_error_log('Invoice marked as paid.', false);
264 264
 
265 265
 		}
266 266
 
267 267
 		// Pending payments.
268
-		if ( $payment_status == 'pending' ) {
268
+		if ($payment_status == 'pending') {
269 269
 
270 270
 			/* translators: %s: pending reason. */
271
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
271
+			$invoice->update_status('wpi-onhold', sprintf(__('Payment pending (%s).', 'invoicing'), $posted['pending_reason']));
272 272
 
273
-			return wpinv_error_log( 'Invoice marked as "payment held".', false );
273
+			return wpinv_error_log('Invoice marked as "payment held".', false);
274 274
 		}
275 275
 
276 276
 		/* translators: %s: payment status. */
277
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
277
+		$invoice->update_status('wpi-failed', sprintf(__('Payment %s via IPN.', 'invoicing'), sanitize_text_field($posted['payment_status'])));
278 278
 
279 279
 	}
280 280
 
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 	 * @param WPInv_Invoice $invoice  Invoice object.
285 285
 	 * @param array    $posted Posted data.
286 286
 	 */
287
-	protected function ipn_txn_cart( $invoice, $posted ) {
288
-		$this->ipn_txn_web_accept( $invoice, $posted );
287
+	protected function ipn_txn_cart($invoice, $posted) {
288
+		$this->ipn_txn_web_accept($invoice, $posted);
289 289
 	}
290 290
 
291 291
 	/**
@@ -294,43 +294,43 @@  discard block
 block discarded – undo
294 294
 	 * @param WPInv_Invoice $invoice  Invoice object.
295 295
 	 * @param array    $posted Posted data.
296 296
 	 */
297
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
297
+	protected function ipn_txn_subscr_signup($invoice, $posted) {
298 298
 
299
-		wpinv_error_log( 'Processing subscription signup', false );
299
+		wpinv_error_log('Processing subscription signup', false);
300 300
 
301 301
 		// Make sure the invoice has a subscription.
302
-		$subscription = getpaid_get_invoice_subscription( $invoice );
302
+		$subscription = getpaid_get_invoice_subscription($invoice);
303 303
 
304
-		if ( empty( $subscription ) ) {
305
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
304
+		if (empty($subscription)) {
305
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
306 306
 		}
307 307
 
308
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
308
+		wpinv_error_log('Found subscription #' . $subscription->get_id(), false);
309 309
 
310 310
 		// Validate the IPN.
311
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
312
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
313
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
311
+		$business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']);
312
+		$this->validate_ipn_receiver_email($invoice, $business_email);
313
+		$this->validate_ipn_currency($invoice, $posted['mc_currency']);
314 314
 
315 315
 		// Activate the subscription.
316
-		$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
317
-		$subscription->set_date_created( current_time( 'mysql' ) );
318
-		$subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
319
-		$subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
316
+		$duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
317
+		$subscription->set_date_created(current_time('mysql'));
318
+		$subscription->set_expiration(date('Y-m-d H:i:s', (current_time('timestamp') + $duration)));
319
+		$subscription->set_profile_id(sanitize_text_field($posted['subscr_id']));
320 320
 		$subscription->activate();
321 321
 
322 322
 		// Set the transaction id.
323
-		if ( ! empty( $posted['txn_id'] ) ) {
324
-			$invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
325
-			$invoice->set_transaction_id( $posted['txn_id'] );
323
+		if (!empty($posted['txn_id'])) {
324
+			$invoice->add_note(sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true);
325
+			$invoice->set_transaction_id($posted['txn_id']);
326 326
 		}
327 327
 
328 328
 		// Update the payment status.
329 329
 		$invoice->mark_paid();
330 330
 
331
-		$invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
331
+		$invoice->add_note(sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
332 332
 
333
-		wpinv_error_log( 'Subscription started.', false );
333
+		wpinv_error_log('Subscription started.', false);
334 334
 	}
335 335
 
336 336
 	/**
@@ -339,45 +339,45 @@  discard block
 block discarded – undo
339 339
 	 * @param WPInv_Invoice $invoice  Invoice object.
340 340
 	 * @param array    $posted Posted data.
341 341
 	 */
342
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
342
+	protected function ipn_txn_subscr_payment($invoice, $posted) {
343 343
 
344 344
 		// Make sure the invoice has a subscription.
345
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
345
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
346 346
 
347
-		if ( empty( $subscription ) ) {
348
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
347
+		if (empty($subscription)) {
348
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
349 349
 		}
350 350
 
351
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
351
+		wpinv_error_log('Found subscription #' . $subscription->get_id(), false);
352 352
 
353 353
 		// PayPal sends a subscr_payment for the first payment too.
354
-		$date_completed = getpaid_format_date( $invoice->get_date_completed() );
355
-		$date_created   = getpaid_format_date( $invoice->get_date_created() );
356
-		$today_date     = getpaid_format_date( current_time( 'mysql' ) );
357
-		$payment_date   = getpaid_format_date( $posted['payment_date'] );
358
-		$subscribe_date = getpaid_format_date( $subscription->get_date_created() );
359
-		$dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
354
+		$date_completed = getpaid_format_date($invoice->get_date_completed());
355
+		$date_created   = getpaid_format_date($invoice->get_date_created());
356
+		$today_date     = getpaid_format_date(current_time('mysql'));
357
+		$payment_date   = getpaid_format_date($posted['payment_date']);
358
+		$subscribe_date = getpaid_format_date($subscription->get_date_created());
359
+		$dates          = array_filter(compact('date_completed', 'date_created', 'subscribe_date'));
360 360
 
361
-		foreach ( $dates as $date ) {
361
+		foreach ($dates as $date) {
362 362
 
363
-			if ( $date !== $today_date && $date !== $payment_date ) {
363
+			if ($date !== $today_date && $date !== $payment_date) {
364 364
 				continue;
365 365
 			}
366 366
 
367
-			if ( ! empty( $posted['txn_id'] ) ) {
368
-				$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
369
-				$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
367
+			if (!empty($posted['txn_id'])) {
368
+				$invoice->set_transaction_id(sanitize_text_field($posted['txn_id']));
369
+				$invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), sanitize_text_field($posted['txn_id'])), false, false, true);
370 370
 			}
371 371
 
372 372
 			return $invoice->mark_paid();
373 373
 
374 374
 		}
375 375
 
376
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
376
+		wpinv_error_log('Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false);
377 377
 
378 378
 		// Abort if the payment is already recorded.
379
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
380
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false );
379
+		if (wpinv_get_id_by_transaction_id($posted['txn_id'])) {
380
+			return wpinv_error_log('Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false);
381 381
 		}
382 382
 
383 383
 		$args = array(
@@ -385,17 +385,17 @@  discard block
 block discarded – undo
385 385
 			'gateway'        => $this->id,
386 386
 		);
387 387
 
388
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
388
+		$invoice = wpinv_get_invoice($subscription->add_payment($args));
389 389
 
390
-		if ( empty( $invoice ) ) {
390
+		if (empty($invoice)) {
391 391
 			return;
392 392
 		}
393 393
 
394
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
395
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
394
+		$invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true);
395
+		$invoice->add_note(wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
396 396
 
397 397
 		$subscription->renew();
398
-		wpinv_error_log( 'Subscription renewed.', false );
398
+		wpinv_error_log('Subscription renewed.', false);
399 399
 
400 400
 	}
401 401
 
@@ -404,18 +404,18 @@  discard block
 block discarded – undo
404 404
 	 *
405 405
 	 * @param WPInv_Invoice $invoice  Invoice object.
406 406
 	 */
407
-	protected function ipn_txn_subscr_cancel( $invoice ) {
407
+	protected function ipn_txn_subscr_cancel($invoice) {
408 408
 
409 409
 		// Make sure the invoice has a subscription.
410
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
410
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
411 411
 
412
-		if ( empty( $subscription ) ) {
413
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
412
+		if (empty($subscription)) {
413
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
414 414
 		}
415 415
 
416
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
416
+		wpinv_error_log('Processing subscription cancellation for the invoice ' . $invoice->get_id(), false);
417 417
 		$subscription->cancel();
418
-		wpinv_error_log( 'Subscription cancelled.', false );
418
+		wpinv_error_log('Subscription cancelled.', false);
419 419
 
420 420
 	}
421 421
 
@@ -425,18 +425,18 @@  discard block
 block discarded – undo
425 425
 	 * @param WPInv_Invoice $invoice  Invoice object.
426 426
 	 * @param array    $posted Posted data.
427 427
 	 */
428
-	protected function ipn_txn_subscr_eot( $invoice ) {
428
+	protected function ipn_txn_subscr_eot($invoice) {
429 429
 
430 430
 		// Make sure the invoice has a subscription.
431
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
431
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
432 432
 
433
-		if ( empty( $subscription ) ) {
434
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
433
+		if (empty($subscription)) {
434
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
435 435
 		}
436 436
 
437
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
437
+		wpinv_error_log('Processing subscription end of life for the invoice ' . $invoice->get_id(), false);
438 438
 		$subscription->complete();
439
-		wpinv_error_log( 'Subscription completed.', false );
439
+		wpinv_error_log('Subscription completed.', false);
440 440
 
441 441
 	}
442 442
 
@@ -446,18 +446,18 @@  discard block
 block discarded – undo
446 446
 	 * @param WPInv_Invoice $invoice  Invoice object.
447 447
 	 * @param array    $posted Posted data.
448 448
 	 */
449
-	protected function ipn_txn_subscr_failed( $invoice ) {
449
+	protected function ipn_txn_subscr_failed($invoice) {
450 450
 
451 451
 		// Make sure the invoice has a subscription.
452
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
452
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
453 453
 
454
-		if ( empty( $subscription ) ) {
455
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
454
+		if (empty($subscription)) {
455
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
456 456
 		}
457 457
 
458
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
458
+		wpinv_error_log('Processing subscription payment failure for the invoice ' . $invoice->get_id(), false);
459 459
 		$subscription->failing();
460
-		wpinv_error_log( 'Subscription marked as failing.', false );
460
+		wpinv_error_log('Subscription marked as failing.', false);
461 461
 
462 462
 	}
463 463
 
@@ -467,18 +467,18 @@  discard block
 block discarded – undo
467 467
 	 * @param WPInv_Invoice $invoice  Invoice object.
468 468
 	 * @param array    $posted Posted data.
469 469
 	 */
470
-	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
470
+	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment($invoice) {
471 471
 
472 472
 		// Make sure the invoice has a subscription.
473
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
473
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
474 474
 
475
-		if ( empty( $subscription ) ) {
476
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
475
+		if (empty($subscription)) {
476
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
477 477
 		}
478 478
 
479
-		wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
479
+		wpinv_error_log('Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false);
480 480
 		$subscription->cancel();
481
-		wpinv_error_log( 'Subscription cancelled.', false );
481
+		wpinv_error_log('Subscription cancelled.', false);
482 482
 	}
483 483
 
484 484
 }
Please login to merge, or discard this patch.
includes/subscription-functions.php 2 patches
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
  */
51 51
 function getpaid_get_invoice_subscription_group( $invoice_id, $subscription_id ) {
52 52
     $subscription_groups = getpaid_get_invoice_subscription_groups( $invoice_id );
53
-	$matching_group      = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
53
+    $matching_group      = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
54 54
     return reset( $matching_group );
55 55
 }
56 56
 
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
  */
64 64
 function getpaid_get_subscription( $subscription ) {
65 65
 
66
-	if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) {
67
-		$subscription = new WPInv_Subscription( $subscription );
68
-	}
66
+    if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) {
67
+        $subscription = new WPInv_Subscription( $subscription );
68
+    }
69 69
 
70
-	return $subscription->exists() ? $subscription : false;
70
+    return $subscription->exists() ? $subscription : false;
71 71
 }
72 72
 
73 73
 /**
@@ -81,28 +81,28 @@  discard block
 block discarded – undo
81 81
  */
82 82
 function getpaid_get_subscriptions( $args = array(), $return = 'results' ) {
83 83
 
84
-	// Do not retrieve all fields if we just want the count.
85
-	if ( 'count' == $return ) {
86
-		$args['fields'] = 'id';
87
-		$args['number'] = 1;
88
-	}
84
+    // Do not retrieve all fields if we just want the count.
85
+    if ( 'count' == $return ) {
86
+        $args['fields'] = 'id';
87
+        $args['number'] = 1;
88
+    }
89 89
 
90
-	// Do not count all matches if we just want the results.
91
-	if ( 'results' == $return ) {
92
-		$args['count_total'] = false;
93
-	}
90
+    // Do not count all matches if we just want the results.
91
+    if ( 'results' == $return ) {
92
+        $args['count_total'] = false;
93
+    }
94 94
 
95
-	$query = new GetPaid_Subscriptions_Query( $args );
95
+    $query = new GetPaid_Subscriptions_Query( $args );
96 96
 
97
-	if ( 'results' == $return ) {
98
-		return $query->get_results();
99
-	}
97
+    if ( 'results' == $return ) {
98
+        return $query->get_results();
99
+    }
100 100
 
101
-	if ( 'count' == $return ) {
102
-		return $query->get_total();
103
-	}
101
+    if ( 'count' == $return ) {
102
+        return $query->get_total();
103
+    }
104 104
 
105
-	return $query;
105
+    return $query;
106 106
 }
107 107
 
108 108
 /**
@@ -112,18 +112,18 @@  discard block
 block discarded – undo
112 112
  */
113 113
 function getpaid_get_subscription_statuses() {
114 114
 
115
-	return apply_filters(
116
-		'getpaid_get_subscription_statuses',
117
-		array(
118
-			'pending'   => __( 'Pending', 'invoicing' ),
119
-			'trialling' => __( 'Trialing', 'invoicing' ),
120
-			'active'    => __( 'Active', 'invoicing' ),
121
-			'failing'   => __( 'Failing', 'invoicing' ),
122
-			'expired'   => __( 'Expired', 'invoicing' ),
123
-			'completed' => __( 'Complete', 'invoicing' ),
124
-			'cancelled' => __( 'Cancelled', 'invoicing' ),
125
-		)
126
-	);
115
+    return apply_filters(
116
+        'getpaid_get_subscription_statuses',
117
+        array(
118
+            'pending'   => __( 'Pending', 'invoicing' ),
119
+            'trialling' => __( 'Trialing', 'invoicing' ),
120
+            'active'    => __( 'Active', 'invoicing' ),
121
+            'failing'   => __( 'Failing', 'invoicing' ),
122
+            'expired'   => __( 'Expired', 'invoicing' ),
123
+            'completed' => __( 'Complete', 'invoicing' ),
124
+            'cancelled' => __( 'Cancelled', 'invoicing' ),
125
+        )
126
+    );
127 127
 
128 128
 }
129 129
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
  * @return string
134 134
  */
135 135
 function getpaid_get_subscription_status_label( $status ) {
136
-	$statuses = getpaid_get_subscription_statuses();
137
-	return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) );
136
+    $statuses = getpaid_get_subscription_statuses();
137
+    return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) );
138 138
 }
139 139
 
140 140
 /**
@@ -144,18 +144,18 @@  discard block
 block discarded – undo
144 144
  */
145 145
 function getpaid_get_subscription_status_classes() {
146 146
 
147
-	return apply_filters(
148
-		'getpaid_get_subscription_status_classes',
149
-		array(
150
-			'pending'   => 'badge-dark',
151
-			'trialling' => 'badge-info',
152
-			'active'    => 'badge-success',
153
-			'failing'   => 'badge-warning',
154
-			'expired'   => 'badge-danger',
155
-			'completed' => 'badge-primary',
156
-			'cancelled' => 'badge-secondary',
157
-		)
158
-	);
147
+    return apply_filters(
148
+        'getpaid_get_subscription_status_classes',
149
+        array(
150
+            'pending'   => 'badge-dark',
151
+            'trialling' => 'badge-info',
152
+            'active'    => 'badge-success',
153
+            'failing'   => 'badge-warning',
154
+            'expired'   => 'badge-danger',
155
+            'completed' => 'badge-primary',
156
+            'cancelled' => 'badge-secondary',
157
+        )
158
+    );
159 159
 
160 160
 }
161 161
 
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
  */
167 167
 function getpaid_get_subscription_status_counts( $args = array() ) {
168 168
 
169
-	$statuses = array_keys( getpaid_get_subscription_statuses() );
170
-	$counts   = array();
169
+    $statuses = array_keys( getpaid_get_subscription_statuses() );
170
+    $counts   = array();
171 171
 
172
-	foreach ( $statuses as $status ) {
173
-		$_args             = wp_parse_args( "status=$status", $args );
174
-		$counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' );
175
-	}
172
+    foreach ( $statuses as $status ) {
173
+        $_args             = wp_parse_args( "status=$status", $args );
174
+        $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' );
175
+    }
176 176
 
177
-	return $counts;
177
+    return $counts;
178 178
 
179 179
 }
180 180
 
@@ -185,32 +185,32 @@  discard block
 block discarded – undo
185 185
  */
186 186
 function getpaid_get_subscription_periods() {
187 187
 
188
-	return apply_filters(
189
-		'getpaid_get_subscription_periods',
190
-		array(
188
+    return apply_filters(
189
+        'getpaid_get_subscription_periods',
190
+        array(
191 191
 
192
-			'day'   => array(
193
-				'singular' => __( '%s day', 'invoicing' ),
194
-				'plural'   => __( '%d days', 'invoicing' ),
195
-			),
192
+            'day'   => array(
193
+                'singular' => __( '%s day', 'invoicing' ),
194
+                'plural'   => __( '%d days', 'invoicing' ),
195
+            ),
196 196
 
197
-			'week'  => array(
198
-				'singular' => __( '%s week', 'invoicing' ),
199
-				'plural'   => __( '%d weeks', 'invoicing' ),
200
-			),
197
+            'week'  => array(
198
+                'singular' => __( '%s week', 'invoicing' ),
199
+                'plural'   => __( '%d weeks', 'invoicing' ),
200
+            ),
201 201
 
202
-			'month' => array(
203
-				'singular' => __( '%s month', 'invoicing' ),
204
-				'plural'   => __( '%d months', 'invoicing' ),
205
-			),
202
+            'month' => array(
203
+                'singular' => __( '%s month', 'invoicing' ),
204
+                'plural'   => __( '%d months', 'invoicing' ),
205
+            ),
206 206
 
207
-			'year'  => array(
208
-				'singular' => __( '%s year', 'invoicing' ),
209
-				'plural'   => __( '%d years', 'invoicing' ),
210
-			),
207
+            'year'  => array(
208
+                'singular' => __( '%s year', 'invoicing' ),
209
+                'plural'   => __( '%d years', 'invoicing' ),
210
+            ),
211 211
 
212
-		)
213
-	);
212
+        )
213
+    );
214 214
 
215 215
 }
216 216
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
  * @return int
222 222
  */
223 223
 function getpaid_get_subscription_trial_period_interval( $trial_period ) {
224
-	return (int) preg_replace( '/[^0-9]/', '', $trial_period );
224
+    return (int) preg_replace( '/[^0-9]/', '', $trial_period );
225 225
 }
226 226
 
227 227
 /**
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
  * @return string
232 232
  */
233 233
 function getpaid_get_subscription_trial_period_period( $trial_period ) {
234
-	return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) );
234
+    return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) );
235 235
 }
236 236
 
237 237
 /**
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
  * @return string
243 243
  */
244 244
 function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) {
245
-	$label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix );
246
-	return strtolower( sanitize_text_field( $label ) );
245
+    $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix );
246
+    return strtolower( sanitize_text_field( $label ) );
247 247
 }
248 248
 
249 249
 /**
@@ -254,22 +254,22 @@  discard block
 block discarded – undo
254 254
  */
255 255
 function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) {
256 256
 
257
-	$periods = getpaid_get_subscription_periods();
258
-	$period  = strtolower( $period );
257
+    $periods = getpaid_get_subscription_periods();
258
+    $period  = strtolower( $period );
259 259
 
260
-	if ( isset( $periods[ $period ] ) ) {
261
-		return sprintf( $periods[ $period ]['singular'], $singular_prefix );
262
-	}
260
+    if ( isset( $periods[ $period ] ) ) {
261
+        return sprintf( $periods[ $period ]['singular'], $singular_prefix );
262
+    }
263 263
 
264
-	// Backwards compatibility.
265
-	foreach ( $periods as $key => $data ) {
266
-		if ( strpos( $key, $period ) === 0 ) {
267
-			return sprintf( $data['singular'], $singular_prefix );
268
-		}
269
-	}
264
+    // Backwards compatibility.
265
+    foreach ( $periods as $key => $data ) {
266
+        if ( strpos( $key, $period ) === 0 ) {
267
+            return sprintf( $data['singular'], $singular_prefix );
268
+        }
269
+    }
270 270
 
271
-	// Invalid string.
272
-	return '';
271
+    // Invalid string.
272
+    return '';
273 273
 }
274 274
 
275 275
 /**
@@ -281,22 +281,22 @@  discard block
 block discarded – undo
281 281
  */
282 282
 function getpaid_get_plural_subscription_period_label( $period, $interval ) {
283 283
 
284
-	$periods = getpaid_get_subscription_periods();
285
-	$period  = strtolower( $period );
284
+    $periods = getpaid_get_subscription_periods();
285
+    $period  = strtolower( $period );
286 286
 
287
-	if ( isset( $periods[ $period ] ) ) {
288
-		return sprintf( $periods[ $period ]['plural'], $interval );
289
-	}
287
+    if ( isset( $periods[ $period ] ) ) {
288
+        return sprintf( $periods[ $period ]['plural'], $interval );
289
+    }
290 290
 
291
-	// Backwards compatibility.
292
-	foreach ( $periods as $key => $data ) {
293
-		if ( strpos( $key, $period ) === 0 ) {
294
-			return sprintf( $data['plural'], $interval );
295
-		}
296
-	}
291
+    // Backwards compatibility.
292
+    foreach ( $periods as $key => $data ) {
293
+        if ( strpos( $key, $period ) === 0 ) {
294
+            return sprintf( $data['plural'], $interval );
295
+        }
296
+    }
297 297
 
298
-	// Invalid string.
299
-	return '';
298
+    // Invalid string.
299
+    return '';
300 300
 }
301 301
 
302 302
 /**
@@ -307,92 +307,92 @@  discard block
 block discarded – undo
307 307
  */
308 308
 function getpaid_get_formatted_subscription_amount( $subscription ) {
309 309
 
310
-	$initial    = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
311
-	$recurring  = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
312
-	$period     = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
313
-	$bill_times = $subscription->get_bill_times();
314
-	$bill_times_less = $bill_times - 1;
315
-
316
-	if ( ! empty( $bill_times ) ) {
317
-		$bill_times = $subscription->get_frequency() * $bill_times;
318
-		$bill_times_less = getpaid_get_subscription_period_label( $subscription->get_frequency(), $bill_times - $subscription->get_frequency() );
319
-		$bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times );
320
-	}
321
-
322
-	// Trial periods.
323
-	if ( $subscription->has_trial_period() ) {
324
-
325
-		$trial_period   = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() );
326
-		$trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() );
327
-
328
-		if ( empty( $bill_times ) ) {
329
-
330
-			return sprintf(
331
-				// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
332
-				_x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
333
-				$initial,
334
-				getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
335
-				$recurring,
336
-				$period
337
-			);
338
-
339
-		}
340
-
341
-		return sprintf(
342
-			// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times
343
-			_x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ),
344
-			$initial,
345
-			getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
346
-			$recurring,
347
-			$period,
348
-			$bill_times
349
-		);
350
-
351
-	}
352
-
353
-	if ( $initial != $recurring ) {
354
-
355
-		if ( empty( $bill_times ) ) {
356
-
357
-			return sprintf(
358
-				// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period
359
-				_x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ),
360
-				$initial,
361
-				$recurring,
362
-				$period
363
-			);
364
-
365
-		}
366
-
367
-		return sprintf(
368
-			// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times
369
-			_x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ),
370
-			$initial,
371
-			$recurring,
372
-			$period,
373
-			$bill_times_less
374
-		);
375
-
376
-	}
377
-
378
-	if ( empty( $bill_times ) ) {
379
-
380
-		return sprintf(
381
-			// translators: $1: is the recurring amount, $2: is the recurring period
382
-			_x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ),
383
-			$initial,
384
-			$period
385
-		);
386
-
387
-	}
388
-
389
-	return sprintf(
390
-		// translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period
391
-		_x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
392
-		$bill_times,
393
-		$initial,
394
-		$period
395
-	);
310
+    $initial    = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
311
+    $recurring  = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
312
+    $period     = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
313
+    $bill_times = $subscription->get_bill_times();
314
+    $bill_times_less = $bill_times - 1;
315
+
316
+    if ( ! empty( $bill_times ) ) {
317
+        $bill_times = $subscription->get_frequency() * $bill_times;
318
+        $bill_times_less = getpaid_get_subscription_period_label( $subscription->get_frequency(), $bill_times - $subscription->get_frequency() );
319
+        $bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times );
320
+    }
321
+
322
+    // Trial periods.
323
+    if ( $subscription->has_trial_period() ) {
324
+
325
+        $trial_period   = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() );
326
+        $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() );
327
+
328
+        if ( empty( $bill_times ) ) {
329
+
330
+            return sprintf(
331
+                // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
332
+                _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
333
+                $initial,
334
+                getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
335
+                $recurring,
336
+                $period
337
+            );
338
+
339
+        }
340
+
341
+        return sprintf(
342
+            // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times
343
+            _x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ),
344
+            $initial,
345
+            getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
346
+            $recurring,
347
+            $period,
348
+            $bill_times
349
+        );
350
+
351
+    }
352
+
353
+    if ( $initial != $recurring ) {
354
+
355
+        if ( empty( $bill_times ) ) {
356
+
357
+            return sprintf(
358
+                // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period
359
+                _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ),
360
+                $initial,
361
+                $recurring,
362
+                $period
363
+            );
364
+
365
+        }
366
+
367
+        return sprintf(
368
+            // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times
369
+            _x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ),
370
+            $initial,
371
+            $recurring,
372
+            $period,
373
+            $bill_times_less
374
+        );
375
+
376
+    }
377
+
378
+    if ( empty( $bill_times ) ) {
379
+
380
+        return sprintf(
381
+            // translators: $1: is the recurring amount, $2: is the recurring period
382
+            _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ),
383
+            $initial,
384
+            $period
385
+        );
386
+
387
+    }
388
+
389
+    return sprintf(
390
+        // translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period
391
+        _x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
392
+        $bill_times,
393
+        $initial,
394
+        $period
395
+    );
396 396
 
397 397
 }
398 398
 
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
  * @return WPInv_Subscription|false
404 404
  */
405 405
 function getpaid_get_invoice_subscription( $invoice ) {
406
-	return getpaid_subscriptions()->get_invoice_subscription( $invoice );
406
+    return getpaid_subscriptions()->get_invoice_subscription( $invoice );
407 407
 }
408 408
 
409 409
 /**
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
  * @param WPInv_Invoice $invoice
413 413
  */
414 414
 function getpaid_activate_invoice_subscription( $invoice ) {
415
-	$subscription = getpaid_get_invoice_subscription( $invoice );
416
-	if ( is_a( $subscription, 'WPInv_Subscription' ) ) {
417
-		$subscription->activate();
418
-	}
415
+    $subscription = getpaid_get_invoice_subscription( $invoice );
416
+    if ( is_a( $subscription, 'WPInv_Subscription' ) ) {
417
+        $subscription->activate();
418
+    }
419 419
 }
420 420
 
421 421
 /**
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
  * @return WPInv_Subscriptions
425 425
  */
426 426
 function getpaid_subscriptions() {
427
-	return getpaid()->get( 'subscriptions' );
427
+    return getpaid()->get( 'subscriptions' );
428 428
 }
429 429
 
430 430
 /**
@@ -443,15 +443,15 @@  discard block
 block discarded – undo
443 443
         return false;
444 444
     }
445 445
 
446
-	// Fetch the invoice subscription.
447
-	$subscription = getpaid_get_subscriptions(
448
-		array(
449
-			'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(),
450
-			'number'     => 1,
451
-		)
452
-	);
446
+    // Fetch the invoice subscription.
447
+    $subscription = getpaid_get_subscriptions(
448
+        array(
449
+            'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(),
450
+            'number'     => 1,
451
+        )
452
+    );
453 453
 
454
-	return empty( $subscription ) ? false : $subscription[0];
454
+    return empty( $subscription ) ? false : $subscription[0];
455 455
 
456 456
 }
457 457
 
@@ -468,48 +468,48 @@  discard block
 block discarded – undo
468 468
  */
469 469
 function getpaid_get_recurring_item_key( $cart_item ) {
470 470
 
471
-	$cart_key     = 'renews_';
472
-	$interval     = $cart_item->get_recurring_interval();
473
-	$period       = $cart_item->get_recurring_period( true );
474
-	$length       = $cart_item->get_recurring_limit() * $interval;
475
-	$trial_period = $cart_item->get_trial_period( true );
476
-	$trial_length = $cart_item->get_trial_interval();
477
-
478
-	// First start with the billing interval and period
479
-	switch ( $interval ) {
480
-		case 1:
481
-			if ( 'day' == $period ) {
482
-				$cart_key .= 'daily';
483
-			} else {
484
-				$cart_key .= sprintf( '%sly', $period );
485
-			}
486
-			break;
487
-		case 2:
488
-			$cart_key .= sprintf( 'every_2nd_%s', $period );
489
-			break;
490
-		case 3:
491
-			$cart_key .= sprintf( 'every_3rd_%s', $period );
492
-		    break;
493
-		default:
494
-			$cart_key .= sprintf( 'every_%dth_%s', $interval, $period );
495
-			break;
496
-	}
497
-
498
-	// Maybe add the optional maximum billing periods...
499
-	if ( $length > 0 ) {
500
-		$cart_key .= '_for_';
501
-		$cart_key .= sprintf( '%d_%s', $length, $period );
502
-		if ( $length > 1 ) {
503
-			$cart_key .= 's';
504
-		}
505
-	}
506
-
507
-	// And an optional free trial.
508
-	if ( $cart_item->has_free_trial() ) {
509
-		$cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period );
510
-	}
511
-
512
-	return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item );
471
+    $cart_key     = 'renews_';
472
+    $interval     = $cart_item->get_recurring_interval();
473
+    $period       = $cart_item->get_recurring_period( true );
474
+    $length       = $cart_item->get_recurring_limit() * $interval;
475
+    $trial_period = $cart_item->get_trial_period( true );
476
+    $trial_length = $cart_item->get_trial_interval();
477
+
478
+    // First start with the billing interval and period
479
+    switch ( $interval ) {
480
+        case 1:
481
+            if ( 'day' == $period ) {
482
+                $cart_key .= 'daily';
483
+            } else {
484
+                $cart_key .= sprintf( '%sly', $period );
485
+            }
486
+            break;
487
+        case 2:
488
+            $cart_key .= sprintf( 'every_2nd_%s', $period );
489
+            break;
490
+        case 3:
491
+            $cart_key .= sprintf( 'every_3rd_%s', $period );
492
+            break;
493
+        default:
494
+            $cart_key .= sprintf( 'every_%dth_%s', $interval, $period );
495
+            break;
496
+    }
497
+
498
+    // Maybe add the optional maximum billing periods...
499
+    if ( $length > 0 ) {
500
+        $cart_key .= '_for_';
501
+        $cart_key .= sprintf( '%d_%s', $length, $period );
502
+        if ( $length > 1 ) {
503
+            $cart_key .= 's';
504
+        }
505
+    }
506
+
507
+    // And an optional free trial.
508
+    if ( $cart_item->has_free_trial() ) {
509
+        $cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period );
510
+    }
511
+
512
+    return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item );
513 513
 }
514 514
 
515 515
 /**
@@ -520,16 +520,16 @@  discard block
 block discarded – undo
520 520
  */
521 521
 function getpaid_get_subscription_groups( $invoice ) {
522 522
 
523
-	// Generate subscription groups.
524
-	$subscription_groups = array();
525
-	foreach ( $invoice->get_items() as $item ) {
523
+    // Generate subscription groups.
524
+    $subscription_groups = array();
525
+    foreach ( $invoice->get_items() as $item ) {
526 526
 
527
-		if ( $item->is_recurring() ) {
528
-			$subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item;
529
-		}
527
+        if ( $item->is_recurring() ) {
528
+            $subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item;
529
+        }
530 530
 }
531 531
 
532
-	return $subscription_groups;
532
+    return $subscription_groups;
533 533
 }
534 534
 
535 535
 /**
@@ -543,56 +543,56 @@  discard block
 block discarded – undo
543 543
  */
544 544
 function getpaid_calculate_subscription_totals( $invoice ) {
545 545
 
546
-	// Generate subscription groups.
547
-	$subscription_groups = getpaid_get_subscription_groups( $invoice );
546
+    // Generate subscription groups.
547
+    $subscription_groups = getpaid_get_subscription_groups( $invoice );
548 548
 
549
-	// Now let's calculate the totals for each group of subscriptions
550
-	$subscription_totals = array();
549
+    // Now let's calculate the totals for each group of subscriptions
550
+    $subscription_totals = array();
551 551
 
552
-	foreach ( $subscription_groups as $subscription_key => $items ) {
552
+    foreach ( $subscription_groups as $subscription_key => $items ) {
553 553
 
554
-		if ( empty( $subscription_totals[ $subscription_key ] ) ) {
554
+        if ( empty( $subscription_totals[ $subscription_key ] ) ) {
555 555
 
556
-			$subscription_totals[ $subscription_key ] = array(
557
-				'initial_total'   => 0,
558
-				'recurring_total' => 0,
559
-				'items'           => array(),
560
-				'trialling'       => false,
561
-			);
556
+            $subscription_totals[ $subscription_key ] = array(
557
+                'initial_total'   => 0,
558
+                'recurring_total' => 0,
559
+                'items'           => array(),
560
+                'trialling'       => false,
561
+            );
562 562
 
563
-		}
563
+        }
564 564
 
565
-		/**
566
-		 * Get the totals of the group.
567
-		 * @var GetPaid_Form_Item $item
568
-		 */
569
-		foreach ( $items as $item ) {
565
+        /**
566
+         * Get the totals of the group.
567
+         * @var GetPaid_Form_Item $item
568
+         */
569
+        foreach ( $items as $item ) {
570 570
 
571
-			$subscription_totals[ $subscription_key ]['items'][ $item->get_id() ]  = $item->prepare_data_for_saving();
572
-			$subscription_totals[ $subscription_key ]['item_id']                 = $item->get_id();
573
-			$subscription_totals[ $subscription_key ]['period']                  = $item->get_recurring_period( true );
574
-			$subscription_totals[ $subscription_key ]['interval']                = $item->get_recurring_interval();
575
-			$subscription_totals[ $subscription_key ]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
-			$subscription_totals[ $subscription_key ]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
-			$subscription_totals[ $subscription_key ]['recurring_limit']         = $item->get_recurring_limit();
571
+            $subscription_totals[ $subscription_key ]['items'][ $item->get_id() ]  = $item->prepare_data_for_saving();
572
+            $subscription_totals[ $subscription_key ]['item_id']                 = $item->get_id();
573
+            $subscription_totals[ $subscription_key ]['period']                  = $item->get_recurring_period( true );
574
+            $subscription_totals[ $subscription_key ]['interval']                = $item->get_recurring_interval();
575
+            $subscription_totals[ $subscription_key ]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
+            $subscription_totals[ $subscription_key ]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
+            $subscription_totals[ $subscription_key ]['recurring_limit']         = $item->get_recurring_limit();
578 578
 
579
-			// Calculate the next renewal date.
580
-			$period       = $item->get_recurring_period( true );
581
-			$interval     = $item->get_recurring_interval();
579
+            // Calculate the next renewal date.
580
+            $period       = $item->get_recurring_period( true );
581
+            $interval     = $item->get_recurring_interval();
582 582
 
583
-			// If the subscription item has a trial period...
584
-			if ( $item->has_free_trial() ) {
585
-				$period   = $item->get_trial_period( true );
586
-				$interval = $item->get_trial_interval();
587
-				$subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period;
588
-			}
583
+            // If the subscription item has a trial period...
584
+            if ( $item->has_free_trial() ) {
585
+                $period   = $item->get_trial_period( true );
586
+                $interval = $item->get_trial_interval();
587
+                $subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period;
588
+            }
589 589
 
590
-			$subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) );
590
+            $subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) );
591 591
 
592
-		}
592
+        }
593 593
 }
594 594
 
595
-	return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice );
595
+    return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice );
596 596
 }
597 597
 
598 598
 /**
@@ -603,16 +603,16 @@  discard block
 block discarded – undo
603 603
  */
604 604
 function getpaid_should_group_subscriptions( $invoice ) {
605 605
 
606
-	$recurring_items = 0;
606
+    $recurring_items = 0;
607 607
 
608
-	foreach ( $invoice->get_items() as $item ) {
608
+    foreach ( $invoice->get_items() as $item ) {
609 609
 
610
-		if ( $item->is_recurring() ) {
611
-			$recurring_items ++;
612
-		}
610
+        if ( $item->is_recurring() ) {
611
+            $recurring_items ++;
612
+        }
613 613
 }
614 614
 
615
-	return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice );
615
+    return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice );
616 616
 }
617 617
 
618 618
 /**
@@ -623,39 +623,39 @@  discard block
 block discarded – undo
623 623
  * @return int
624 624
  */
625 625
 function getpaid_count_subscription_invoices( $parent_invoice_id, $subscription_id = false ) {
626
-	global $wpdb;
626
+    global $wpdb;
627 627
 
628
-	$parent_invoice_id = (int) $parent_invoice_id;
628
+    $parent_invoice_id = (int) $parent_invoice_id;
629 629
 
630
-	if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) {
630
+    if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) {
631 631
 
632
-		return (int) $wpdb->get_var(
633
-			$wpdb->prepare(
634
-				"SELECT COUNT(ID) FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
635
-				$parent_invoice_id,
636
-				$parent_invoice_id
637
-			)
638
-		);
632
+        return (int) $wpdb->get_var(
633
+            $wpdb->prepare(
634
+                "SELECT COUNT(ID) FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
635
+                $parent_invoice_id,
636
+                $parent_invoice_id
637
+            )
638
+        );
639 639
 
640
-	}
640
+    }
641 641
 
642
-	$invoice_ids = $wpdb->get_col(
643
-		$wpdb->prepare(
644
-			"SELECT ID FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
645
-			$parent_invoice_id,
646
-			$parent_invoice_id
647
-		)
648
-	);
642
+    $invoice_ids = $wpdb->get_col(
643
+        $wpdb->prepare(
644
+            "SELECT ID FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
645
+            $parent_invoice_id,
646
+            $parent_invoice_id
647
+        )
648
+    );
649 649
 
650
-	$count = 0;
650
+    $count = 0;
651 651
 
652
-	foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) {
652
+    foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) {
653 653
 
654
-		if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) {
655
-			$count ++;
656
-			continue;
657
-		}
654
+        if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) {
655
+            $count ++;
656
+            continue;
657
+        }
658 658
 }
659 659
 
660
-	return $count;
660
+    return $count;
661 661
 }
Please login to merge, or discard this patch.
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@  discard block
 block discarded – undo
13 13
  * @return      WPInv_Subscription[]|WPInv_Subscription|false
14 14
  * @since       2.3.0
15 15
  */
16
-function getpaid_get_invoice_subscriptions( $invoice ) {
16
+function getpaid_get_invoice_subscriptions($invoice) {
17 17
 
18 18
     // Retrieve subscription groups.
19
-    $subscription_ids = wp_list_pluck( getpaid_get_invoice_subscription_groups( $invoice->get_id() ), 'subscription_id' );
19
+    $subscription_ids = wp_list_pluck(getpaid_get_invoice_subscription_groups($invoice->get_id()), 'subscription_id');
20 20
 
21 21
     // No subscription groups, normal subscription.
22
-    if ( empty( $subscription_ids ) ) {
23
-        return getpaid_subscriptions()->get_invoice_subscription( $invoice );
22
+    if (empty($subscription_ids)) {
23
+        return getpaid_subscriptions()->get_invoice_subscription($invoice);
24 24
     }
25 25
 
26 26
     // Subscription groups.
27
-    return array_filter( array_map( 'getpaid_get_subscription', $subscription_ids ) );
27
+    return array_filter(array_map('getpaid_get_subscription', $subscription_ids));
28 28
 
29 29
 }
30 30
 
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
  * @return      array
36 36
  * @since       2.3.0
37 37
  */
38
-function getpaid_get_invoice_subscription_groups( $invoice_id ) {
39
-    $subscription_groups = get_post_meta( $invoice_id, 'getpaid_subscription_groups', true );
40
-    return empty( $subscription_groups ) ? array() : $subscription_groups;
38
+function getpaid_get_invoice_subscription_groups($invoice_id) {
39
+    $subscription_groups = get_post_meta($invoice_id, 'getpaid_subscription_groups', true);
40
+    return empty($subscription_groups) ? array() : $subscription_groups;
41 41
 }
42 42
 
43 43
 /**
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
  * @return      array|false
49 49
  * @since       2.3.0
50 50
  */
51
-function getpaid_get_invoice_subscription_group( $invoice_id, $subscription_id ) {
52
-    $subscription_groups = getpaid_get_invoice_subscription_groups( $invoice_id );
53
-	$matching_group      = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
54
-    return reset( $matching_group );
51
+function getpaid_get_invoice_subscription_group($invoice_id, $subscription_id) {
52
+    $subscription_groups = getpaid_get_invoice_subscription_groups($invoice_id);
53
+	$matching_group = wp_list_filter($subscription_groups, compact('subscription_id'));
54
+    return reset($matching_group);
55 55
 }
56 56
 
57 57
 /**
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
  * @since       2.3.0
62 62
  * @return WPInv_Subscription|false
63 63
  */
64
-function getpaid_get_subscription( $subscription ) {
64
+function getpaid_get_subscription($subscription) {
65 65
 
66
-	if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) {
67
-		$subscription = new WPInv_Subscription( $subscription );
66
+	if (!is_a($subscription, 'WPInv_Subscription')) {
67
+		$subscription = new WPInv_Subscription($subscription);
68 68
 	}
69 69
 
70 70
 	return $subscription->exists() ? $subscription : false;
@@ -79,26 +79,26 @@  discard block
 block discarded – undo
79 79
  *
80 80
  * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query
81 81
  */
82
-function getpaid_get_subscriptions( $args = array(), $return = 'results' ) {
82
+function getpaid_get_subscriptions($args = array(), $return = 'results') {
83 83
 
84 84
 	// Do not retrieve all fields if we just want the count.
85
-	if ( 'count' == $return ) {
85
+	if ('count' == $return) {
86 86
 		$args['fields'] = 'id';
87 87
 		$args['number'] = 1;
88 88
 	}
89 89
 
90 90
 	// Do not count all matches if we just want the results.
91
-	if ( 'results' == $return ) {
91
+	if ('results' == $return) {
92 92
 		$args['count_total'] = false;
93 93
 	}
94 94
 
95
-	$query = new GetPaid_Subscriptions_Query( $args );
95
+	$query = new GetPaid_Subscriptions_Query($args);
96 96
 
97
-	if ( 'results' == $return ) {
97
+	if ('results' == $return) {
98 98
 		return $query->get_results();
99 99
 	}
100 100
 
101
-	if ( 'count' == $return ) {
101
+	if ('count' == $return) {
102 102
 		return $query->get_total();
103 103
 	}
104 104
 
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 	return apply_filters(
116 116
 		'getpaid_get_subscription_statuses',
117 117
 		array(
118
-			'pending'   => __( 'Pending', 'invoicing' ),
119
-			'trialling' => __( 'Trialing', 'invoicing' ),
120
-			'active'    => __( 'Active', 'invoicing' ),
121
-			'failing'   => __( 'Failing', 'invoicing' ),
122
-			'expired'   => __( 'Expired', 'invoicing' ),
123
-			'completed' => __( 'Complete', 'invoicing' ),
124
-			'cancelled' => __( 'Cancelled', 'invoicing' ),
118
+			'pending'   => __('Pending', 'invoicing'),
119
+			'trialling' => __('Trialing', 'invoicing'),
120
+			'active'    => __('Active', 'invoicing'),
121
+			'failing'   => __('Failing', 'invoicing'),
122
+			'expired'   => __('Expired', 'invoicing'),
123
+			'completed' => __('Complete', 'invoicing'),
124
+			'cancelled' => __('Cancelled', 'invoicing'),
125 125
 		)
126 126
 	);
127 127
 
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return string
134 134
  */
135
-function getpaid_get_subscription_status_label( $status ) {
135
+function getpaid_get_subscription_status_label($status) {
136 136
 	$statuses = getpaid_get_subscription_statuses();
137
-	return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) );
137
+	return isset($statuses[$status]) ? $statuses[$status] : ucfirst(sanitize_text_field($status));
138 138
 }
139 139
 
140 140
 /**
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
  *
165 165
  * @return array
166 166
  */
167
-function getpaid_get_subscription_status_counts( $args = array() ) {
167
+function getpaid_get_subscription_status_counts($args = array()) {
168 168
 
169
-	$statuses = array_keys( getpaid_get_subscription_statuses() );
169
+	$statuses = array_keys(getpaid_get_subscription_statuses());
170 170
 	$counts   = array();
171 171
 
172
-	foreach ( $statuses as $status ) {
173
-		$_args             = wp_parse_args( "status=$status", $args );
174
-		$counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' );
172
+	foreach ($statuses as $status) {
173
+		$_args             = wp_parse_args("status=$status", $args);
174
+		$counts[$status] = getpaid_get_subscriptions($_args, 'count');
175 175
 	}
176 176
 
177 177
 	return $counts;
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
 		array(
191 191
 
192 192
 			'day'   => array(
193
-				'singular' => __( '%s day', 'invoicing' ),
194
-				'plural'   => __( '%d days', 'invoicing' ),
193
+				'singular' => __('%s day', 'invoicing'),
194
+				'plural'   => __('%d days', 'invoicing'),
195 195
 			),
196 196
 
197 197
 			'week'  => array(
198
-				'singular' => __( '%s week', 'invoicing' ),
199
-				'plural'   => __( '%d weeks', 'invoicing' ),
198
+				'singular' => __('%s week', 'invoicing'),
199
+				'plural'   => __('%d weeks', 'invoicing'),
200 200
 			),
201 201
 
202 202
 			'month' => array(
203
-				'singular' => __( '%s month', 'invoicing' ),
204
-				'plural'   => __( '%d months', 'invoicing' ),
203
+				'singular' => __('%s month', 'invoicing'),
204
+				'plural'   => __('%d months', 'invoicing'),
205 205
 			),
206 206
 
207 207
 			'year'  => array(
208
-				'singular' => __( '%s year', 'invoicing' ),
209
-				'plural'   => __( '%d years', 'invoicing' ),
208
+				'singular' => __('%s year', 'invoicing'),
209
+				'plural'   => __('%d years', 'invoicing'),
210 210
 			),
211 211
 
212 212
 		)
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
  * @param string $trial_period
221 221
  * @return int
222 222
  */
223
-function getpaid_get_subscription_trial_period_interval( $trial_period ) {
224
-	return (int) preg_replace( '/[^0-9]/', '', $trial_period );
223
+function getpaid_get_subscription_trial_period_interval($trial_period) {
224
+	return (int) preg_replace('/[^0-9]/', '', $trial_period);
225 225
 }
226 226
 
227 227
 /**
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
  * @param string $trial_period
231 231
  * @return string
232 232
  */
233
-function getpaid_get_subscription_trial_period_period( $trial_period ) {
234
-	return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) );
233
+function getpaid_get_subscription_trial_period_period($trial_period) {
234
+	return preg_replace('/[^a-z]/', '', strtolower($trial_period));
235 235
 }
236 236
 
237 237
 /**
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
  * @param int $interval
242 242
  * @return string
243 243
  */
244
-function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) {
245
-	$label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix );
246
-	return strtolower( sanitize_text_field( $label ) );
244
+function getpaid_get_subscription_period_label($period, $interval = 1, $singular_prefix = '1') {
245
+	$label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label($period, $interval) : getpaid_get_singular_subscription_period_label($period, $singular_prefix);
246
+	return strtolower(sanitize_text_field($label));
247 247
 }
248 248
 
249 249
 /**
@@ -252,19 +252,19 @@  discard block
 block discarded – undo
252 252
  * @param string $period
253 253
  * @return string
254 254
  */
255
-function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) {
255
+function getpaid_get_singular_subscription_period_label($period, $singular_prefix = '1') {
256 256
 
257 257
 	$periods = getpaid_get_subscription_periods();
258
-	$period  = strtolower( $period );
258
+	$period  = strtolower($period);
259 259
 
260
-	if ( isset( $periods[ $period ] ) ) {
261
-		return sprintf( $periods[ $period ]['singular'], $singular_prefix );
260
+	if (isset($periods[$period])) {
261
+		return sprintf($periods[$period]['singular'], $singular_prefix);
262 262
 	}
263 263
 
264 264
 	// Backwards compatibility.
265
-	foreach ( $periods as $key => $data ) {
266
-		if ( strpos( $key, $period ) === 0 ) {
267
-			return sprintf( $data['singular'], $singular_prefix );
265
+	foreach ($periods as $key => $data) {
266
+		if (strpos($key, $period) === 0) {
267
+			return sprintf($data['singular'], $singular_prefix);
268 268
 		}
269 269
 	}
270 270
 
@@ -279,19 +279,19 @@  discard block
 block discarded – undo
279 279
  * @param int $interval
280 280
  * @return string
281 281
  */
282
-function getpaid_get_plural_subscription_period_label( $period, $interval ) {
282
+function getpaid_get_plural_subscription_period_label($period, $interval) {
283 283
 
284 284
 	$periods = getpaid_get_subscription_periods();
285
-	$period  = strtolower( $period );
285
+	$period  = strtolower($period);
286 286
 
287
-	if ( isset( $periods[ $period ] ) ) {
288
-		return sprintf( $periods[ $period ]['plural'], $interval );
287
+	if (isset($periods[$period])) {
288
+		return sprintf($periods[$period]['plural'], $interval);
289 289
 	}
290 290
 
291 291
 	// Backwards compatibility.
292
-	foreach ( $periods as $key => $data ) {
293
-		if ( strpos( $key, $period ) === 0 ) {
294
-			return sprintf( $data['plural'], $interval );
292
+	foreach ($periods as $key => $data) {
293
+		if (strpos($key, $period) === 0) {
294
+			return sprintf($data['plural'], $interval);
295 295
 		}
296 296
 	}
297 297
 
@@ -305,33 +305,33 @@  discard block
 block discarded – undo
305 305
  * @param WPInv_Subscription $subscription
306 306
  * @return string
307 307
  */
308
-function getpaid_get_formatted_subscription_amount( $subscription ) {
308
+function getpaid_get_formatted_subscription_amount($subscription) {
309 309
 
310
-	$initial    = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
311
-	$recurring  = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
312
-	$period     = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
310
+	$initial    = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency());
311
+	$recurring  = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency());
312
+	$period     = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), '');
313 313
 	$bill_times = $subscription->get_bill_times();
314 314
 	$bill_times_less = $bill_times - 1;
315 315
 
316
-	if ( ! empty( $bill_times ) ) {
316
+	if (!empty($bill_times)) {
317 317
 		$bill_times = $subscription->get_frequency() * $bill_times;
318
-		$bill_times_less = getpaid_get_subscription_period_label( $subscription->get_frequency(), $bill_times - $subscription->get_frequency() );
319
-		$bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times );
318
+		$bill_times_less = getpaid_get_subscription_period_label($subscription->get_frequency(), $bill_times - $subscription->get_frequency());
319
+		$bill_times = getpaid_get_subscription_period_label($subscription->get_period(), $bill_times);
320 320
 	}
321 321
 
322 322
 	// Trial periods.
323
-	if ( $subscription->has_trial_period() ) {
323
+	if ($subscription->has_trial_period()) {
324 324
 
325
-		$trial_period   = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() );
326
-		$trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() );
325
+		$trial_period   = getpaid_get_subscription_trial_period_period($subscription->get_trial_period());
326
+		$trial_interval = getpaid_get_subscription_trial_period_interval($subscription->get_trial_period());
327 327
 
328
-		if ( empty( $bill_times ) ) {
328
+		if (empty($bill_times)) {
329 329
 
330 330
 			return sprintf(
331 331
 				// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
332
-				_x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
332
+				_x('%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'),
333 333
 				$initial,
334
-				getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
334
+				getpaid_get_subscription_period_label($trial_period, $trial_interval),
335 335
 				$recurring,
336 336
 				$period
337 337
 			);
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
 
341 341
 		return sprintf(
342 342
 			// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times
343
-			_x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ),
343
+			_x('%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing'),
344 344
 			$initial,
345
-			getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
345
+			getpaid_get_subscription_period_label($trial_period, $trial_interval),
346 346
 			$recurring,
347 347
 			$period,
348 348
 			$bill_times
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 
351 351
 	}
352 352
 
353
-	if ( $initial != $recurring ) {
353
+	if ($initial != $recurring) {
354 354
 
355
-		if ( empty( $bill_times ) ) {
355
+		if (empty($bill_times)) {
356 356
 
357 357
 			return sprintf(
358 358
 				// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period
359
-				_x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ),
359
+				_x('Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing'),
360 360
 				$initial,
361 361
 				$recurring,
362 362
 				$period
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 
367 367
 		return sprintf(
368 368
 			// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times
369
-			_x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ),
369
+			_x('Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing'),
370 370
 			$initial,
371 371
 			$recurring,
372 372
 			$period,
@@ -375,11 +375,11 @@  discard block
 block discarded – undo
375 375
 
376 376
 	}
377 377
 
378
-	if ( empty( $bill_times ) ) {
378
+	if (empty($bill_times)) {
379 379
 
380 380
 		return sprintf(
381 381
 			// translators: $1: is the recurring amount, $2: is the recurring period
382
-			_x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ),
382
+			_x('%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing'),
383 383
 			$initial,
384 384
 			$period
385 385
 		);
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 
389 389
 	return sprintf(
390 390
 		// translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period
391
-		_x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
391
+		_x('%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'),
392 392
 		$bill_times,
393 393
 		$initial,
394 394
 		$period
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
  * @param WPInv_Invoice $invoice
403 403
  * @return WPInv_Subscription|false
404 404
  */
405
-function getpaid_get_invoice_subscription( $invoice ) {
406
-	return getpaid_subscriptions()->get_invoice_subscription( $invoice );
405
+function getpaid_get_invoice_subscription($invoice) {
406
+	return getpaid_subscriptions()->get_invoice_subscription($invoice);
407 407
 }
408 408
 
409 409
 /**
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
  *
412 412
  * @param WPInv_Invoice $invoice
413 413
  */
414
-function getpaid_activate_invoice_subscription( $invoice ) {
415
-	$subscription = getpaid_get_invoice_subscription( $invoice );
416
-	if ( is_a( $subscription, 'WPInv_Subscription' ) ) {
414
+function getpaid_activate_invoice_subscription($invoice) {
415
+	$subscription = getpaid_get_invoice_subscription($invoice);
416
+	if (is_a($subscription, 'WPInv_Subscription')) {
417 417
 		$subscription->activate();
418 418
 	}
419 419
 }
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
  * @return WPInv_Subscriptions
425 425
  */
426 426
 function getpaid_subscriptions() {
427
-	return getpaid()->get( 'subscriptions' );
427
+	return getpaid()->get('subscriptions');
428 428
 }
429 429
 
430 430
 /**
@@ -433,13 +433,13 @@  discard block
 block discarded – undo
433 433
  * @since 2.3.0
434 434
  * @return WPInv_Subscription|bool
435 435
  */
436
-function wpinv_get_invoice_subscription( $invoice ) {
436
+function wpinv_get_invoice_subscription($invoice) {
437 437
 
438 438
     // Retrieve the invoice.
439
-    $invoice = new WPInv_Invoice( $invoice );
439
+    $invoice = new WPInv_Invoice($invoice);
440 440
 
441 441
     // Ensure it is a recurring invoice.
442
-    if ( ! $invoice->is_recurring() ) {
442
+    if (!$invoice->is_recurring()) {
443 443
         return false;
444 444
     }
445 445
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 		)
452 452
 	);
453 453
 
454
-	return empty( $subscription ) ? false : $subscription[0];
454
+	return empty($subscription) ? false : $subscription[0];
455 455
 
456 456
 }
457 457
 
@@ -466,50 +466,50 @@  discard block
 block discarded – undo
466 466
  * @param GetPaid_Form_Item|WPInv_Item $cart_item
467 467
  * @return string
468 468
  */
469
-function getpaid_get_recurring_item_key( $cart_item ) {
469
+function getpaid_get_recurring_item_key($cart_item) {
470 470
 
471 471
 	$cart_key     = 'renews_';
472 472
 	$interval     = $cart_item->get_recurring_interval();
473
-	$period       = $cart_item->get_recurring_period( true );
473
+	$period       = $cart_item->get_recurring_period(true);
474 474
 	$length       = $cart_item->get_recurring_limit() * $interval;
475
-	$trial_period = $cart_item->get_trial_period( true );
475
+	$trial_period = $cart_item->get_trial_period(true);
476 476
 	$trial_length = $cart_item->get_trial_interval();
477 477
 
478 478
 	// First start with the billing interval and period
479
-	switch ( $interval ) {
479
+	switch ($interval) {
480 480
 		case 1:
481
-			if ( 'day' == $period ) {
481
+			if ('day' == $period) {
482 482
 				$cart_key .= 'daily';
483 483
 			} else {
484
-				$cart_key .= sprintf( '%sly', $period );
484
+				$cart_key .= sprintf('%sly', $period);
485 485
 			}
486 486
 			break;
487 487
 		case 2:
488
-			$cart_key .= sprintf( 'every_2nd_%s', $period );
488
+			$cart_key .= sprintf('every_2nd_%s', $period);
489 489
 			break;
490 490
 		case 3:
491
-			$cart_key .= sprintf( 'every_3rd_%s', $period );
491
+			$cart_key .= sprintf('every_3rd_%s', $period);
492 492
 		    break;
493 493
 		default:
494
-			$cart_key .= sprintf( 'every_%dth_%s', $interval, $period );
494
+			$cart_key .= sprintf('every_%dth_%s', $interval, $period);
495 495
 			break;
496 496
 	}
497 497
 
498 498
 	// Maybe add the optional maximum billing periods...
499
-	if ( $length > 0 ) {
499
+	if ($length > 0) {
500 500
 		$cart_key .= '_for_';
501
-		$cart_key .= sprintf( '%d_%s', $length, $period );
502
-		if ( $length > 1 ) {
501
+		$cart_key .= sprintf('%d_%s', $length, $period);
502
+		if ($length > 1) {
503 503
 			$cart_key .= 's';
504 504
 		}
505 505
 	}
506 506
 
507 507
 	// And an optional free trial.
508
-	if ( $cart_item->has_free_trial() ) {
509
-		$cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period );
508
+	if ($cart_item->has_free_trial()) {
509
+		$cart_key .= sprintf('_after_a_%d_%s_trial', $trial_length, $trial_period);
510 510
 	}
511 511
 
512
-	return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item );
512
+	return apply_filters('getpaid_get_recurring_item_key', $cart_key, $cart_item);
513 513
 }
514 514
 
515 515
 /**
@@ -518,14 +518,14 @@  discard block
 block discarded – undo
518 518
  * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice
519 519
  * @return array
520 520
  */
521
-function getpaid_get_subscription_groups( $invoice ) {
521
+function getpaid_get_subscription_groups($invoice) {
522 522
 
523 523
 	// Generate subscription groups.
524 524
 	$subscription_groups = array();
525
-	foreach ( $invoice->get_items() as $item ) {
525
+	foreach ($invoice->get_items() as $item) {
526 526
 
527
-		if ( $item->is_recurring() ) {
528
-			$subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item;
527
+		if ($item->is_recurring()) {
528
+			$subscription_groups[getpaid_get_recurring_item_key($item)][] = $item;
529 529
 		}
530 530
 }
531 531
 
@@ -541,19 +541,19 @@  discard block
 block discarded – undo
541 541
  * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice
542 542
  * @return array
543 543
  */
544
-function getpaid_calculate_subscription_totals( $invoice ) {
544
+function getpaid_calculate_subscription_totals($invoice) {
545 545
 
546 546
 	// Generate subscription groups.
547
-	$subscription_groups = getpaid_get_subscription_groups( $invoice );
547
+	$subscription_groups = getpaid_get_subscription_groups($invoice);
548 548
 
549 549
 	// Now let's calculate the totals for each group of subscriptions
550 550
 	$subscription_totals = array();
551 551
 
552
-	foreach ( $subscription_groups as $subscription_key => $items ) {
552
+	foreach ($subscription_groups as $subscription_key => $items) {
553 553
 
554
-		if ( empty( $subscription_totals[ $subscription_key ] ) ) {
554
+		if (empty($subscription_totals[$subscription_key])) {
555 555
 
556
-			$subscription_totals[ $subscription_key ] = array(
556
+			$subscription_totals[$subscription_key] = array(
557 557
 				'initial_total'   => 0,
558 558
 				'recurring_total' => 0,
559 559
 				'items'           => array(),
@@ -566,33 +566,33 @@  discard block
 block discarded – undo
566 566
 		 * Get the totals of the group.
567 567
 		 * @var GetPaid_Form_Item $item
568 568
 		 */
569
-		foreach ( $items as $item ) {
569
+		foreach ($items as $item) {
570 570
 
571
-			$subscription_totals[ $subscription_key ]['items'][ $item->get_id() ]  = $item->prepare_data_for_saving();
572
-			$subscription_totals[ $subscription_key ]['item_id']                 = $item->get_id();
573
-			$subscription_totals[ $subscription_key ]['period']                  = $item->get_recurring_period( true );
574
-			$subscription_totals[ $subscription_key ]['interval']                = $item->get_recurring_interval();
575
-			$subscription_totals[ $subscription_key ]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
-			$subscription_totals[ $subscription_key ]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
-			$subscription_totals[ $subscription_key ]['recurring_limit']         = $item->get_recurring_limit();
571
+			$subscription_totals[$subscription_key]['items'][$item->get_id()] = $item->prepare_data_for_saving();
572
+			$subscription_totals[$subscription_key]['item_id']                 = $item->get_id();
573
+			$subscription_totals[$subscription_key]['period']                  = $item->get_recurring_period(true);
574
+			$subscription_totals[$subscription_key]['interval']                = $item->get_recurring_interval();
575
+			$subscription_totals[$subscription_key]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
+			$subscription_totals[$subscription_key]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
+			$subscription_totals[$subscription_key]['recurring_limit']         = $item->get_recurring_limit();
578 578
 
579 579
 			// Calculate the next renewal date.
580
-			$period       = $item->get_recurring_period( true );
580
+			$period       = $item->get_recurring_period(true);
581 581
 			$interval     = $item->get_recurring_interval();
582 582
 
583 583
 			// If the subscription item has a trial period...
584
-			if ( $item->has_free_trial() ) {
585
-				$period   = $item->get_trial_period( true );
584
+			if ($item->has_free_trial()) {
585
+				$period   = $item->get_trial_period(true);
586 586
 				$interval = $item->get_trial_interval();
587
-				$subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period;
587
+				$subscription_totals[$subscription_key]['trialling'] = $interval . ' ' . $period;
588 588
 			}
589 589
 
590
-			$subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) );
590
+			$subscription_totals[$subscription_key]['renews_on'] = date('Y-m-d H:i:s', strtotime("+$interval $period", current_time('timestamp')));
591 591
 
592 592
 		}
593 593
 }
594 594
 
595
-	return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice );
595
+	return apply_filters('getpaid_calculate_subscription_totals', $subscription_totals, $invoice);
596 596
 }
597 597
 
598 598
 /**
@@ -601,18 +601,18 @@  discard block
 block discarded – undo
601 601
  * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice
602 602
  * @return array
603 603
  */
604
-function getpaid_should_group_subscriptions( $invoice ) {
604
+function getpaid_should_group_subscriptions($invoice) {
605 605
 
606 606
 	$recurring_items = 0;
607 607
 
608
-	foreach ( $invoice->get_items() as $item ) {
608
+	foreach ($invoice->get_items() as $item) {
609 609
 
610
-		if ( $item->is_recurring() ) {
611
-			$recurring_items ++;
610
+		if ($item->is_recurring()) {
611
+			$recurring_items++;
612 612
 		}
613 613
 }
614 614
 
615
-	return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice );
615
+	return apply_filters('getpaid_should_group_subscriptions', $recurring_items > 1, $invoice);
616 616
 }
617 617
 
618 618
 /**
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
  * @param int|false $subscription_id
623 623
  * @return int
624 624
  */
625
-function getpaid_count_subscription_invoices( $parent_invoice_id, $subscription_id = false ) {
625
+function getpaid_count_subscription_invoices($parent_invoice_id, $subscription_id = false) {
626 626
 	global $wpdb;
627 627
 
628 628
 	$parent_invoice_id = (int) $parent_invoice_id;
629 629
 
630
-	if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) {
630
+	if (false === $subscription_id || !(bool) get_post_meta($parent_invoice_id, '_wpinv_subscription_id', true)) {
631 631
 
632 632
 		return (int) $wpdb->get_var(
633 633
 			$wpdb->prepare(
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
 
650 650
 	$count = 0;
651 651
 
652
-	foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) {
652
+	foreach (wp_parse_id_list($invoice_ids) as $invoice_id) {
653 653
 
654
-		if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) {
655
-			$count ++;
654
+		if ($invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta($invoice_id, '_wpinv_subscription_id', true)) {
655
+			$count++;
656 656
 			continue;
657 657
 		}
658 658
 }
Please login to merge, or discard this patch.
includes/wpinv-item-functions.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
     $args = wp_parse_args(
58 58
         $args,
59 59
         array(
60
-			'status'     => array( 'publish' ),
61
-			'limit'      => get_option( 'posts_per_page' ),
62
-			'page'       => 1,
63
-			'exclude'    => array(),
64
-			'orderby'    => 'date',
65
-			'order'      => 'DESC',
66
-			'type'       => wpinv_item_types(),
67
-			'meta_query' => array(),
68
-			'return'     => 'objects',
69
-			'paginate'   => false,
60
+            'status'     => array( 'publish' ),
61
+            'limit'      => get_option( 'posts_per_page' ),
62
+            'page'       => 1,
63
+            'exclude'    => array(),
64
+            'orderby'    => 'date',
65
+            'order'      => 'DESC',
66
+            'type'       => wpinv_item_types(),
67
+            'meta_query' => array(),
68
+            'return'     => 'objects',
69
+            'paginate'   => false,
70 70
         )
71 71
     );
72 72
 
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 
207 207
 function wpinv_get_item_types() {
208 208
     $item_types = array(
209
-		'custom' => __( 'Standard', 'invoicing' ),
210
-		'fee'    => __( 'Fee', 'invoicing' ),
211
-	);
209
+        'custom' => __( 'Standard', 'invoicing' ),
210
+        'fee'    => __( 'Fee', 'invoicing' ),
211
+    );
212 212
     return apply_filters( 'wpinv_get_item_types', $item_types );
213 213
 }
214 214
 
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
 function wpinv_get_random_items( $num = 3, $post_ids = true ) {
250 250
     if ( $post_ids ) {
251 251
         $args = array(
252
-			'post_type'  => 'wpi_item',
253
-			'orderby'    => 'rand',
254
-			'post_count' => $num,
255
-			'fields'     => 'ids',
256
-		);
252
+            'post_type'  => 'wpi_item',
253
+            'orderby'    => 'rand',
254
+            'post_count' => $num,
255
+            'fields'     => 'ids',
256
+        );
257 257
     } else {
258 258
         $args = array(
259
-			'post_type'  => 'wpi_item',
260
-			'orderby'    => 'rand',
261
-			'post_count' => $num,
262
-		);
259
+            'post_type'  => 'wpi_item',
260
+            'orderby'    => 'rand',
261
+            'post_count' => $num,
262
+        );
263 263
     }
264 264
 
265 265
     $args  = apply_filters( 'wpinv_get_random_items', $args );
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
     $bill_times_less = $bill_times - 1;
428 428
 
429 429
     if ( ! empty( $bill_times ) ) {
430
-		$bill_times = $item->get_recurring_interval() * $bill_times;
430
+        $bill_times = $item->get_recurring_interval() * $bill_times;
431 431
         $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() );
432
-		$bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times );
433
-	}
432
+        $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times );
433
+    }
434 434
 
435 435
     if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) {
436 436
         $initial_price   = wpinv_price( $item->get_sub_total(), $currency );
Please login to merge, or discard this patch.
Spacing   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves an item by it's ID.
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
  * @param int the item ID to retrieve.
15 15
  * @return WPInv_Item|false
16 16
  */
17
-function wpinv_get_item_by_id( $id ) {
18
-    $item = wpinv_get_item( $id );
19
-    return empty( $item ) || $id != $item->get_id() ? false : $item;
17
+function wpinv_get_item_by_id($id) {
18
+    $item = wpinv_get_item($id);
19
+    return empty($item) || $id != $item->get_id() ? false : $item;
20 20
 }
21 21
 
22 22
 /**
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
  *
25 25
  * @return WPInv_Item|false
26 26
  */
27
-function wpinv_get_item_by( $field = '', $value = '', $type = '' ) {
27
+function wpinv_get_item_by($field = '', $value = '', $type = '') {
28 28
 
29
-    if ( 'id' == strtolower( $field ) ) {
30
-        return wpinv_get_item_by_id( $field );
29
+    if ('id' == strtolower($field)) {
30
+        return wpinv_get_item_by_id($field);
31 31
     }
32 32
 
33
-    $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type );
34
-    return empty( $id ) ? false : wpinv_get_item( $id );
33
+    $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type);
34
+    return empty($id) ? false : wpinv_get_item($id);
35 35
 
36 36
 }
37 37
 
@@ -41,24 +41,24 @@  discard block
 block discarded – undo
41 41
  * @param int|WPInv_Item the item to retrieve.
42 42
  * @return WPInv_Item|false
43 43
  */
44
-function wpinv_get_item( $item = 0 ) {
44
+function wpinv_get_item($item = 0) {
45 45
 
46
-    if ( empty( $item ) ) {
46
+    if (empty($item)) {
47 47
         return false;
48 48
     }
49 49
 
50
-    $item = new WPInv_Item( $item );
50
+    $item = new WPInv_Item($item);
51 51
     return $item->exists() ? $item : false;
52 52
 
53 53
 }
54 54
 
55
-function wpinv_get_all_items( $args = array() ) {
55
+function wpinv_get_all_items($args = array()) {
56 56
 
57 57
     $args = wp_parse_args(
58 58
         $args,
59 59
         array(
60
-			'status'     => array( 'publish' ),
61
-			'limit'      => get_option( 'posts_per_page' ),
60
+			'status'     => array('publish'),
61
+			'limit'      => get_option('posts_per_page'),
62 62
 			'page'       => 1,
63 63
 			'exclude'    => array(),
64 64
 			'orderby'    => 'date',
@@ -78,44 +78,44 @@  discard block
 block discarded – undo
78 78
         'fields'         => 'ids',
79 79
         'orderby'        => $args['orderby'],
80 80
         'order'          => $args['order'],
81
-        'paged'          => absint( $args['page'] ),
81
+        'paged'          => absint($args['page']),
82 82
     );
83 83
 
84
-    if ( ! empty( $args['exclude'] ) ) {
85
-        $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] );
84
+    if (!empty($args['exclude'])) {
85
+        $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']);
86 86
     }
87 87
 
88
-    if ( ! $args['paginate'] ) {
88
+    if (!$args['paginate']) {
89 89
         $wp_query_args['no_found_rows'] = true;
90 90
     }
91 91
 
92
-    if ( ! empty( $args['search'] ) ) {
92
+    if (!empty($args['search'])) {
93 93
         $wp_query_args['s'] = $args['search'];
94 94
     }
95 95
 
96
-    if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) {
97
-        $types = wpinv_parse_list( $args['type'] );
96
+    if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) {
97
+        $types = wpinv_parse_list($args['type']);
98 98
         $wp_query_args['meta_query'][] = array(
99 99
             'key'     => '_wpinv_type',
100
-            'value'   => implode( ',', $types ),
100
+            'value'   => implode(',', $types),
101 101
             'compare' => 'IN',
102 102
         );
103 103
     }
104 104
 
105
-    $wp_query_args = apply_filters( 'wpinv_get_items_args', $wp_query_args, $args );
105
+    $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args);
106 106
 
107 107
     // Get results.
108
-    $items = new WP_Query( $wp_query_args );
108
+    $items = new WP_Query($wp_query_args);
109 109
 
110
-    if ( 'objects' === $args['return'] ) {
111
-        $return = array_map( 'wpinv_get_item_by_id', $items->posts );
112
-    } elseif ( 'self' === $args['return'] ) {
110
+    if ('objects' === $args['return']) {
111
+        $return = array_map('wpinv_get_item_by_id', $items->posts);
112
+    } elseif ('self' === $args['return']) {
113 113
         return $items;
114 114
     } else {
115 115
         $return = $items->posts;
116 116
     }
117 117
 
118
-    if ( $args['paginate'] ) {
118
+    if ($args['paginate']) {
119 119
         return (object) array(
120 120
             'items'         => $return,
121 121
             'total'         => $items->found_posts,
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 
128 128
 }
129 129
 
130
-function wpinv_is_free_item( $item_id = 0 ) {
131
-    if ( empty( $item_id ) ) {
130
+function wpinv_is_free_item($item_id = 0) {
131
+    if (empty($item_id)) {
132 132
         return false;
133 133
     }
134 134
 
135
-    $item = new WPInv_Item( $item_id );
135
+    $item = new WPInv_Item($item_id);
136 136
 
137 137
     return $item->is_free();
138 138
 }
@@ -142,21 +142,21 @@  discard block
 block discarded – undo
142 142
  *
143 143
  * @param WP_Post|WPInv_Item|Int $item The item to check for.
144 144
  */
145
-function wpinv_item_is_editable( $item = 0 ) {
145
+function wpinv_item_is_editable($item = 0) {
146 146
 
147 147
     // Fetch the item.
148
-    $item = new WPInv_Item( $item );
148
+    $item = new WPInv_Item($item);
149 149
 
150 150
     // Check if it is editable.
151 151
     return $item->is_editable();
152 152
 }
153 153
 
154
-function wpinv_get_item_price( $item_id = 0 ) {
155
-    if ( empty( $item_id ) ) {
154
+function wpinv_get_item_price($item_id = 0) {
155
+    if (empty($item_id)) {
156 156
         return false;
157 157
     }
158 158
 
159
-    $item = new WPInv_Item( $item_id );
159
+    $item = new WPInv_Item($item_id);
160 160
 
161 161
     return $item->get_price();
162 162
 }
@@ -166,88 +166,88 @@  discard block
 block discarded – undo
166 166
  *
167 167
  * @param WPInv_Item|int $item
168 168
  */
169
-function wpinv_is_recurring_item( $item = 0 ) {
170
-    $item = new WPInv_Item( $item );
169
+function wpinv_is_recurring_item($item = 0) {
170
+    $item = new WPInv_Item($item);
171 171
     return $item->is_recurring();
172 172
 }
173 173
 
174
-function wpinv_item_price( $item_id = 0 ) {
175
-    if ( empty( $item_id ) ) {
174
+function wpinv_item_price($item_id = 0) {
175
+    if (empty($item_id)) {
176 176
         return false;
177 177
     }
178 178
 
179
-    $price = wpinv_get_item_price( $item_id );
180
-    $price = wpinv_price( $price );
179
+    $price = wpinv_get_item_price($item_id);
180
+    $price = wpinv_price($price);
181 181
 
182
-    return apply_filters( 'wpinv_item_price', $price, $item_id );
182
+    return apply_filters('wpinv_item_price', $price, $item_id);
183 183
 }
184 184
 
185
-function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) {
186
-    if ( is_null( $amount_override ) ) {
187
-        $original_price = get_post_meta( $item_id, '_wpinv_price', true );
185
+function wpinv_get_item_final_price($item_id = 0, $amount_override = null) {
186
+    if (is_null($amount_override)) {
187
+        $original_price = get_post_meta($item_id, '_wpinv_price', true);
188 188
     } else {
189 189
         $original_price = $amount_override;
190 190
     }
191 191
 
192 192
     $price = $original_price;
193 193
 
194
-    return apply_filters( 'wpinv_get_item_final_price', $price, $item_id );
194
+    return apply_filters('wpinv_get_item_final_price', $price, $item_id);
195 195
 }
196 196
 
197
-function wpinv_item_custom_singular_name( $item_id ) {
198
-    if ( empty( $item_id ) ) {
197
+function wpinv_item_custom_singular_name($item_id) {
198
+    if (empty($item_id)) {
199 199
         return false;
200 200
     }
201 201
 
202
-    $item = new WPInv_Item( $item_id );
202
+    $item = new WPInv_Item($item_id);
203 203
 
204 204
     return $item->get_custom_singular_name();
205 205
 }
206 206
 
207 207
 function wpinv_get_item_types() {
208 208
     $item_types = array(
209
-		'custom' => __( 'Standard', 'invoicing' ),
210
-		'fee'    => __( 'Fee', 'invoicing' ),
209
+		'custom' => __('Standard', 'invoicing'),
210
+		'fee'    => __('Fee', 'invoicing'),
211 211
 	);
212
-    return apply_filters( 'wpinv_get_item_types', $item_types );
212
+    return apply_filters('wpinv_get_item_types', $item_types);
213 213
 }
214 214
 
215 215
 function wpinv_item_types() {
216 216
     $item_types = wpinv_get_item_types();
217 217
 
218
-    return ( ! empty( $item_types ) ? array_keys( $item_types ) : array() );
218
+    return (!empty($item_types) ? array_keys($item_types) : array());
219 219
 }
220 220
 
221
-function wpinv_get_item_type( $item_id ) {
222
-    if ( empty( $item_id ) ) {
221
+function wpinv_get_item_type($item_id) {
222
+    if (empty($item_id)) {
223 223
         return false;
224 224
     }
225 225
 
226
-    $item = new WPInv_Item( $item_id );
226
+    $item = new WPInv_Item($item_id);
227 227
 
228 228
     return $item->get_type();
229 229
 }
230 230
 
231
-function wpinv_item_type( $item_id ) {
231
+function wpinv_item_type($item_id) {
232 232
     $item_types = wpinv_get_item_types();
233 233
 
234
-    $item_type = wpinv_get_item_type( $item_id );
234
+    $item_type = wpinv_get_item_type($item_id);
235 235
 
236
-    if ( empty( $item_type ) ) {
236
+    if (empty($item_type)) {
237 237
         $item_type = '-';
238 238
     }
239 239
 
240
-    $item_type = isset( $item_types[ $item_type ] ) ? $item_types[ $item_type ] : __( $item_type, 'invoicing' );
240
+    $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing');
241 241
 
242
-    return apply_filters( 'wpinv_item_type', $item_type, $item_id );
242
+    return apply_filters('wpinv_item_type', $item_type, $item_id);
243 243
 }
244 244
 
245
-function wpinv_get_random_item( $post_ids = true ) {
246
-    wpinv_get_random_items( 1, $post_ids );
245
+function wpinv_get_random_item($post_ids = true) {
246
+    wpinv_get_random_items(1, $post_ids);
247 247
 }
248 248
 
249
-function wpinv_get_random_items( $num = 3, $post_ids = true ) {
250
-    if ( $post_ids ) {
249
+function wpinv_get_random_items($num = 3, $post_ids = true) {
250
+    if ($post_ids) {
251 251
         $args = array(
252 252
 			'post_type'  => 'wpi_item',
253 253
 			'orderby'    => 'rand',
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 		);
263 263
     }
264 264
 
265
-    $args  = apply_filters( 'wpinv_get_random_items', $args );
265
+    $args = apply_filters('wpinv_get_random_items', $args);
266 266
 
267
-    return get_posts( $args );
267
+    return get_posts($args);
268 268
 }
269 269
 
270 270
 /**
@@ -273,13 +273,13 @@  discard block
 block discarded – undo
273 273
  * @param WPInv_Item|int $item
274 274
  * @param bool $html
275 275
  */
276
-function wpinv_get_item_suffix( $item, $html = true ) {
276
+function wpinv_get_item_suffix($item, $html = true) {
277 277
 
278
-    $item   = new WPInv_Item( $item );
279
-    $suffix = $item->is_recurring() ? ' ' . __( '(r)', 'invoicing' ) : '';
280
-    $suffix = $html ? $suffix : wp_strip_all_tags( $suffix );
278
+    $item   = new WPInv_Item($item);
279
+    $suffix = $item->is_recurring() ? ' ' . __('(r)', 'invoicing') : '';
280
+    $suffix = $html ? $suffix : wp_strip_all_tags($suffix);
281 281
 
282
-    return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html );
282
+    return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html);
283 283
 }
284 284
 
285 285
 /**
@@ -288,9 +288,9 @@  discard block
 block discarded – undo
288 288
  * @param WPInv_Item|int $item
289 289
  * @param bool $force_delete
290 290
  */
291
-function wpinv_remove_item( $item = 0, $force_delete = false ) {
292
-    $item = new WPInv_Item( $item );
293
-    $item->delete( $force_delete );
291
+function wpinv_remove_item($item = 0, $force_delete = false) {
292
+    $item = new WPInv_Item($item);
293
+    $item->delete($force_delete);
294 294
 }
295 295
 
296 296
 /**
@@ -329,44 +329,44 @@  discard block
 block discarded – undo
329 329
  * @param bool $wp_error whether or not to return a WP_Error on failure.
330 330
  * @return bool|WP_Error|WPInv_Item
331 331
  */
332
-function wpinv_create_item( $args = array(), $wp_error = false ) {
332
+function wpinv_create_item($args = array(), $wp_error = false) {
333 333
 
334 334
     // Prepare the item.
335
-    if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) {
336
-        $type = empty( $args['type'] ) ? 'custom' : $args['type'];
337
-        $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type );
335
+    if (!empty($args['custom_id']) && empty($args['ID'])) {
336
+        $type = empty($args['type']) ? 'custom' : $args['type'];
337
+        $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type);
338 338
 
339
-        if ( ! empty( $item ) ) {
339
+        if (!empty($item)) {
340 340
             $args['ID'] = $item->get_id();
341 341
         }
342 342
     }
343 343
 
344 344
     // Do we have an item?
345
-    if ( ! empty( $args['ID'] ) ) {
346
-        $item = new WPInv_Item( $args['ID'] );
345
+    if (!empty($args['ID'])) {
346
+        $item = new WPInv_Item($args['ID']);
347 347
     } else {
348 348
         $item = new WPInv_Item();
349 349
     }
350 350
 
351 351
     // Do we have an error?
352
-    if ( ! empty( $item->last_error ) ) {
353
-        return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false;
352
+    if (!empty($item->last_error)) {
353
+        return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false;
354 354
     }
355 355
 
356 356
     // Update item props.
357
-    $item->set_props( $args );
357
+    $item->set_props($args);
358 358
 
359 359
     // Save the item.
360 360
     $item->save();
361 361
 
362 362
     // Do we have an error?
363
-    if ( ! empty( $item->last_error ) ) {
364
-        return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false;
363
+    if (!empty($item->last_error)) {
364
+        return $wp_error ? new WP_Error('not_saved', $item->last_error) : false;
365 365
     }
366 366
 
367 367
     // Was the item saved?
368
-    if ( ! $item->get_id() ) {
369
-        return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false;
368
+    if (!$item->get_id()) {
369
+        return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false;
370 370
     }
371 371
 
372 372
     return $item;
@@ -378,14 +378,14 @@  discard block
 block discarded – undo
378 378
  *
379 379
  * @see wpinv_create_item()
380 380
  */
381
-function wpinv_update_item( $args = array(), $wp_error = false ) {
382
-    return wpinv_create_item( $args, $wp_error );
381
+function wpinv_update_item($args = array(), $wp_error = false) {
382
+    return wpinv_create_item($args, $wp_error);
383 383
 }
384 384
 
385 385
 /**
386 386
  * Sanitizes a recurring period
387 387
  */
388
-function getpaid_sanitize_recurring_period( $period, $full = false ) {
388
+function getpaid_sanitize_recurring_period($period, $full = false) {
389 389
 
390 390
     $periods = array(
391 391
         'D' => 'day',
@@ -394,16 +394,16 @@  discard block
 block discarded – undo
394 394
         'Y' => 'year',
395 395
     );
396 396
 
397
-    if ( ! isset( $periods[ $period ] ) ) {
397
+    if (!isset($periods[$period])) {
398 398
         $period = 'D';
399 399
     }
400 400
 
401
-    return $full ? $periods[ $period ] : $period;
401
+    return $full ? $periods[$period] : $period;
402 402
 
403 403
 }
404 404
 
405
-function wpinv_item_max_buyable_quantity( $item_id ) {
406
-    return apply_filters( 'wpinv_item_max_buyable_quantity', 5, $item_id );
405
+function wpinv_item_max_buyable_quantity($item_id) {
406
+    return apply_filters('wpinv_item_max_buyable_quantity', 5, $item_id);
407 407
 }
408 408
 
409 409
 /**
@@ -411,47 +411,47 @@  discard block
 block discarded – undo
411 411
  *
412 412
  * @param WPInv_Item|GetPaid_Form_Item $item
413 413
  */
414
-function getpaid_item_recurring_price_help_text( $item, $currency = '', $_initial_price = false, $_recurring_price = false ) {
414
+function getpaid_item_recurring_price_help_text($item, $currency = '', $_initial_price = false, $_recurring_price = false) {
415 415
 
416 416
     // Abort if it is not recurring.
417
-    if ( ! $item->is_recurring() ) {
417
+    if (!$item->is_recurring()) {
418 418
         return '';
419 419
     }
420 420
 
421
-    $initial_price   = false === $_initial_price ? wpinv_price( $item->get_initial_price(), $currency ) : $_initial_price;
422
-    $recurring_price = false === $_recurring_price ? wpinv_price( $item->get_recurring_price(), $currency ) : $_recurring_price;
423
-    $period          = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' );
421
+    $initial_price   = false === $_initial_price ? wpinv_price($item->get_initial_price(), $currency) : $_initial_price;
422
+    $recurring_price = false === $_recurring_price ? wpinv_price($item->get_recurring_price(), $currency) : $_recurring_price;
423
+    $period          = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '');
424 424
     $initial_class   = 'getpaid-item-initial-price';
425 425
     $recurring_class = 'getpaid-item-recurring-price';
426 426
     $bill_times      = $item->get_recurring_limit();
427 427
     $bill_times_less = $bill_times - 1;
428 428
 
429
-    if ( ! empty( $bill_times ) ) {
429
+    if (!empty($bill_times)) {
430 430
 		$bill_times = $item->get_recurring_interval() * $bill_times;
431
-        $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() );
432
-		$bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times );
431
+        $bill_times_less = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times - $item->get_recurring_interval());
432
+		$bill_times = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times);
433 433
 	}
434 434
 
435
-    if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) {
436
-        $initial_price   = wpinv_price( $item->get_sub_total(), $currency );
437
-        $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency );
435
+    if ($item instanceof GetPaid_Form_Item && false === $_initial_price) {
436
+        $initial_price   = wpinv_price($item->get_sub_total(), $currency);
437
+        $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency);
438 438
     }
439 439
 
440
-    if ( wpinv_price( 0, $currency ) == $initial_price && wpinv_price( 0, $currency ) == $recurring_price ) {
441
-        return __( 'Free forever', 'invoicing' );
440
+    if (wpinv_price(0, $currency) == $initial_price && wpinv_price(0, $currency) == $recurring_price) {
441
+        return __('Free forever', 'invoicing');
442 442
     }
443 443
 
444 444
     // For free trial items.
445
-    if ( $item->has_free_trial() ) {
446
-        $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() );
445
+    if ($item->has_free_trial()) {
446
+        $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval());
447 447
 
448
-        if ( wpinv_price( 0, $currency ) == $initial_price ) {
448
+        if (wpinv_price(0, $currency) == $initial_price) {
449 449
 
450
-            if ( empty( $bill_times ) ) {
450
+            if (empty($bill_times)) {
451 451
 
452 452
                 return sprintf(
453 453
                     // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period
454
-                    _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ),
454
+                    _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'),
455 455
                     "<span class='getpaid-item-trial-period'>$trial_period</span>",
456 456
                     "<span class='$recurring_class'>$recurring_price</span>",
457 457
                     "<span class='getpaid-item-recurring-period'>$period</span>"
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 
462 462
             return sprintf(
463 463
                 // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period, $4: is the bill times
464
-                _x( 'Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing' ),
464
+                _x('Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing'),
465 465
                 "<span class='getpaid-item-trial-period'>$trial_period</span>",
466 466
                 "<span class='$recurring_class'>$recurring_price</span>",
467 467
                 "<span class='getpaid-item-recurring-period'>$period</span>",
@@ -470,11 +470,11 @@  discard block
 block discarded – undo
470 470
 
471 471
         }
472 472
 
473
-        if ( empty( $bill_times ) ) {
473
+        if (empty($bill_times)) {
474 474
 
475 475
             return sprintf(
476 476
                 // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period
477
-                _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ),
477
+                _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'),
478 478
                 "<span class='$initial_class'>$initial_price</span>",
479 479
                 "<span class='getpaid-item-trial-period'>$trial_period</span>",
480 480
                 "<span class='$recurring_class'>$recurring_price</span>",
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 
486 486
         return sprintf(
487 487
             // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period, $4: is the susbcription bill times
488
-            _x( '%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing' ),
488
+            _x('%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing'),
489 489
             "<span class='$initial_class'>$initial_price</span>",
490 490
             "<span class='getpaid-item-trial-period'>$trial_period</span>",
491 491
             "<span class='$recurring_class'>$recurring_price</span>",
@@ -495,13 +495,13 @@  discard block
 block discarded – undo
495 495
 
496 496
     }
497 497
 
498
-    if ( $initial_price == $recurring_price ) {
498
+    if ($initial_price == $recurring_price) {
499 499
 
500
-        if ( empty( $bill_times ) ) {
500
+        if (empty($bill_times)) {
501 501
 
502 502
             return sprintf(
503 503
                 // translators: $1: is the recurring price, $2: is the susbcription period
504
-                _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ),
504
+                _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'),
505 505
                 "<span class='$recurring_class'>$recurring_price</span>",
506 506
                 "<span class='getpaid-item-recurring-period'>$period</span>"
507 507
             );
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 
511 511
         return sprintf(
512 512
             // translators: $1: is the recurring price, $2: is the susbcription period, $3: is the susbcription bill times
513
-            _x( '%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
513
+            _x('%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'),
514 514
             "<span class='$recurring_class'>$recurring_price</span>",
515 515
             "<span class='getpaid-item-recurring-period'>$period</span>",
516 516
             "<span class='getpaid-item-recurring-bill-times'>$bill_times</span>"
@@ -518,13 +518,13 @@  discard block
 block discarded – undo
518 518
 
519 519
     }
520 520
 
521
-    if ( $initial_price == wpinv_price( 0, $currency ) ) {
521
+    if ($initial_price == wpinv_price(0, $currency)) {
522 522
 
523
-        if ( empty( $bill_times ) ) {
523
+        if (empty($bill_times)) {
524 524
 
525 525
             return sprintf(
526 526
                 // translators: $1: is the recurring period, $2: is the recurring price
527
-                _x( 'Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing' ),
527
+                _x('Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing'),
528 528
                 "<span class='getpaid-item-recurring-period'>$period</span>",
529 529
                 "<span class='$recurring_class'>$recurring_price</span>"
530 530
             );
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 
534 534
         return sprintf(
535 535
             // translators: $1: is the recurring period, $2: is the recurring price, $3: is the bill times
536
-            _x( 'Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing' ),
536
+            _x('Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing'),
537 537
             "<span class='getpaid-item-recurring-period'>$period</span>",
538 538
             "<span class='$recurring_class'>$recurring_price</span>",
539 539
             "<span class='getpaid-item-recurring-bill-times'>$bill_times_less</span>"
@@ -541,11 +541,11 @@  discard block
 block discarded – undo
541 541
 
542 542
     }
543 543
 
544
-    if ( empty( $bill_times ) ) {
544
+    if (empty($bill_times)) {
545 545
 
546 546
         return sprintf(
547 547
             // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period
548
-            _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ),
548
+            _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'),
549 549
             "<span class='$initial_class'>$initial_price</span>",
550 550
             "<span class='$recurring_class'>$recurring_price</span>",
551 551
             "<span class='getpaid-item-recurring-period'>$period</span>"
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 
556 556
     return sprintf(
557 557
         // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period, $4: is the susbcription bill times
558
-        _x( 'Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing' ),
558
+        _x('Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing'),
559 559
         "<span class='$initial_class'>$initial_price</span>",
560 560
         "<span class='$recurring_class'>$recurring_price</span>",
561 561
         "<span class='getpaid-item-recurring-period'>$period</span>",
Please login to merge, or discard this patch.
templates/payment-forms/elements/billing_email.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 $value = $query_value;
13 13
 $class = '';
14 14
 
15
-if ( ! empty( $form->invoice ) ) {
16
-    $value   = sanitize_email( $form->invoice->get_email() );
17
-} elseif ( is_user_logged_in() ) {
15
+if (!empty($form->invoice)) {
16
+    $value = sanitize_email($form->invoice->get_email());
17
+} elseif (is_user_logged_in()) {
18 18
     $user  = wp_get_current_user();
19
-    $value = sanitize_email( $user->user_email );
19
+    $value = sanitize_email($user->user_email);
20 20
 }
21 21
 
22
-if ( ! empty( $value ) && ! empty( $hide_billing_email ) ) {
22
+if (!empty($value) && !empty($hide_billing_email)) {
23 23
     $class = 'd-none';
24 24
 }
25 25
 
26
-do_action( 'getpaid_before_payment_form_billing_email', $form );
26
+do_action('getpaid_before_payment_form_billing_email', $form);
27 27
 
28
-echo "<span class='" . esc_attr( $class ) . "'>";
28
+echo "<span class='" . esc_attr($class) . "'>";
29 29
 
30 30
 aui()->input(
31 31
     array(
32 32
         'name'             => 'billing_email',
33
-        'id'               => esc_attr( $element_id ),
34
-        'placeholder'      => empty( $placeholder ) ? '' : esc_attr( $placeholder ),
35
-        'required'         => ! empty( $required ),
36
-        'label'            => empty( $label ) ? '' : wp_kses_post( $label ) . '<span class="text-danger"> *</span>',
33
+        'id'               => esc_attr($element_id),
34
+        'placeholder'      => empty($placeholder) ? '' : esc_attr($placeholder),
35
+        'required'         => !empty($required),
36
+        'label'            => empty($label) ? '' : wp_kses_post($label) . '<span class="text-danger"> *</span>',
37 37
         'label_type'       => 'vertical',
38
-        'help_text'        => empty( $description ) ? '' : wp_kses_post( $description ),
38
+        'help_text'        => empty($description) ? '' : wp_kses_post($description),
39 39
         'type'             => 'email',
40 40
         'value'            => $value,
41 41
         'class'            => 'wpinv_billing_email getpaid-refresh-on-change',
@@ -48,4 +48,4 @@  discard block
 block discarded – undo
48 48
 
49 49
 echo '</span>';
50 50
 
51
-do_action( 'getpaid_after_payment_form_billing_email', $form );
51
+do_action('getpaid_after_payment_form_billing_email', $form);
Please login to merge, or discard this patch.
templates/payment-forms/elements/date.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -12,59 +12,59 @@
 block discarded – undo
12 12
 $label       = empty( $label ) ? '' : wp_kses_post( $label );
13 13
 $label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
14 14
 if ( ! empty( $required ) ) {
15
-	$label .= "<span class='text-danger'> *</span>";
15
+    $label .= "<span class='text-danger'> *</span>";
16 16
 }
17 17
 
18 18
 $disable_dates = array();
19 19
 
20 20
 if ( ! empty( $disabled_dates ) ) {
21
-	$disabled_dates = preg_replace( '/\s+/', '', $disabled_dates );
22
-	$disabled_dates = str_ireplace( 'today', current_time( 'Y-m-d' ), $disabled_dates );
23
-	$disabled_dates = array_filter( explode( ',', $disabled_dates ) );
21
+    $disabled_dates = preg_replace( '/\s+/', '', $disabled_dates );
22
+    $disabled_dates = str_ireplace( 'today', current_time( 'Y-m-d' ), $disabled_dates );
23
+    $disabled_dates = array_filter( explode( ',', $disabled_dates ) );
24 24
 
25
-	foreach ( $disabled_dates as $disabled_date ) {
25
+    foreach ( $disabled_dates as $disabled_date ) {
26 26
 
27
-		$disabled_date = trim( $disabled_date );
27
+        $disabled_date = trim( $disabled_date );
28 28
 
29
-		if ( false === strpos( $disabled_date, '|' ) ) {
30
-			$disable_dates[] = $disabled_date;
31
-			continue;
32
-		}
29
+        if ( false === strpos( $disabled_date, '|' ) ) {
30
+            $disable_dates[] = $disabled_date;
31
+            continue;
32
+        }
33 33
 
34
-		$disabled_date   = explode( '|', $disabled_date );
35
-		$disable_dates[] = array(
36
-			'from' => trim( $disabled_date[0] ),
37
-			'to'   => trim( $disabled_date[1] ),
38
-		);
34
+        $disabled_date   = explode( '|', $disabled_date );
35
+        $disable_dates[] = array(
36
+            'from' => trim( $disabled_date[0] ),
37
+            'to'   => trim( $disabled_date[1] ),
38
+        );
39 39
 
40
-	}
40
+    }
41 41
 }
42 42
 
43 43
 $options = array(
44
-	'data-default-date'     => empty( $default_date ) ? false : $default_date,
45
-	'data-min-date'         => empty( $min_date ) ? false : $min_date,
46
-	'data-max-date'         => empty( $max_date ) ? false : $max_date,
47
-	'data-mode'             => empty( $mode ) ? 'single' : $mode,
48
-	'data-alt-format'       => get_option( 'date_format', 'F j, Y' ),
49
-	'data-date-format'      => 'Y-m-d',
50
-	'data-alt-input'        => 'true',
51
-	'data-disable_alt'      => empty( $disabled_dates ) ? false : wp_json_encode( $disable_dates ),
52
-	'data-disable_days_alt' => empty( $disable_days ) ? false : wp_json_encode( wp_parse_id_list( $disable_days ) ),
44
+    'data-default-date'     => empty( $default_date ) ? false : $default_date,
45
+    'data-min-date'         => empty( $min_date ) ? false : $min_date,
46
+    'data-max-date'         => empty( $max_date ) ? false : $max_date,
47
+    'data-mode'             => empty( $mode ) ? 'single' : $mode,
48
+    'data-alt-format'       => get_option( 'date_format', 'F j, Y' ),
49
+    'data-date-format'      => 'Y-m-d',
50
+    'data-alt-input'        => 'true',
51
+    'data-disable_alt'      => empty( $disabled_dates ) ? false : wp_json_encode( $disable_dates ),
52
+    'data-disable_days_alt' => empty( $disable_days ) ? false : wp_json_encode( wp_parse_id_list( $disable_days ) ),
53 53
 );
54 54
 
55 55
 aui()->input(
56
-	array(
57
-		'name'             => esc_attr( $id ),
58
-		'id'               => esc_attr( $element_id ),
59
-		'placeholder'      => empty( $placeholder ) ? '' : esc_attr( $placeholder ),
60
-		'required'         => ! empty( $required ),
61
-		'label'            => $label,
62
-		'label_type'       => 'vertical',
63
-		'help_text'        => empty( $description ) ? '' : wp_kses_post( $description ),
64
-		'type'             => 'datepicker',
65
-		'class'            => $label_class . ' getpaid-init-flatpickr flatpickr-input',
66
-		'extra_attributes' => array_filter( apply_filters( 'getpaid_date_field_attributes', $options ) ),
67
-		'value'            => $query_value,
68
-	),
69
-	true
56
+    array(
57
+        'name'             => esc_attr( $id ),
58
+        'id'               => esc_attr( $element_id ),
59
+        'placeholder'      => empty( $placeholder ) ? '' : esc_attr( $placeholder ),
60
+        'required'         => ! empty( $required ),
61
+        'label'            => $label,
62
+        'label_type'       => 'vertical',
63
+        'help_text'        => empty( $description ) ? '' : wp_kses_post( $description ),
64
+        'type'             => 'datepicker',
65
+        'class'            => $label_class . ' getpaid-init-flatpickr flatpickr-input',
66
+        'extra_attributes' => array_filter( apply_filters( 'getpaid_date_field_attributes', $options ) ),
67
+        'value'            => $query_value,
68
+    ),
69
+    true
70 70
 );
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -7,63 +7,63 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$label       = empty( $label ) ? '' : wp_kses_post( $label );
13
-$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
14
-if ( ! empty( $required ) ) {
12
+$label       = empty($label) ? '' : wp_kses_post($label);
13
+$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label));
14
+if (!empty($required)) {
15 15
 	$label .= "<span class='text-danger'> *</span>";
16 16
 }
17 17
 
18 18
 $disable_dates = array();
19 19
 
20
-if ( ! empty( $disabled_dates ) ) {
21
-	$disabled_dates = preg_replace( '/\s+/', '', $disabled_dates );
22
-	$disabled_dates = str_ireplace( 'today', current_time( 'Y-m-d' ), $disabled_dates );
23
-	$disabled_dates = array_filter( explode( ',', $disabled_dates ) );
20
+if (!empty($disabled_dates)) {
21
+	$disabled_dates = preg_replace('/\s+/', '', $disabled_dates);
22
+	$disabled_dates = str_ireplace('today', current_time('Y-m-d'), $disabled_dates);
23
+	$disabled_dates = array_filter(explode(',', $disabled_dates));
24 24
 
25
-	foreach ( $disabled_dates as $disabled_date ) {
25
+	foreach ($disabled_dates as $disabled_date) {
26 26
 
27
-		$disabled_date = trim( $disabled_date );
27
+		$disabled_date = trim($disabled_date);
28 28
 
29
-		if ( false === strpos( $disabled_date, '|' ) ) {
29
+		if (false === strpos($disabled_date, '|')) {
30 30
 			$disable_dates[] = $disabled_date;
31 31
 			continue;
32 32
 		}
33 33
 
34
-		$disabled_date   = explode( '|', $disabled_date );
34
+		$disabled_date   = explode('|', $disabled_date);
35 35
 		$disable_dates[] = array(
36
-			'from' => trim( $disabled_date[0] ),
37
-			'to'   => trim( $disabled_date[1] ),
36
+			'from' => trim($disabled_date[0]),
37
+			'to'   => trim($disabled_date[1]),
38 38
 		);
39 39
 
40 40
 	}
41 41
 }
42 42
 
43 43
 $options = array(
44
-	'data-default-date'     => empty( $default_date ) ? false : $default_date,
45
-	'data-min-date'         => empty( $min_date ) ? false : $min_date,
46
-	'data-max-date'         => empty( $max_date ) ? false : $max_date,
47
-	'data-mode'             => empty( $mode ) ? 'single' : $mode,
48
-	'data-alt-format'       => get_option( 'date_format', 'F j, Y' ),
44
+	'data-default-date'     => empty($default_date) ? false : $default_date,
45
+	'data-min-date'         => empty($min_date) ? false : $min_date,
46
+	'data-max-date'         => empty($max_date) ? false : $max_date,
47
+	'data-mode'             => empty($mode) ? 'single' : $mode,
48
+	'data-alt-format'       => get_option('date_format', 'F j, Y'),
49 49
 	'data-date-format'      => 'Y-m-d',
50 50
 	'data-alt-input'        => 'true',
51
-	'data-disable_alt'      => empty( $disabled_dates ) ? false : wp_json_encode( $disable_dates ),
52
-	'data-disable_days_alt' => empty( $disable_days ) ? false : wp_json_encode( wp_parse_id_list( $disable_days ) ),
51
+	'data-disable_alt'      => empty($disabled_dates) ? false : wp_json_encode($disable_dates),
52
+	'data-disable_days_alt' => empty($disable_days) ? false : wp_json_encode(wp_parse_id_list($disable_days)),
53 53
 );
54 54
 
55 55
 aui()->input(
56 56
 	array(
57
-		'name'             => esc_attr( $id ),
58
-		'id'               => esc_attr( $element_id ),
59
-		'placeholder'      => empty( $placeholder ) ? '' : esc_attr( $placeholder ),
60
-		'required'         => ! empty( $required ),
57
+		'name'             => esc_attr($id),
58
+		'id'               => esc_attr($element_id),
59
+		'placeholder'      => empty($placeholder) ? '' : esc_attr($placeholder),
60
+		'required'         => !empty($required),
61 61
 		'label'            => $label,
62 62
 		'label_type'       => 'vertical',
63
-		'help_text'        => empty( $description ) ? '' : wp_kses_post( $description ),
63
+		'help_text'        => empty($description) ? '' : wp_kses_post($description),
64 64
 		'type'             => 'datepicker',
65 65
 		'class'            => $label_class . ' getpaid-init-flatpickr flatpickr-input',
66
-		'extra_attributes' => array_filter( apply_filters( 'getpaid_date_field_attributes', $options ) ),
66
+		'extra_attributes' => array_filter(apply_filters('getpaid_date_field_attributes', $options)),
67 67
 		'value'            => $query_value,
68 68
 	),
69 69
 	true
Please login to merge, or discard this patch.
includes/admin/class-getpaid-installer.php 2 patches
Indentation   +384 added lines, -384 removed lines patch added patch discarded remove patch
@@ -20,237 +20,237 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class GetPaid_Installer {
22 22
 
23
-	/**
24
-	 * Upgrades the install.
25
-	 *
26
-	 * @param string $upgrade_from The current invoicing version.
27
-	 */
28
-	public function upgrade_db( $upgrade_from ) {
29
-
30
-		// Save the current invoicing version.
31
-		update_option( 'wpinv_version', WPINV_VERSION );
32
-
33
-		// Setup the invoice Custom Post Type.
34
-		GetPaid_Post_Types::register_post_types();
35
-
36
-		// Clear the permalinks
37
-		flush_rewrite_rules();
38
-
39
-		// Maybe create new/missing pages.
40
-		$this->create_pages();
41
-
42
-		// Maybe re(add) admin capabilities.
43
-		$this->add_capabilities();
44
-
45
-		// Maybe create the default payment form.
46
-		wpinv_get_default_payment_form();
47
-
48
-		// Create any missing database tables.
49
-		$method = "upgrade_from_$upgrade_from";
50
-
51
-		$installed = get_option( 'gepaid_installed_on' );
52
-
53
-		if ( empty( $installed ) ) {
54
-			update_option( 'gepaid_installed_on', time() );
55
-		}
56
-
57
-		if ( method_exists( $this, $method ) ) {
58
-			$this->$method();
59
-		}
60
-
61
-	}
62
-
63
-	/**
64
-	 * Do a fresh install.
65
-	 *
66
-	 */
67
-	public function upgrade_from_0() {
68
-		$this->create_subscriptions_table();
69
-		$this->create_invoices_table();
70
-		$this->create_invoice_items_table();
71
-
72
-		// Save default tax rates.
73
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
74
-	}
75
-
76
-	/**
77
-	 * Upgrade to 0.0.5
78
-	 *
79
-	 */
80
-	public function upgrade_from_004() {
81
-		global $wpdb;
82
-
83
-		// Invoices.
84
-		$results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
85
-		if ( ! empty( $results ) ) {
86
-			$wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
87
-
88
-			// Clean post cache
89
-			foreach ( $results as $row ) {
90
-				clean_post_cache( $row->ID );
91
-			}
92
-		}
93
-
94
-		// Item meta key changes
95
-		$query = 'SELECT DISTINCT post_id FROM ' . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
96
-		$results = $wpdb->get_results( $query );
97
-
98
-		if ( ! empty( $results ) ) {
99
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
100
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
101
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
102
-
103
-			foreach ( $results as $row ) {
104
-				clean_post_cache( $row->post_id );
105
-			}
106
-		}
107
-
108
-		$this->upgrade_from_102();
109
-	}
110
-
111
-	/**
112
-	 * Upgrade to 1.0.3
113
-	 *
114
-	 */
115
-	public function upgrade_from_102() {
116
-		$this->create_subscriptions_table();
117
-		$this->upgrade_from_118();
118
-	}
119
-
120
-	/**
121
-	 * Upgrade to version 2.0.0.
122
-	 *
123
-	 */
124
-	public function upgrade_from_118() {
125
-		$this->create_invoices_table();
126
-		$this->create_invoice_items_table();
127
-		$this->migrate_old_invoices();
128
-	}
129
-
130
-	/**
131
-	 * Upgrade to version 2.0.8.
132
-	 *
133
-	 */
134
-	public function upgrade_from_207() {
135
-		global $wpdb;
136
-		$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" );
137
-		$this->upgrade_from_2615();
138
-	}
139
-
140
-	/**
141
-	 * Upgrade to version 2.6.16.
142
-	 *
143
-	 */
144
-	public function upgrade_from_2615() {
145
-		global $wpdb;
146
-		$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN item_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY custom_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY price DECIMAL(16,4) NOT NULL DEFAULT '0';" );
147
-		$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoices MODIFY COLUMN subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY tax DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY fees_total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0';" );
148
-	}
149
-
150
-	/**
151
-	 * Give administrators the capability to manage GetPaid.
152
-	 *
153
-	 */
154
-	public function add_capabilities() {
155
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
156
-	}
157
-
158
-	/**
159
-	 * Retreives GetPaid pages.
160
-	 *
161
-	 */
162
-	public static function get_pages() {
163
-
164
-		return apply_filters(
165
-			'wpinv_create_pages',
166
-			array(
167
-
168
-				// Checkout page.
169
-				'checkout_page'             => array(
170
-					'name'    => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
171
-					'title'   => _x( 'Checkout', 'Page title', 'invoicing' ),
172
-					'content' => '
23
+    /**
24
+     * Upgrades the install.
25
+     *
26
+     * @param string $upgrade_from The current invoicing version.
27
+     */
28
+    public function upgrade_db( $upgrade_from ) {
29
+
30
+        // Save the current invoicing version.
31
+        update_option( 'wpinv_version', WPINV_VERSION );
32
+
33
+        // Setup the invoice Custom Post Type.
34
+        GetPaid_Post_Types::register_post_types();
35
+
36
+        // Clear the permalinks
37
+        flush_rewrite_rules();
38
+
39
+        // Maybe create new/missing pages.
40
+        $this->create_pages();
41
+
42
+        // Maybe re(add) admin capabilities.
43
+        $this->add_capabilities();
44
+
45
+        // Maybe create the default payment form.
46
+        wpinv_get_default_payment_form();
47
+
48
+        // Create any missing database tables.
49
+        $method = "upgrade_from_$upgrade_from";
50
+
51
+        $installed = get_option( 'gepaid_installed_on' );
52
+
53
+        if ( empty( $installed ) ) {
54
+            update_option( 'gepaid_installed_on', time() );
55
+        }
56
+
57
+        if ( method_exists( $this, $method ) ) {
58
+            $this->$method();
59
+        }
60
+
61
+    }
62
+
63
+    /**
64
+     * Do a fresh install.
65
+     *
66
+     */
67
+    public function upgrade_from_0() {
68
+        $this->create_subscriptions_table();
69
+        $this->create_invoices_table();
70
+        $this->create_invoice_items_table();
71
+
72
+        // Save default tax rates.
73
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
74
+    }
75
+
76
+    /**
77
+     * Upgrade to 0.0.5
78
+     *
79
+     */
80
+    public function upgrade_from_004() {
81
+        global $wpdb;
82
+
83
+        // Invoices.
84
+        $results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
85
+        if ( ! empty( $results ) ) {
86
+            $wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
87
+
88
+            // Clean post cache
89
+            foreach ( $results as $row ) {
90
+                clean_post_cache( $row->ID );
91
+            }
92
+        }
93
+
94
+        // Item meta key changes
95
+        $query = 'SELECT DISTINCT post_id FROM ' . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
96
+        $results = $wpdb->get_results( $query );
97
+
98
+        if ( ! empty( $results ) ) {
99
+            $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
100
+            $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
101
+            $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
102
+
103
+            foreach ( $results as $row ) {
104
+                clean_post_cache( $row->post_id );
105
+            }
106
+        }
107
+
108
+        $this->upgrade_from_102();
109
+    }
110
+
111
+    /**
112
+     * Upgrade to 1.0.3
113
+     *
114
+     */
115
+    public function upgrade_from_102() {
116
+        $this->create_subscriptions_table();
117
+        $this->upgrade_from_118();
118
+    }
119
+
120
+    /**
121
+     * Upgrade to version 2.0.0.
122
+     *
123
+     */
124
+    public function upgrade_from_118() {
125
+        $this->create_invoices_table();
126
+        $this->create_invoice_items_table();
127
+        $this->migrate_old_invoices();
128
+    }
129
+
130
+    /**
131
+     * Upgrade to version 2.0.8.
132
+     *
133
+     */
134
+    public function upgrade_from_207() {
135
+        global $wpdb;
136
+        $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" );
137
+        $this->upgrade_from_2615();
138
+    }
139
+
140
+    /**
141
+     * Upgrade to version 2.6.16.
142
+     *
143
+     */
144
+    public function upgrade_from_2615() {
145
+        global $wpdb;
146
+        $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN item_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY custom_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY price DECIMAL(16,4) NOT NULL DEFAULT '0';" );
147
+        $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoices MODIFY COLUMN subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY tax DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY fees_total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0';" );
148
+    }
149
+
150
+    /**
151
+     * Give administrators the capability to manage GetPaid.
152
+     *
153
+     */
154
+    public function add_capabilities() {
155
+        $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
156
+    }
157
+
158
+    /**
159
+     * Retreives GetPaid pages.
160
+     *
161
+     */
162
+    public static function get_pages() {
163
+
164
+        return apply_filters(
165
+            'wpinv_create_pages',
166
+            array(
167
+
168
+                // Checkout page.
169
+                'checkout_page'             => array(
170
+                    'name'    => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
171
+                    'title'   => _x( 'Checkout', 'Page title', 'invoicing' ),
172
+                    'content' => '
173 173
 						<!-- wp:shortcode -->
174 174
 						[wpinv_checkout]
175 175
 						<!-- /wp:shortcode -->
176 176
 					',
177
-					'parent'  => '',
178
-				),
179
-
180
-				// Invoice history page.
181
-				'invoice_history_page'      => array(
182
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
183
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
184
-					'content' => '
177
+                    'parent'  => '',
178
+                ),
179
+
180
+                // Invoice history page.
181
+                'invoice_history_page'      => array(
182
+                    'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
183
+                    'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
184
+                    'content' => '
185 185
 					<!-- wp:shortcode -->
186 186
 					[wpinv_history]
187 187
 					<!-- /wp:shortcode -->
188 188
 				',
189
-					'parent'  => '',
190
-				),
191
-
192
-				// Success page content.
193
-				'success_page'              => array(
194
-					'name'    => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
195
-					'title'   => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
196
-					'content' => '
189
+                    'parent'  => '',
190
+                ),
191
+
192
+                // Success page content.
193
+                'success_page'              => array(
194
+                    'name'    => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
195
+                    'title'   => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
196
+                    'content' => '
197 197
 					<!-- wp:shortcode -->
198 198
 					[wpinv_receipt]
199 199
 					<!-- /wp:shortcode -->
200 200
 				',
201
-					'parent'  => 'gp-checkout',
202
-				),
203
-
204
-				// Failure page content.
205
-				'failure_page'              => array(
206
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
207
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
208
-					'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
209
-					'parent'  => 'gp-checkout',
210
-				),
211
-
212
-				// Subscriptions history page.
213
-				'invoice_subscription_page' => array(
214
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
215
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
216
-					'content' => '
201
+                    'parent'  => 'gp-checkout',
202
+                ),
203
+
204
+                // Failure page content.
205
+                'failure_page'              => array(
206
+                    'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
207
+                    'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
208
+                    'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
209
+                    'parent'  => 'gp-checkout',
210
+                ),
211
+
212
+                // Subscriptions history page.
213
+                'invoice_subscription_page' => array(
214
+                    'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
215
+                    'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
216
+                    'content' => '
217 217
 					<!-- wp:shortcode -->
218 218
 					[wpinv_subscriptions]
219 219
 					<!-- /wp:shortcode -->
220 220
 				',
221
-					'parent'  => '',
222
-				),
221
+                    'parent'  => '',
222
+                ),
223 223
 
224
-			)
225
-		);
224
+            )
225
+        );
226 226
 
227
-	}
227
+    }
228 228
 
229
-	/**
230
-	 * Re-create GetPaid pages.
231
-	 *
232
-	 */
233
-	public function create_pages() {
229
+    /**
230
+     * Re-create GetPaid pages.
231
+     *
232
+     */
233
+    public function create_pages() {
234 234
 
235
-		foreach ( self::get_pages() as $key => $page ) {
236
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
237
-		}
235
+        foreach ( self::get_pages() as $key => $page ) {
236
+            wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
237
+        }
238 238
 
239
-	}
239
+    }
240 240
 
241
-	/**
242
-	 * Create subscriptions table.
243
-	 *
244
-	 */
245
-	public function create_subscriptions_table() {
241
+    /**
242
+     * Create subscriptions table.
243
+     *
244
+     */
245
+    public function create_subscriptions_table() {
246 246
 
247
-		global $wpdb;
247
+        global $wpdb;
248 248
 
249
-		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
249
+        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
250 250
 
251
-		// Create tables.
252
-		$charset_collate = $wpdb->get_charset_collate();
253
-		$sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wpinv_subscriptions (
251
+        // Create tables.
252
+        $charset_collate = $wpdb->get_charset_collate();
253
+        $sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wpinv_subscriptions (
254 254
 			id bigint(20) unsigned NOT NULL auto_increment,
255 255
 			customer_id bigint(20) NOT NULL,
256 256
 			frequency int(11) NOT NULL DEFAULT '1',
@@ -273,22 +273,22 @@  discard block
 block discarded – undo
273 273
 			KEY customer_and_status (customer_id, status)
274 274
 		  ) $charset_collate;";
275 275
 
276
-		dbDelta( $sql );
276
+        dbDelta( $sql );
277 277
 
278
-	}
278
+    }
279 279
 
280
-	/**
281
-	 * Create invoices table.
282
-	 *
283
-	 */
284
-	public function create_invoices_table() {
285
-		global $wpdb;
280
+    /**
281
+     * Create invoices table.
282
+     *
283
+     */
284
+    public function create_invoices_table() {
285
+        global $wpdb;
286 286
 
287
-		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
287
+        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
288 288
 
289
-		// Create tables.
290
-		$charset_collate = $wpdb->get_charset_collate();
291
-		$sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoices (
289
+        // Create tables.
290
+        $charset_collate = $wpdb->get_charset_collate();
291
+        $sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoices (
292 292
 			post_id BIGINT(20) NOT NULL,
293 293
             `number` VARCHAR(100),
294 294
             `key` VARCHAR(100),
@@ -324,22 +324,22 @@  discard block
 block discarded – undo
324 324
 			KEY `key` (`key`)
325 325
 		  ) $charset_collate;";
326 326
 
327
-		dbDelta( $sql );
327
+        dbDelta( $sql );
328 328
 
329
-	}
329
+    }
330 330
 
331
-	/**
332
-	 * Create invoice items table.
333
-	 *
334
-	 */
335
-	public function create_invoice_items_table() {
336
-		global $wpdb;
331
+    /**
332
+     * Create invoice items table.
333
+     *
334
+     */
335
+    public function create_invoice_items_table() {
336
+        global $wpdb;
337 337
 
338
-		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
338
+        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
339 339
 
340
-		// Create tables.
341
-		$charset_collate = $wpdb->get_charset_collate();
342
-		$sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoice_items (
340
+        // Create tables.
341
+        $charset_collate = $wpdb->get_charset_collate();
342
+        $sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoice_items (
343 343
 			ID BIGINT(20) NOT NULL AUTO_INCREMENT,
344 344
             post_id BIGINT(20) NOT NULL,
345 345
             item_id BIGINT(20) NOT NULL,
@@ -361,159 +361,159 @@  discard block
 block discarded – undo
361 361
 			KEY post_id (post_id)
362 362
 		  ) $charset_collate;";
363 363
 
364
-		dbDelta( $sql );
365
-
366
-	}
367
-
368
-	/**
369
-	 * Migrates old invoices to new invoices.
370
-	 *
371
-	 */
372
-	public function migrate_old_invoices() {
373
-		global $wpdb;
374
-
375
-		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
376
-		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
377
-		$migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
378
-		$invoices            = array_unique(
379
-			get_posts(
380
-				array(
381
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
382
-					'posts_per_page' => -1,
383
-					'fields'         => 'ids',
384
-					'post_status'    => array_keys( get_post_stati() ),
385
-					'exclude'        => (array) $migrated,
386
-				)
387
-			)
388
-		);
389
-
390
-		// Abort if we do not have any invoices.
391
-		if ( empty( $invoices ) ) {
392
-			return;
393
-		}
394
-
395
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php';
396
-
397
-		$invoice_rows = array();
398
-		foreach ( $invoices as $invoice ) {
399
-
400
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
401
-
402
-			if ( empty( $invoice->ID ) ) {
403
-				return;
404
-			}
405
-
406
-			$fields = array(
407
-				'post_id'            => $invoice->ID,
408
-				'number'             => $invoice->get_number(),
409
-				'key'                => $invoice->get_key(),
410
-				'type'               => str_replace( 'wpi_', '', $invoice->post_type ),
411
-				'mode'               => $invoice->mode,
412
-				'user_ip'            => $invoice->get_ip(),
413
-				'first_name'         => $invoice->get_first_name(),
414
-				'last_name'          => $invoice->get_last_name(),
415
-				'address'            => $invoice->get_address(),
416
-				'city'               => $invoice->city,
417
-				'state'              => $invoice->state,
418
-				'country'            => $invoice->country,
419
-				'zip'                => $invoice->zip,
420
-				'adddress_confirmed' => (int) $invoice->adddress_confirmed,
421
-				'gateway'            => $invoice->get_gateway(),
422
-				'transaction_id'     => $invoice->get_transaction_id(),
423
-				'currency'           => $invoice->get_currency(),
424
-				'subtotal'           => $invoice->get_subtotal(),
425
-				'tax'                => $invoice->get_tax(),
426
-				'fees_total'         => $invoice->get_fees_total(),
427
-				'total'              => $invoice->get_total(),
428
-				'discount'           => $invoice->get_discount(),
429
-				'discount_code'      => $invoice->get_discount_code(),
430
-				'disable_taxes'      => $invoice->disable_taxes,
431
-				'due_date'           => $invoice->get_due_date(),
432
-				'completed_date'     => $invoice->get_completed_date(),
433
-				'company'            => $invoice->company,
434
-				'vat_number'         => $invoice->vat_number,
435
-				'vat_rate'           => $invoice->vat_rate,
436
-				'custom_meta'        => $invoice->payment_meta,
437
-			);
438
-
439
-			foreach ( $fields as $key => $val ) {
440
-				if ( is_null( $val ) ) {
441
-					$val = '';
442
-				}
443
-				$val = maybe_serialize( $val );
444
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
445
-			}
446
-
447
-			$fields = implode( ', ', $fields );
448
-			$invoice_rows[] = "($fields)";
449
-
450
-			$item_rows    = array();
451
-			$item_columns = array();
452
-			foreach ( $invoice->get_cart_details() as $details ) {
453
-				$fields = array(
454
-					'post_id'          => $invoice->ID,
455
-					'item_id'          => $details['id'],
456
-					'item_name'        => $details['name'],
457
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
458
-					'vat_rate'         => $details['vat_rate'],
459
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
460
-					'tax'              => $details['tax'],
461
-					'item_price'       => $details['item_price'],
462
-					'custom_price'     => $details['custom_price'],
463
-					'quantity'         => $details['quantity'],
464
-					'discount'         => $details['discount'],
465
-					'subtotal'         => $details['subtotal'],
466
-					'price'            => $details['price'],
467
-					'meta'             => $details['meta'],
468
-					'fees'             => $details['fees'],
469
-				);
470
-
471
-				$item_columns = array_keys( $fields );
472
-
473
-				foreach ( $fields as $key => $val ) {
474
-					if ( is_null( $val ) ) {
475
-						$val = '';
476
-					}
477
-					$val = maybe_serialize( $val );
478
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
479
-				}
480
-
481
-				$fields = implode( ', ', $fields );
482
-				$item_rows[] = "($fields)";
483
-			}
484
-
485
-			$item_rows    = implode( ', ', $item_rows );
486
-			$item_columns = implode( ', ', $item_columns );
487
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
488
-		}
489
-
490
-		if ( empty( $invoice_rows ) ) {
491
-			return;
492
-		}
493
-
494
-		$invoice_rows = implode( ', ', $invoice_rows );
495
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
496
-
497
-	}
498
-
499
-	/**
500
-	 * Migrates old invoices to new invoices.
501
-	 *
502
-	 */
503
-	public static function rename_gateways_label() {
504
-		global $wpdb;
505
-
506
-		foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
507
-
508
-			$wpdb->update(
509
-				$wpdb->prefix . 'getpaid_invoices',
510
-				array( 'gateway' => $gateway ),
511
-				array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
512
-				'%s',
513
-				'%s'
514
-			);
515
-
516
-		}
517
-	}
364
+        dbDelta( $sql );
365
+
366
+    }
367
+
368
+    /**
369
+     * Migrates old invoices to new invoices.
370
+     *
371
+     */
372
+    public function migrate_old_invoices() {
373
+        global $wpdb;
374
+
375
+        $invoices_table      = $wpdb->prefix . 'getpaid_invoices';
376
+        $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
377
+        $migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
378
+        $invoices            = array_unique(
379
+            get_posts(
380
+                array(
381
+                    'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
382
+                    'posts_per_page' => -1,
383
+                    'fields'         => 'ids',
384
+                    'post_status'    => array_keys( get_post_stati() ),
385
+                    'exclude'        => (array) $migrated,
386
+                )
387
+            )
388
+        );
389
+
390
+        // Abort if we do not have any invoices.
391
+        if ( empty( $invoices ) ) {
392
+            return;
393
+        }
394
+
395
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php';
396
+
397
+        $invoice_rows = array();
398
+        foreach ( $invoices as $invoice ) {
399
+
400
+            $invoice = new WPInv_Legacy_Invoice( $invoice );
401
+
402
+            if ( empty( $invoice->ID ) ) {
403
+                return;
404
+            }
405
+
406
+            $fields = array(
407
+                'post_id'            => $invoice->ID,
408
+                'number'             => $invoice->get_number(),
409
+                'key'                => $invoice->get_key(),
410
+                'type'               => str_replace( 'wpi_', '', $invoice->post_type ),
411
+                'mode'               => $invoice->mode,
412
+                'user_ip'            => $invoice->get_ip(),
413
+                'first_name'         => $invoice->get_first_name(),
414
+                'last_name'          => $invoice->get_last_name(),
415
+                'address'            => $invoice->get_address(),
416
+                'city'               => $invoice->city,
417
+                'state'              => $invoice->state,
418
+                'country'            => $invoice->country,
419
+                'zip'                => $invoice->zip,
420
+                'adddress_confirmed' => (int) $invoice->adddress_confirmed,
421
+                'gateway'            => $invoice->get_gateway(),
422
+                'transaction_id'     => $invoice->get_transaction_id(),
423
+                'currency'           => $invoice->get_currency(),
424
+                'subtotal'           => $invoice->get_subtotal(),
425
+                'tax'                => $invoice->get_tax(),
426
+                'fees_total'         => $invoice->get_fees_total(),
427
+                'total'              => $invoice->get_total(),
428
+                'discount'           => $invoice->get_discount(),
429
+                'discount_code'      => $invoice->get_discount_code(),
430
+                'disable_taxes'      => $invoice->disable_taxes,
431
+                'due_date'           => $invoice->get_due_date(),
432
+                'completed_date'     => $invoice->get_completed_date(),
433
+                'company'            => $invoice->company,
434
+                'vat_number'         => $invoice->vat_number,
435
+                'vat_rate'           => $invoice->vat_rate,
436
+                'custom_meta'        => $invoice->payment_meta,
437
+            );
438
+
439
+            foreach ( $fields as $key => $val ) {
440
+                if ( is_null( $val ) ) {
441
+                    $val = '';
442
+                }
443
+                $val = maybe_serialize( $val );
444
+                $fields[ $key ] = $wpdb->prepare( '%s', $val );
445
+            }
446
+
447
+            $fields = implode( ', ', $fields );
448
+            $invoice_rows[] = "($fields)";
449
+
450
+            $item_rows    = array();
451
+            $item_columns = array();
452
+            foreach ( $invoice->get_cart_details() as $details ) {
453
+                $fields = array(
454
+                    'post_id'          => $invoice->ID,
455
+                    'item_id'          => $details['id'],
456
+                    'item_name'        => $details['name'],
457
+                    'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
458
+                    'vat_rate'         => $details['vat_rate'],
459
+                    'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
460
+                    'tax'              => $details['tax'],
461
+                    'item_price'       => $details['item_price'],
462
+                    'custom_price'     => $details['custom_price'],
463
+                    'quantity'         => $details['quantity'],
464
+                    'discount'         => $details['discount'],
465
+                    'subtotal'         => $details['subtotal'],
466
+                    'price'            => $details['price'],
467
+                    'meta'             => $details['meta'],
468
+                    'fees'             => $details['fees'],
469
+                );
470
+
471
+                $item_columns = array_keys( $fields );
472
+
473
+                foreach ( $fields as $key => $val ) {
474
+                    if ( is_null( $val ) ) {
475
+                        $val = '';
476
+                    }
477
+                    $val = maybe_serialize( $val );
478
+                    $fields[ $key ] = $wpdb->prepare( '%s', $val );
479
+                }
480
+
481
+                $fields = implode( ', ', $fields );
482
+                $item_rows[] = "($fields)";
483
+            }
484
+
485
+            $item_rows    = implode( ', ', $item_rows );
486
+            $item_columns = implode( ', ', $item_columns );
487
+            $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
488
+        }
489
+
490
+        if ( empty( $invoice_rows ) ) {
491
+            return;
492
+        }
493
+
494
+        $invoice_rows = implode( ', ', $invoice_rows );
495
+        $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
496
+
497
+    }
498
+
499
+    /**
500
+     * Migrates old invoices to new invoices.
501
+     *
502
+     */
503
+    public static function rename_gateways_label() {
504
+        global $wpdb;
505
+
506
+        foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
507
+
508
+            $wpdb->update(
509
+                $wpdb->prefix . 'getpaid_invoices',
510
+                array( 'gateway' => $gateway ),
511
+                array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
512
+                '%s',
513
+                '%s'
514
+            );
515
+
516
+        }
517
+    }
518 518
 
519 519
 }
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   2.0.2
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * The main installer/updater class.
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @param string $upgrade_from The current invoicing version.
27 27
 	 */
28
-	public function upgrade_db( $upgrade_from ) {
28
+	public function upgrade_db($upgrade_from) {
29 29
 
30 30
 		// Save the current invoicing version.
31
-		update_option( 'wpinv_version', WPINV_VERSION );
31
+		update_option('wpinv_version', WPINV_VERSION);
32 32
 
33 33
 		// Setup the invoice Custom Post Type.
34 34
 		GetPaid_Post_Types::register_post_types();
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 		// Create any missing database tables.
49 49
 		$method = "upgrade_from_$upgrade_from";
50 50
 
51
-		$installed = get_option( 'gepaid_installed_on' );
51
+		$installed = get_option('gepaid_installed_on');
52 52
 
53
-		if ( empty( $installed ) ) {
54
-			update_option( 'gepaid_installed_on', time() );
53
+		if (empty($installed)) {
54
+			update_option('gepaid_installed_on', time());
55 55
 		}
56 56
 
57
-		if ( method_exists( $this, $method ) ) {
57
+		if (method_exists($this, $method)) {
58 58
 			$this->$method();
59 59
 		}
60 60
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		$this->create_invoice_items_table();
71 71
 
72 72
 		// Save default tax rates.
73
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
73
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
74 74
 	}
75 75
 
76 76
 	/**
@@ -81,27 +81,27 @@  discard block
 block discarded – undo
81 81
 		global $wpdb;
82 82
 
83 83
 		// Invoices.
84
-		$results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
85
-		if ( ! empty( $results ) ) {
86
-			$wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
84
+		$results = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
85
+		if (!empty($results)) {
86
+			$wpdb->query("UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
87 87
 
88 88
 			// Clean post cache
89
-			foreach ( $results as $row ) {
90
-				clean_post_cache( $row->ID );
89
+			foreach ($results as $row) {
90
+				clean_post_cache($row->ID);
91 91
 			}
92 92
 		}
93 93
 
94 94
 		// Item meta key changes
95 95
 		$query = 'SELECT DISTINCT post_id FROM ' . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
96
-		$results = $wpdb->get_results( $query );
96
+		$results = $wpdb->get_results($query);
97 97
 
98
-		if ( ! empty( $results ) ) {
99
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
100
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
101
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
98
+		if (!empty($results)) {
99
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
100
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
101
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
102 102
 
103
-			foreach ( $results as $row ) {
104
-				clean_post_cache( $row->post_id );
103
+			foreach ($results as $row) {
104
+				clean_post_cache($row->post_id);
105 105
 			}
106 106
 		}
107 107
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	public function upgrade_from_207() {
135 135
 		global $wpdb;
136
-		$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" );
136
+		$wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);");
137 137
 		$this->upgrade_from_2615();
138 138
 	}
139 139
 
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function upgrade_from_2615() {
145 145
 		global $wpdb;
146
-		$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN item_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY custom_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY price DECIMAL(16,4) NOT NULL DEFAULT '0';" );
147
-		$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoices MODIFY COLUMN subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY tax DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY fees_total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0';" );
146
+		$wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN item_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY custom_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY price DECIMAL(16,4) NOT NULL DEFAULT '0';");
147
+		$wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoices MODIFY COLUMN subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY tax DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY fees_total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0';");
148 148
 	}
149 149
 
150 150
 	/**
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 */
154 154
 	public function add_capabilities() {
155
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
155
+		$GLOBALS['wp_roles']->add_cap('administrator', 'manage_invoicing');
156 156
 	}
157 157
 
158 158
 	/**
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 
168 168
 				// Checkout page.
169 169
 				'checkout_page'             => array(
170
-					'name'    => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
171
-					'title'   => _x( 'Checkout', 'Page title', 'invoicing' ),
170
+					'name'    => _x('gp-checkout', 'Page slug', 'invoicing'),
171
+					'title'   => _x('Checkout', 'Page title', 'invoicing'),
172 172
 					'content' => '
173 173
 						<!-- wp:shortcode -->
174 174
 						[wpinv_checkout]
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 
180 180
 				// Invoice history page.
181 181
 				'invoice_history_page'      => array(
182
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
183
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
182
+					'name'    => _x('gp-invoices', 'Page slug', 'invoicing'),
183
+					'title'   => _x('My Invoices', 'Page title', 'invoicing'),
184 184
 					'content' => '
185 185
 					<!-- wp:shortcode -->
186 186
 					[wpinv_history]
@@ -191,8 +191,8 @@  discard block
 block discarded – undo
191 191
 
192 192
 				// Success page content.
193 193
 				'success_page'              => array(
194
-					'name'    => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
195
-					'title'   => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
194
+					'name'    => _x('gp-receipt', 'Page slug', 'invoicing'),
195
+					'title'   => _x('Payment Confirmation', 'Page title', 'invoicing'),
196 196
 					'content' => '
197 197
 					<!-- wp:shortcode -->
198 198
 					[wpinv_receipt]
@@ -203,16 +203,16 @@  discard block
 block discarded – undo
203 203
 
204 204
 				// Failure page content.
205 205
 				'failure_page'              => array(
206
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
207
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
208
-					'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
206
+					'name'    => _x('gp-transaction-failed', 'Page slug', 'invoicing'),
207
+					'title'   => _x('Transaction Failed', 'Page title', 'invoicing'),
208
+					'content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'),
209 209
 					'parent'  => 'gp-checkout',
210 210
 				),
211 211
 
212 212
 				// Subscriptions history page.
213 213
 				'invoice_subscription_page' => array(
214
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
215
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
214
+					'name'    => _x('gp-subscriptions', 'Page slug', 'invoicing'),
215
+					'title'   => _x('My Subscriptions', 'Page title', 'invoicing'),
216 216
 					'content' => '
217 217
 					<!-- wp:shortcode -->
218 218
 					[wpinv_subscriptions]
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
 	 */
233 233
 	public function create_pages() {
234 234
 
235
-		foreach ( self::get_pages() as $key => $page ) {
236
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
235
+		foreach (self::get_pages() as $key => $page) {
236
+			wpinv_create_page(esc_sql($page['name']), $key, $page['title'], $page['content'], $page['parent']);
237 237
 		}
238 238
 
239 239
 	}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 			KEY customer_and_status (customer_id, status)
274 274
 		  ) $charset_collate;";
275 275
 
276
-		dbDelta( $sql );
276
+		dbDelta($sql);
277 277
 
278 278
 	}
279 279
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 			KEY `key` (`key`)
325 325
 		  ) $charset_collate;";
326 326
 
327
-		dbDelta( $sql );
327
+		dbDelta($sql);
328 328
 
329 329
 	}
330 330
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 			KEY post_id (post_id)
362 362
 		  ) $charset_collate;";
363 363
 
364
-		dbDelta( $sql );
364
+		dbDelta($sql);
365 365
 
366 366
 	}
367 367
 
@@ -374,32 +374,32 @@  discard block
 block discarded – undo
374 374
 
375 375
 		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
376 376
 		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
377
-		$migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
377
+		$migrated            = $wpdb->get_col("SELECT post_id FROM $invoices_table");
378 378
 		$invoices            = array_unique(
379 379
 			get_posts(
380 380
 				array(
381
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
381
+					'post_type'      => array('wpi_invoice', 'wpi_quote'),
382 382
 					'posts_per_page' => -1,
383 383
 					'fields'         => 'ids',
384
-					'post_status'    => array_keys( get_post_stati() ),
384
+					'post_status'    => array_keys(get_post_stati()),
385 385
 					'exclude'        => (array) $migrated,
386 386
 				)
387 387
 			)
388 388
 		);
389 389
 
390 390
 		// Abort if we do not have any invoices.
391
-		if ( empty( $invoices ) ) {
391
+		if (empty($invoices)) {
392 392
 			return;
393 393
 		}
394 394
 
395 395
 		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php';
396 396
 
397 397
 		$invoice_rows = array();
398
-		foreach ( $invoices as $invoice ) {
398
+		foreach ($invoices as $invoice) {
399 399
 
400
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
400
+			$invoice = new WPInv_Legacy_Invoice($invoice);
401 401
 
402
-			if ( empty( $invoice->ID ) ) {
402
+			if (empty($invoice->ID)) {
403 403
 				return;
404 404
 			}
405 405
 
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 				'post_id'            => $invoice->ID,
408 408
 				'number'             => $invoice->get_number(),
409 409
 				'key'                => $invoice->get_key(),
410
-				'type'               => str_replace( 'wpi_', '', $invoice->post_type ),
410
+				'type'               => str_replace('wpi_', '', $invoice->post_type),
411 411
 				'mode'               => $invoice->mode,
412 412
 				'user_ip'            => $invoice->get_ip(),
413 413
 				'first_name'         => $invoice->get_first_name(),
@@ -436,27 +436,27 @@  discard block
 block discarded – undo
436 436
 				'custom_meta'        => $invoice->payment_meta,
437 437
 			);
438 438
 
439
-			foreach ( $fields as $key => $val ) {
440
-				if ( is_null( $val ) ) {
439
+			foreach ($fields as $key => $val) {
440
+				if (is_null($val)) {
441 441
 					$val = '';
442 442
 				}
443
-				$val = maybe_serialize( $val );
444
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
443
+				$val = maybe_serialize($val);
444
+				$fields[$key] = $wpdb->prepare('%s', $val);
445 445
 			}
446 446
 
447
-			$fields = implode( ', ', $fields );
447
+			$fields = implode(', ', $fields);
448 448
 			$invoice_rows[] = "($fields)";
449 449
 
450 450
 			$item_rows    = array();
451 451
 			$item_columns = array();
452
-			foreach ( $invoice->get_cart_details() as $details ) {
452
+			foreach ($invoice->get_cart_details() as $details) {
453 453
 				$fields = array(
454 454
 					'post_id'          => $invoice->ID,
455 455
 					'item_id'          => $details['id'],
456 456
 					'item_name'        => $details['name'],
457
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
457
+					'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'],
458 458
 					'vat_rate'         => $details['vat_rate'],
459
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
459
+					'vat_class'        => empty($details['vat_class']) ? '_standard' : $details['vat_class'],
460 460
 					'tax'              => $details['tax'],
461 461
 					'item_price'       => $details['item_price'],
462 462
 					'custom_price'     => $details['custom_price'],
@@ -468,31 +468,31 @@  discard block
 block discarded – undo
468 468
 					'fees'             => $details['fees'],
469 469
 				);
470 470
 
471
-				$item_columns = array_keys( $fields );
471
+				$item_columns = array_keys($fields);
472 472
 
473
-				foreach ( $fields as $key => $val ) {
474
-					if ( is_null( $val ) ) {
473
+				foreach ($fields as $key => $val) {
474
+					if (is_null($val)) {
475 475
 						$val = '';
476 476
 					}
477
-					$val = maybe_serialize( $val );
478
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
477
+					$val = maybe_serialize($val);
478
+					$fields[$key] = $wpdb->prepare('%s', $val);
479 479
 				}
480 480
 
481
-				$fields = implode( ', ', $fields );
481
+				$fields = implode(', ', $fields);
482 482
 				$item_rows[] = "($fields)";
483 483
 			}
484 484
 
485
-			$item_rows    = implode( ', ', $item_rows );
486
-			$item_columns = implode( ', ', $item_columns );
487
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
485
+			$item_rows    = implode(', ', $item_rows);
486
+			$item_columns = implode(', ', $item_columns);
487
+			$wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows");
488 488
 		}
489 489
 
490
-		if ( empty( $invoice_rows ) ) {
490
+		if (empty($invoice_rows)) {
491 491
 			return;
492 492
 		}
493 493
 
494
-		$invoice_rows = implode( ', ', $invoice_rows );
495
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
494
+		$invoice_rows = implode(', ', $invoice_rows);
495
+		$wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows");
496 496
 
497 497
 	}
498 498
 
@@ -503,12 +503,12 @@  discard block
 block discarded – undo
503 503
 	public static function rename_gateways_label() {
504 504
 		global $wpdb;
505 505
 
506
-		foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
506
+		foreach (array_keys(wpinv_get_payment_gateways()) as $gateway) {
507 507
 
508 508
 			$wpdb->update(
509 509
 				$wpdb->prefix . 'getpaid_invoices',
510
-				array( 'gateway' => $gateway ),
511
-				array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
510
+				array('gateway' => $gateway),
511
+				array('gateway' => wpinv_get_gateway_admin_label($gateway)),
512 512
 				'%s',
513 513
 				'%s'
514 514
 			);
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports-export.php 2 patches
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -12,47 +12,47 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports_Export {
14 14
 
15
-	/**
16
-	 * Displays the reports tab.
17
-	 *
18
-	 */
19
-	public function display() {
20
-
21
-		echo "<div class='row mt-4' style='max-width: 920px;' >";
22
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
23
-			$this->display_post_type_export( $post_type );
24
-		}
25
-		$this->display_subscription_export();
26
-		echo '</div>';
27
-
28
-	}
29
-
30
-	/**
31
-	 * Retrieves the download url.
32
-	 *
33
-	 */
34
-	public function get_download_url( $post_type ) {
35
-
36
-		return wp_nonce_url(
37
-			add_query_arg(
38
-				array(
39
-					'getpaid-admin-action' => 'export_invoices',
40
-					'post_type'            => urlencode( $post_type ),
41
-				)
42
-			),
43
-			'getpaid-nonce',
44
-			'getpaid-nonce'
45
-		);
46
-
47
-	}
48
-
49
-	/**
50
-	 * Displays a single post type export card.
51
-	 *
52
-	 */
53
-	public function display_post_type_export( $post_type ) {
54
-
55
-		?>
15
+    /**
16
+     * Displays the reports tab.
17
+     *
18
+     */
19
+    public function display() {
20
+
21
+        echo "<div class='row mt-4' style='max-width: 920px;' >";
22
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
23
+            $this->display_post_type_export( $post_type );
24
+        }
25
+        $this->display_subscription_export();
26
+        echo '</div>';
27
+
28
+    }
29
+
30
+    /**
31
+     * Retrieves the download url.
32
+     *
33
+     */
34
+    public function get_download_url( $post_type ) {
35
+
36
+        return wp_nonce_url(
37
+            add_query_arg(
38
+                array(
39
+                    'getpaid-admin-action' => 'export_invoices',
40
+                    'post_type'            => urlencode( $post_type ),
41
+                )
42
+            ),
43
+            'getpaid-nonce',
44
+            'getpaid-nonce'
45
+        );
46
+
47
+    }
48
+
49
+    /**
50
+     * Displays a single post type export card.
51
+     *
52
+     */
53
+    public function display_post_type_export( $post_type ) {
54
+
55
+        ?>
56 56
 
57 57
 		<div class="col-12 col-md-6">
58 58
 			<div class="card m-0 p-0" style="max-width:100%">
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 				<div class="card-header">
61 61
 					<strong>
62 62
 						<?php
63
-							printf(
64
-								esc_html__( 'Export %s', 'invoicing' ),
65
-								esc_html( getpaid_get_post_type_label( $post_type ) )
66
-							);
67
-						?>
63
+                            printf(
64
+                                esc_html__( 'Export %s', 'invoicing' ),
65
+                                esc_html( getpaid_get_post_type_label( $post_type ) )
66
+                            );
67
+                        ?>
68 68
 					</strong>
69 69
 				</div>
70 70
 
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 					<form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>">
74 74
 
75 75
 						<?php
76
-							$this->generate_from_date( $post_type );
77
-							$this->generate_to_date( $post_type );
78
-							$this->generate_post_status_select( $post_type );
79
-							$this->generate_file_type_select( $post_type );
80
-							submit_button( __( 'Download', 'invoicing' ) );
81
-						?>
76
+                            $this->generate_from_date( $post_type );
77
+                            $this->generate_to_date( $post_type );
78
+                            $this->generate_post_status_select( $post_type );
79
+                            $this->generate_file_type_select( $post_type );
80
+                            submit_button( __( 'Download', 'invoicing' ) );
81
+                        ?>
82 82
 
83 83
 					</form>
84 84
 
@@ -89,135 +89,135 @@  discard block
 block discarded – undo
89 89
 
90 90
 		<?php
91 91
 
92
-	}
93
-
94
-	/**
95
-	 * Generates the from date input field.
96
-	 *
97
-	 */
98
-	public function generate_from_date( $post_type ) {
99
-
100
-		aui()->input(
101
-			array(
102
-				'type'             => 'datepicker',
103
-				'id'               => esc_attr( "$post_type-from_date" ),
104
-				'name'             => 'from_date',
105
-				'label'            => __( 'From Date', 'invoicing' ),
106
-				'label_type'       => 'vertical',
107
-				'placeholder'      => 'YYYY-MM-DD',
108
-				'extra_attributes' => array(
109
-					'data-enable-time' => 'false',
110
-					'data-allow-input' => 'true',
111
-				),
112
-			),
113
-			true
114
-		);
115
-
116
-	}
117
-
118
-	/**
119
-	 * Generates the to date input field.
120
-	 *
121
-	 */
122
-	public function generate_to_date( $post_type ) {
123
-
124
-		aui()->input(
125
-			array(
126
-				'type'             => 'datepicker',
127
-				'id'               => esc_attr( "$post_type-to_date" ),
128
-				'name'             => 'to_date',
129
-				'label'            => __( 'To Date', 'invoicing' ),
130
-				'label_type'       => 'vertical',
131
-				'placeholder'      => 'YYYY-MM-DD',
132
-				'extra_attributes' => array(
133
-					'data-enable-time' => 'false',
134
-					'data-allow-input' => 'true',
135
-				),
136
-			),
137
-			true
138
-		);
139
-	}
140
-
141
-	/**
142
-	 * Generates the to post status select field.
143
-	 *
144
-	 */
145
-	public function generate_post_status_select( $post_type ) {
146
-
147
-		if ( 'subscriptions' === $post_type ) {
148
-			$options = getpaid_get_subscription_statuses();
149
-		} else {
150
-			$options = wpinv_get_invoice_statuses( true, false, $post_type );
151
-		}
152
-
153
-		aui()->select(
154
-			array(
155
-				'name'        => 'status',
156
-				'id'          => esc_attr( "$post_type-status" ),
157
-				'placeholder' => __( 'All Statuses', 'invoicing' ),
158
-				'label'       => __( 'Status', 'invoicing' ),
159
-				'label_type'  => 'vertical',
160
-				'label_class' => 'd-block',
161
-				'options'     => $options,
162
-			),
163
-			true
164
-		);
165
-
166
-	}
167
-
168
-	/**
169
-	 * Generates the to file type select field.
170
-	 *
171
-	 */
172
-	public function generate_file_type_select( $post_type ) {
173
-
174
-		aui()->select(
175
-			array(
176
-				'name'        => 'file_type',
177
-				'id'          => esc_attr( "$post_type-file_type" ),
178
-				'placeholder' => __( 'Select File Type', 'invoicing' ),
179
-				'label'       => __( 'Export File', 'invoicing' ),
180
-				'label_type'  => 'vertical',
181
-				'label_class' => 'd-block',
182
-				'value'       => 'csv',
183
-				'options'     => array(
184
-					'csv'  => __( 'CSV', 'invoicing' ),
185
-					'xml'  => __( 'XML', 'invoicing' ),
186
-					'json' => __( 'JSON', 'invoicing' ),
187
-				),
188
-			),
189
-			true
190
-		);
191
-
192
-	}
193
-
194
-	/**
195
-	 * Displays a field's markup.
196
-	 *
197
-	 */
198
-	public function display_markup( $markup ) {
199
-
200
-		echo wp_kses(
201
-			str_replace(
202
-				array(
203
-					'form-control',
204
-					'custom-select',
205
-				),
206
-				'regular-text',
207
-				$markup
208
-			),
209
-			getpaid_allowed_html()
210
-		);
211
-
212
-	}
213
-
214
-	/**
215
-	 * Displays a subscription export card.
216
-	 *
217
-	 */
218
-	public function display_subscription_export() {
219
-
220
-		?>
92
+    }
93
+
94
+    /**
95
+     * Generates the from date input field.
96
+     *
97
+     */
98
+    public function generate_from_date( $post_type ) {
99
+
100
+        aui()->input(
101
+            array(
102
+                'type'             => 'datepicker',
103
+                'id'               => esc_attr( "$post_type-from_date" ),
104
+                'name'             => 'from_date',
105
+                'label'            => __( 'From Date', 'invoicing' ),
106
+                'label_type'       => 'vertical',
107
+                'placeholder'      => 'YYYY-MM-DD',
108
+                'extra_attributes' => array(
109
+                    'data-enable-time' => 'false',
110
+                    'data-allow-input' => 'true',
111
+                ),
112
+            ),
113
+            true
114
+        );
115
+
116
+    }
117
+
118
+    /**
119
+     * Generates the to date input field.
120
+     *
121
+     */
122
+    public function generate_to_date( $post_type ) {
123
+
124
+        aui()->input(
125
+            array(
126
+                'type'             => 'datepicker',
127
+                'id'               => esc_attr( "$post_type-to_date" ),
128
+                'name'             => 'to_date',
129
+                'label'            => __( 'To Date', 'invoicing' ),
130
+                'label_type'       => 'vertical',
131
+                'placeholder'      => 'YYYY-MM-DD',
132
+                'extra_attributes' => array(
133
+                    'data-enable-time' => 'false',
134
+                    'data-allow-input' => 'true',
135
+                ),
136
+            ),
137
+            true
138
+        );
139
+    }
140
+
141
+    /**
142
+     * Generates the to post status select field.
143
+     *
144
+     */
145
+    public function generate_post_status_select( $post_type ) {
146
+
147
+        if ( 'subscriptions' === $post_type ) {
148
+            $options = getpaid_get_subscription_statuses();
149
+        } else {
150
+            $options = wpinv_get_invoice_statuses( true, false, $post_type );
151
+        }
152
+
153
+        aui()->select(
154
+            array(
155
+                'name'        => 'status',
156
+                'id'          => esc_attr( "$post_type-status" ),
157
+                'placeholder' => __( 'All Statuses', 'invoicing' ),
158
+                'label'       => __( 'Status', 'invoicing' ),
159
+                'label_type'  => 'vertical',
160
+                'label_class' => 'd-block',
161
+                'options'     => $options,
162
+            ),
163
+            true
164
+        );
165
+
166
+    }
167
+
168
+    /**
169
+     * Generates the to file type select field.
170
+     *
171
+     */
172
+    public function generate_file_type_select( $post_type ) {
173
+
174
+        aui()->select(
175
+            array(
176
+                'name'        => 'file_type',
177
+                'id'          => esc_attr( "$post_type-file_type" ),
178
+                'placeholder' => __( 'Select File Type', 'invoicing' ),
179
+                'label'       => __( 'Export File', 'invoicing' ),
180
+                'label_type'  => 'vertical',
181
+                'label_class' => 'd-block',
182
+                'value'       => 'csv',
183
+                'options'     => array(
184
+                    'csv'  => __( 'CSV', 'invoicing' ),
185
+                    'xml'  => __( 'XML', 'invoicing' ),
186
+                    'json' => __( 'JSON', 'invoicing' ),
187
+                ),
188
+            ),
189
+            true
190
+        );
191
+
192
+    }
193
+
194
+    /**
195
+     * Displays a field's markup.
196
+     *
197
+     */
198
+    public function display_markup( $markup ) {
199
+
200
+        echo wp_kses(
201
+            str_replace(
202
+                array(
203
+                    'form-control',
204
+                    'custom-select',
205
+                ),
206
+                'regular-text',
207
+                $markup
208
+            ),
209
+            getpaid_allowed_html()
210
+        );
211
+
212
+    }
213
+
214
+    /**
215
+     * Displays a subscription export card.
216
+     *
217
+     */
218
+    public function display_subscription_export() {
219
+
220
+        ?>
221 221
 
222 222
 		<div class="col-12 col-md-6">
223 223
 			<div class="card m-0 p-0" style="max-width:100%">
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
 					<form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>">
234 234
 
235 235
 						<?php
236
-							$this->generate_from_date( 'subscriptions' );
237
-							$this->generate_to_date( 'subscriptions' );
238
-							$this->generate_post_status_select( 'subscriptions' );
239
-							$this->generate_file_type_select( 'subscriptions' );
240
-							submit_button( __( 'Download', 'invoicing' ) );
241
-						?>
236
+                            $this->generate_from_date( 'subscriptions' );
237
+                            $this->generate_to_date( 'subscriptions' );
238
+                            $this->generate_post_status_select( 'subscriptions' );
239
+                            $this->generate_file_type_select( 'subscriptions' );
240
+                            submit_button( __( 'Download', 'invoicing' ) );
241
+                        ?>
242 242
 
243 243
 					</form>
244 244
 
@@ -249,6 +249,6 @@  discard block
 block discarded – undo
249 249
 
250 250
 		<?php
251 251
 
252
-	}
252
+    }
253 253
 
254 254
 }
Please login to merge, or discard this patch.
Spacing   +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
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports_Export Class.
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 	public function display() {
20 20
 
21 21
 		echo "<div class='row mt-4' style='max-width: 920px;' >";
22
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
23
-			$this->display_post_type_export( $post_type );
22
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
23
+			$this->display_post_type_export($post_type);
24 24
 		}
25 25
 		$this->display_subscription_export();
26 26
 		echo '</div>';
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
 	 * Retrieves the download url.
32 32
 	 *
33 33
 	 */
34
-	public function get_download_url( $post_type ) {
34
+	public function get_download_url($post_type) {
35 35
 
36 36
 		return wp_nonce_url(
37 37
 			add_query_arg(
38 38
 				array(
39 39
 					'getpaid-admin-action' => 'export_invoices',
40
-					'post_type'            => urlencode( $post_type ),
40
+					'post_type'            => urlencode($post_type),
41 41
 				)
42 42
 			),
43 43
 			'getpaid-nonce',
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * Displays a single post type export card.
51 51
 	 *
52 52
 	 */
53
-	public function display_post_type_export( $post_type ) {
53
+	public function display_post_type_export($post_type) {
54 54
 
55 55
 		?>
56 56
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 					<strong>
62 62
 						<?php
63 63
 							printf(
64
-								esc_html__( 'Export %s', 'invoicing' ),
65
-								esc_html( getpaid_get_post_type_label( $post_type ) )
64
+								esc_html__('Export %s', 'invoicing'),
65
+								esc_html(getpaid_get_post_type_label($post_type))
66 66
 							);
67 67
 						?>
68 68
 					</strong>
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 
71 71
 				<div class="card-body">
72 72
 
73
-					<form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>">
73
+					<form method="post" action="<?php echo esc_url($this->get_download_url($post_type)); ?>">
74 74
 
75 75
 						<?php
76
-							$this->generate_from_date( $post_type );
77
-							$this->generate_to_date( $post_type );
78
-							$this->generate_post_status_select( $post_type );
79
-							$this->generate_file_type_select( $post_type );
80
-							submit_button( __( 'Download', 'invoicing' ) );
76
+							$this->generate_from_date($post_type);
77
+							$this->generate_to_date($post_type);
78
+							$this->generate_post_status_select($post_type);
79
+							$this->generate_file_type_select($post_type);
80
+							submit_button(__('Download', 'invoicing'));
81 81
 						?>
82 82
 
83 83
 					</form>
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
 	 * Generates the from date input field.
96 96
 	 *
97 97
 	 */
98
-	public function generate_from_date( $post_type ) {
98
+	public function generate_from_date($post_type) {
99 99
 
100 100
 		aui()->input(
101 101
 			array(
102 102
 				'type'             => 'datepicker',
103
-				'id'               => esc_attr( "$post_type-from_date" ),
103
+				'id'               => esc_attr("$post_type-from_date"),
104 104
 				'name'             => 'from_date',
105
-				'label'            => __( 'From Date', 'invoicing' ),
105
+				'label'            => __('From Date', 'invoicing'),
106 106
 				'label_type'       => 'vertical',
107 107
 				'placeholder'      => 'YYYY-MM-DD',
108 108
 				'extra_attributes' => array(
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 	 * Generates the to date input field.
120 120
 	 *
121 121
 	 */
122
-	public function generate_to_date( $post_type ) {
122
+	public function generate_to_date($post_type) {
123 123
 
124 124
 		aui()->input(
125 125
 			array(
126 126
 				'type'             => 'datepicker',
127
-				'id'               => esc_attr( "$post_type-to_date" ),
127
+				'id'               => esc_attr("$post_type-to_date"),
128 128
 				'name'             => 'to_date',
129
-				'label'            => __( 'To Date', 'invoicing' ),
129
+				'label'            => __('To Date', 'invoicing'),
130 130
 				'label_type'       => 'vertical',
131 131
 				'placeholder'      => 'YYYY-MM-DD',
132 132
 				'extra_attributes' => array(
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
 	 * Generates the to post status select field.
143 143
 	 *
144 144
 	 */
145
-	public function generate_post_status_select( $post_type ) {
145
+	public function generate_post_status_select($post_type) {
146 146
 
147
-		if ( 'subscriptions' === $post_type ) {
147
+		if ('subscriptions' === $post_type) {
148 148
 			$options = getpaid_get_subscription_statuses();
149 149
 		} else {
150
-			$options = wpinv_get_invoice_statuses( true, false, $post_type );
150
+			$options = wpinv_get_invoice_statuses(true, false, $post_type);
151 151
 		}
152 152
 
153 153
 		aui()->select(
154 154
 			array(
155 155
 				'name'        => 'status',
156
-				'id'          => esc_attr( "$post_type-status" ),
157
-				'placeholder' => __( 'All Statuses', 'invoicing' ),
158
-				'label'       => __( 'Status', 'invoicing' ),
156
+				'id'          => esc_attr("$post_type-status"),
157
+				'placeholder' => __('All Statuses', 'invoicing'),
158
+				'label'       => __('Status', 'invoicing'),
159 159
 				'label_type'  => 'vertical',
160 160
 				'label_class' => 'd-block',
161 161
 				'options'     => $options,
@@ -169,21 +169,21 @@  discard block
 block discarded – undo
169 169
 	 * Generates the to file type select field.
170 170
 	 *
171 171
 	 */
172
-	public function generate_file_type_select( $post_type ) {
172
+	public function generate_file_type_select($post_type) {
173 173
 
174 174
 		aui()->select(
175 175
 			array(
176 176
 				'name'        => 'file_type',
177
-				'id'          => esc_attr( "$post_type-file_type" ),
178
-				'placeholder' => __( 'Select File Type', 'invoicing' ),
179
-				'label'       => __( 'Export File', 'invoicing' ),
177
+				'id'          => esc_attr("$post_type-file_type"),
178
+				'placeholder' => __('Select File Type', 'invoicing'),
179
+				'label'       => __('Export File', 'invoicing'),
180 180
 				'label_type'  => 'vertical',
181 181
 				'label_class' => 'd-block',
182 182
 				'value'       => 'csv',
183 183
 				'options'     => array(
184
-					'csv'  => __( 'CSV', 'invoicing' ),
185
-					'xml'  => __( 'XML', 'invoicing' ),
186
-					'json' => __( 'JSON', 'invoicing' ),
184
+					'csv'  => __('CSV', 'invoicing'),
185
+					'xml'  => __('XML', 'invoicing'),
186
+					'json' => __('JSON', 'invoicing'),
187 187
 				),
188 188
 			),
189 189
 			true
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * Displays a field's markup.
196 196
 	 *
197 197
 	 */
198
-	public function display_markup( $markup ) {
198
+	public function display_markup($markup) {
199 199
 
200 200
 		echo wp_kses(
201 201
 			str_replace(
@@ -224,20 +224,20 @@  discard block
 block discarded – undo
224 224
 
225 225
 				<div class="card-header">
226 226
 					<strong>
227
-						<?php esc_html_e( 'Export Subscriptions', 'invoicing' ); ?>
227
+						<?php esc_html_e('Export Subscriptions', 'invoicing'); ?>
228 228
 					</strong>
229 229
 				</div>
230 230
 
231 231
 				<div class="card-body">
232 232
 
233
-					<form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>">
233
+					<form method="post" action="<?php echo esc_url($this->get_download_url('subscriptions')); ?>">
234 234
 
235 235
 						<?php
236
-							$this->generate_from_date( 'subscriptions' );
237
-							$this->generate_to_date( 'subscriptions' );
238
-							$this->generate_post_status_select( 'subscriptions' );
239
-							$this->generate_file_type_select( 'subscriptions' );
240
-							submit_button( __( 'Download', 'invoicing' ) );
236
+							$this->generate_from_date('subscriptions');
237
+							$this->generate_to_date('subscriptions');
238
+							$this->generate_post_status_select('subscriptions');
239
+							$this->generate_file_type_select('subscriptions');
240
+							submit_button(__('Download', 'invoicing'));
241 241
 						?>
242 242
 
243 243
 					</form>
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/includes/ayecode-ui-settings.php 3 patches
Braces   +11 added lines, -7 removed lines patch added patch discarded remove patch
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 
421 421
 			if( is_admin() && !$this->is_aui_screen()){
422 422
 				// don't add wp-admin scripts if not requested to
423
-			}else{
423
+			} else{
424 424
 				$css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
425 425
 
426 426
 				$rtl = is_rtl() ? '-rtl' : '';
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
 
1563 1563
 			if( is_admin() && !$this->is_aui_screen()){
1564 1564
 				// don't add wp-admin scripts if not requested to
1565
-			}else {
1565
+			} else {
1566 1566
 
1567 1567
 				$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
1568 1568
 
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
 						$colors[$color['slug']] = esc_attr($color['color']);
1950 1950
 					}
1951 1951
 				}
1952
-			}else{
1952
+			} else{
1953 1953
 				$settings = get_option('aui_options');
1954 1954
 				$colors = array(
1955 1955
 					'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
@@ -2036,9 +2036,9 @@  discard block
 block discarded – undo
2036 2036
 
2037 2037
 			if($compatibility===true || $compatibility===1){
2038 2038
 				$compatibility = '.bsui';
2039
-			}elseif(!$compatibility){
2039
+			} elseif(!$compatibility){
2040 2040
 				$compatibility = '';
2041
-			}else{
2041
+			} else{
2042 2042
 				$compatibility = esc_attr($compatibility);
2043 2043
 			}
2044 2044
 
@@ -2885,7 +2885,9 @@  discard block
 block discarded – undo
2885 2885
 		 * @return mixed
2886 2886
 		 */
2887 2887
 		public static function minify_js($input) {
2888
-			if(trim($input) === "") return $input;
2888
+			if(trim($input) === "") {
2889
+			    return $input;
2890
+			}
2889 2891
 			return preg_replace(
2890 2892
 				array(
2891 2893
 					// Remove comment(s)
@@ -2917,7 +2919,9 @@  discard block
 block discarded – undo
2917 2919
 		 * @return mixed
2918 2920
 		 */
2919 2921
 		public static function minify_css($input) {
2920
-			if(trim($input) === "") return $input;
2922
+			if(trim($input) === "") {
2923
+			    return $input;
2924
+			}
2921 2925
 			return preg_replace(
2922 2926
 				array(
2923 2927
 					// Remove comment(s)
Please login to merge, or discard this patch.
Indentation   +1689 added lines, -1689 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,435 +21,435 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'AyeCode_UI_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class AyeCode_UI_Settings
28
-	 * @ver 1.0.0
29
-	 * @todo decide how to implement textdomain
30
-	 */
31
-	class AyeCode_UI_Settings {
32
-
33
-		/**
34
-		 * Class version version.
35
-		 *
36
-		 * @var string
37
-		 */
38
-		public $version = '0.1.85';
39
-
40
-		/**
41
-		 * Class textdomain.
42
-		 *
43
-		 * @var string
44
-		 */
45
-		public $textdomain = 'aui';
46
-
47
-		/**
48
-		 * Latest version of Bootstrap at time of publish published.
49
-		 *
50
-		 * @var string
51
-		 */
52
-		public $latest = "4.5.3";
53
-
54
-		/**
55
-		 * Current version of select2 being used.
56
-		 *
57
-		 * @var string
58
-		 */
59
-		public $select2_version = "4.0.11";
60
-
61
-		/**
62
-		 * The title.
63
-		 *
64
-		 * @var string
65
-		 */
66
-		public $name = 'AyeCode UI';
67
-
68
-		/**
69
-		 * The relative url to the assets.
70
-		 *
71
-		 * @var string
72
-		 */
73
-		public $url = '';
74
-
75
-		/**
76
-		 * Holds the settings values.
77
-		 *
78
-		 * @var array
79
-		 */
80
-		private $settings;
81
-
82
-		/**
83
-		 * AyeCode_UI_Settings instance.
84
-		 *
85
-		 * @access private
86
-		 * @since  1.0.0
87
-		 * @var    AyeCode_UI_Settings There can be only one!
88
-		 */
89
-		private static $instance = null;
90
-
91
-
92
-		/**
93
-		 * Main AyeCode_UI_Settings Instance.
94
-		 *
95
-		 * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded.
96
-		 *
97
-		 * @since 1.0.0
98
-		 * @static
99
-		 * @return AyeCode_UI_Settings - Main instance.
100
-		 */
101
-		public static function instance() {
102
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
103
-
104
-				self::$instance = new AyeCode_UI_Settings;
105
-
106
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
107
-
108
-				if ( is_admin() ) {
109
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
110
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
111
-
112
-					// Maybe show example page
113
-					add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
114
-
115
-					if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
116
-						add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 );
117
-					}
118
-				}
119
-
120
-				add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
121
-
122
-				do_action( 'ayecode_ui_settings_loaded' );
123
-			}
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class AyeCode_UI_Settings
28
+     * @ver 1.0.0
29
+     * @todo decide how to implement textdomain
30
+     */
31
+    class AyeCode_UI_Settings {
32
+
33
+        /**
34
+         * Class version version.
35
+         *
36
+         * @var string
37
+         */
38
+        public $version = '0.1.85';
39
+
40
+        /**
41
+         * Class textdomain.
42
+         *
43
+         * @var string
44
+         */
45
+        public $textdomain = 'aui';
46
+
47
+        /**
48
+         * Latest version of Bootstrap at time of publish published.
49
+         *
50
+         * @var string
51
+         */
52
+        public $latest = "4.5.3";
53
+
54
+        /**
55
+         * Current version of select2 being used.
56
+         *
57
+         * @var string
58
+         */
59
+        public $select2_version = "4.0.11";
60
+
61
+        /**
62
+         * The title.
63
+         *
64
+         * @var string
65
+         */
66
+        public $name = 'AyeCode UI';
67
+
68
+        /**
69
+         * The relative url to the assets.
70
+         *
71
+         * @var string
72
+         */
73
+        public $url = '';
74
+
75
+        /**
76
+         * Holds the settings values.
77
+         *
78
+         * @var array
79
+         */
80
+        private $settings;
81
+
82
+        /**
83
+         * AyeCode_UI_Settings instance.
84
+         *
85
+         * @access private
86
+         * @since  1.0.0
87
+         * @var    AyeCode_UI_Settings There can be only one!
88
+         */
89
+        private static $instance = null;
90
+
91
+
92
+        /**
93
+         * Main AyeCode_UI_Settings Instance.
94
+         *
95
+         * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded.
96
+         *
97
+         * @since 1.0.0
98
+         * @static
99
+         * @return AyeCode_UI_Settings - Main instance.
100
+         */
101
+        public static function instance() {
102
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
103
+
104
+                self::$instance = new AyeCode_UI_Settings;
105
+
106
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
107
+
108
+                if ( is_admin() ) {
109
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
110
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
111
+
112
+                    // Maybe show example page
113
+                    add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
114
+
115
+                    if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
116
+                        add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 );
117
+                    }
118
+                }
124 119
 
125
-			return self::$instance;
126
-		}
120
+                add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
127 121
 
128
-		/**
129
-		 * Add custom colors to the color selector.
130
-		 *
131
-		 * @param $theme_colors
132
-		 * @param $include_outlines
133
-		 * @param $include_branding
134
-		 *
135
-		 * @return mixed
136
-		 */
137
-		public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){
122
+                do_action( 'ayecode_ui_settings_loaded' );
123
+            }
138 124
 
125
+            return self::$instance;
126
+        }
139 127
 
140
-			$setting = wp_get_global_settings();
128
+        /**
129
+         * Add custom colors to the color selector.
130
+         *
131
+         * @param $theme_colors
132
+         * @param $include_outlines
133
+         * @param $include_branding
134
+         *
135
+         * @return mixed
136
+         */
137
+        public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){
141 138
 
142
-			if(!empty($setting['color']['palette']['custom'])){
143
-				foreach($setting['color']['palette']['custom'] as $color){
144
-					$theme_colors[$color['slug']] = esc_attr($color['name']);
145
-				}
146
-			}
147
-
148
-			return $theme_colors;
149
-		}
150
-
151
-		/**
152
-		 * Setup some constants.
153
-		 */
154
-		public function constants(){
155
-			define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" );
156
-			define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' );
157
-			define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' );
158
-			define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' );
159
-			define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' );
160
-			define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' );
161
-			define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' );
162
-			define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' );
163
-			define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' );
164
-			define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' );
165
-			define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' );
166
-			define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' );
167
-			define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' );
168
-			define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' );
169
-			define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' );
170
-			define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' );
171
-
172
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173
-				define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
174
-			}
175
-			if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) {
176
-				define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL );
177
-			}
178
-			if ( ! defined( 'AUI_INFO_COLOR' ) ) {
179
-				define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL );
180
-			}
181
-			if ( ! defined( 'AUI_WARNING_COLOR' ) ) {
182
-				define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL );
183
-			}
184
-			if ( ! defined( 'AUI_DANGER_COLOR' ) ) {
185
-				define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL );
186
-			}
187
-			if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) {
188
-				define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL );
189
-			}
190
-			if ( ! defined( 'AUI_LIGHT_COLOR' ) ) {
191
-				define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL );
192
-			}
193
-			if ( ! defined( 'AUI_DARK_COLOR' ) ) {
194
-				define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL );
195
-			}
196
-			if ( ! defined( 'AUI_WHITE_COLOR' ) ) {
197
-				define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL );
198
-			}
199
-			if ( ! defined( 'AUI_PURPLE_COLOR' ) ) {
200
-				define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL );
201
-			}
202
-			if ( ! defined( 'AUI_SALMON_COLOR' ) ) {
203
-				define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL );
204
-			}
205
-			if ( ! defined( 'AUI_CYAN_COLOR' ) ) {
206
-				define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL );
207
-			}
208
-			if ( ! defined( 'AUI_GRAY_COLOR' ) ) {
209
-				define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL );
210
-			}
211
-			if ( ! defined( 'AUI_INDIGO_COLOR' ) ) {
212
-				define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL );
213
-			}
214
-			if ( ! defined( 'AUI_ORANGE_COLOR' ) ) {
215
-				define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL );
216
-			}
217
-			if ( ! defined( 'AUI_BLACK_COLOR' ) ) {
218
-				define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL );
219
-			}
220
-
221
-		}
222
-
223
-		public static function get_colors( $original = false){
224
-
225
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
226
-				return array();
227
-			}
228
-			if ( $original ) {
229
-				return array(
230
-					'primary'   => AUI_PRIMARY_COLOR_ORIGINAL,
231
-					'secondary' => AUI_SECONDARY_COLOR_ORIGINAL,
232
-					'info'      => AUI_INFO_COLOR_ORIGINAL,
233
-					'warning'   => AUI_WARNING_COLOR_ORIGINAL,
234
-					'danger'    => AUI_DANGER_COLOR_ORIGINAL,
235
-					'success'   => AUI_SUCCESS_COLOR_ORIGINAL,
236
-					'light'     => AUI_LIGHT_COLOR_ORIGINAL,
237
-					'dark'      => AUI_DARK_COLOR_ORIGINAL,
238
-					'white'     => AUI_WHITE_COLOR_ORIGINAL,
239
-					'purple'    => AUI_PURPLE_COLOR_ORIGINAL,
240
-					'salmon'    => AUI_SALMON_COLOR_ORIGINAL,
241
-					'cyan'      => AUI_CYAN_COLOR_ORIGINAL,
242
-					'gray'      => AUI_GRAY_COLOR_ORIGINAL,
243
-					'indigo'    => AUI_INDIGO_COLOR_ORIGINAL,
244
-					'orange'    => AUI_ORANGE_COLOR_ORIGINAL,
245
-					'black'     => AUI_BLACK_COLOR_ORIGINAL,
246
-				);
247
-			}
248
-
249
-			return array(
250
-				'primary'   => AUI_PRIMARY_COLOR,
251
-				'secondary' => AUI_SECONDARY_COLOR,
252
-				'info'      => AUI_INFO_COLOR,
253
-				'warning'   => AUI_WARNING_COLOR,
254
-				'danger'    => AUI_DANGER_COLOR,
255
-				'success'   => AUI_SUCCESS_COLOR,
256
-				'light'     => AUI_LIGHT_COLOR,
257
-				'dark'      => AUI_DARK_COLOR,
258
-				'white'     => AUI_WHITE_COLOR,
259
-				'purple'    => AUI_PURPLE_COLOR,
260
-				'salmon'    => AUI_SALMON_COLOR,
261
-				'cyan'      => AUI_CYAN_COLOR,
262
-				'gray'      => AUI_GRAY_COLOR,
263
-				'indigo'    => AUI_INDIGO_COLOR,
264
-				'orange'    => AUI_ORANGE_COLOR,
265
-				'black'     => AUI_BLACK_COLOR,
266
-			);
267
-		}
268
-
269
-		/**
270
-		 * Initiate the settings and add the required action hooks.
271
-		 */
272
-		public function init() {
273
-
274
-			// Maybe fix settings
275
-			if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) {
276
-				$db_settings = get_option( 'ayecode-ui-settings' );
277
-				if ( ! empty( $db_settings ) ) {
278
-					$db_settings['css_backend'] = 'compatibility';
279
-					$db_settings['js_backend'] = 'core-popper';
280
-					update_option( 'ayecode-ui-settings', $db_settings );
281
-					wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true"));
282
-				}
283
-			}
284 139
 
285
-			$this->constants();
286
-			$this->settings = $this->get_settings();
287
-			$this->url = $this->get_url();
140
+            $setting = wp_get_global_settings();
288 141
 
289
-			/**
290
-			 * Maybe load CSS
291
-			 *
292
-			 * We load super early in case there is a theme version that might change the colors
293
-			 */
294
-			if ( $this->settings['css'] ) {
295
-				$priority = $this->is_bs3_compat() ? 100 : 1;
296
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority );
297
-			}
298
-			if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
299
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
300
-			}
301
-
302
-			// maybe load JS
303
-			if ( $this->settings['js'] ) {
304
-				$priority = $this->is_bs3_compat() ? 100 : 1;
305
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
306
-			}
307
-			if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
308
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
309
-			}
310
-
311
-			// Maybe set the HTML font size
312
-			if ( $this->settings['html_font_size'] ) {
313
-				add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
314
-			}
315
-
316
-			// Maybe show backend style error
317
-			if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){
318
-				add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) );
319
-			}
320
-
321
-		}
322
-
323
-		/**
324
-		 * Show admin notice if backend scripts not loaded.
325
-		 */
326
-		public function show_admin_style_notice(){
327
-			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin'));
328
-			$button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>';
329
-			$message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button;
330
-			echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>';
331
-		}
332
-
333
-		/**
334
-		 * Check if we should load the admin scripts or not.
335
-		 *
336
-		 * @return bool
337
-		 */
338
-		public function load_admin_scripts(){
339
-			$result = true;
340
-
341
-			// check if specifically disabled
342
-			if(!empty($this->settings['disable_admin'])){
343
-				$url_parts = explode("\n",$this->settings['disable_admin']);
344
-				foreach($url_parts as $part){
345
-					if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
346
-						return false; // return early, no point checking further
347
-					}
348
-				}
349
-			}
350
-
351
-			return $result;
352
-		}
353
-
354
-		/**
355
-		 * Add a html font size to the footer.
356
-		 */
357
-		public function html_font_size(){
358
-			$this->settings = $this->get_settings();
359
-			echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
360
-		}
361
-
362
-		/**
363
-		 * Check if the current admin screen should load scripts.
364
-		 *
365
-		 * @return bool
366
-		 */
367
-		public function is_aui_screen(){
142
+            if(!empty($setting['color']['palette']['custom'])){
143
+                foreach($setting['color']['palette']['custom'] as $color){
144
+                    $theme_colors[$color['slug']] = esc_attr($color['name']);
145
+                }
146
+            }
147
+
148
+            return $theme_colors;
149
+        }
150
+
151
+        /**
152
+         * Setup some constants.
153
+         */
154
+        public function constants(){
155
+            define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" );
156
+            define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' );
157
+            define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' );
158
+            define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' );
159
+            define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' );
160
+            define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' );
161
+            define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' );
162
+            define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' );
163
+            define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' );
164
+            define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' );
165
+            define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' );
166
+            define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' );
167
+            define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' );
168
+            define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' );
169
+            define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' );
170
+            define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' );
171
+
172
+            if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173
+                define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
174
+            }
175
+            if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) {
176
+                define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL );
177
+            }
178
+            if ( ! defined( 'AUI_INFO_COLOR' ) ) {
179
+                define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL );
180
+            }
181
+            if ( ! defined( 'AUI_WARNING_COLOR' ) ) {
182
+                define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL );
183
+            }
184
+            if ( ! defined( 'AUI_DANGER_COLOR' ) ) {
185
+                define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL );
186
+            }
187
+            if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) {
188
+                define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL );
189
+            }
190
+            if ( ! defined( 'AUI_LIGHT_COLOR' ) ) {
191
+                define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL );
192
+            }
193
+            if ( ! defined( 'AUI_DARK_COLOR' ) ) {
194
+                define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL );
195
+            }
196
+            if ( ! defined( 'AUI_WHITE_COLOR' ) ) {
197
+                define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL );
198
+            }
199
+            if ( ! defined( 'AUI_PURPLE_COLOR' ) ) {
200
+                define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL );
201
+            }
202
+            if ( ! defined( 'AUI_SALMON_COLOR' ) ) {
203
+                define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL );
204
+            }
205
+            if ( ! defined( 'AUI_CYAN_COLOR' ) ) {
206
+                define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL );
207
+            }
208
+            if ( ! defined( 'AUI_GRAY_COLOR' ) ) {
209
+                define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL );
210
+            }
211
+            if ( ! defined( 'AUI_INDIGO_COLOR' ) ) {
212
+                define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL );
213
+            }
214
+            if ( ! defined( 'AUI_ORANGE_COLOR' ) ) {
215
+                define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL );
216
+            }
217
+            if ( ! defined( 'AUI_BLACK_COLOR' ) ) {
218
+                define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL );
219
+            }
220
+
221
+        }
222
+
223
+        public static function get_colors( $original = false){
224
+
225
+            if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
226
+                return array();
227
+            }
228
+            if ( $original ) {
229
+                return array(
230
+                    'primary'   => AUI_PRIMARY_COLOR_ORIGINAL,
231
+                    'secondary' => AUI_SECONDARY_COLOR_ORIGINAL,
232
+                    'info'      => AUI_INFO_COLOR_ORIGINAL,
233
+                    'warning'   => AUI_WARNING_COLOR_ORIGINAL,
234
+                    'danger'    => AUI_DANGER_COLOR_ORIGINAL,
235
+                    'success'   => AUI_SUCCESS_COLOR_ORIGINAL,
236
+                    'light'     => AUI_LIGHT_COLOR_ORIGINAL,
237
+                    'dark'      => AUI_DARK_COLOR_ORIGINAL,
238
+                    'white'     => AUI_WHITE_COLOR_ORIGINAL,
239
+                    'purple'    => AUI_PURPLE_COLOR_ORIGINAL,
240
+                    'salmon'    => AUI_SALMON_COLOR_ORIGINAL,
241
+                    'cyan'      => AUI_CYAN_COLOR_ORIGINAL,
242
+                    'gray'      => AUI_GRAY_COLOR_ORIGINAL,
243
+                    'indigo'    => AUI_INDIGO_COLOR_ORIGINAL,
244
+                    'orange'    => AUI_ORANGE_COLOR_ORIGINAL,
245
+                    'black'     => AUI_BLACK_COLOR_ORIGINAL,
246
+                );
247
+            }
248
+
249
+            return array(
250
+                'primary'   => AUI_PRIMARY_COLOR,
251
+                'secondary' => AUI_SECONDARY_COLOR,
252
+                'info'      => AUI_INFO_COLOR,
253
+                'warning'   => AUI_WARNING_COLOR,
254
+                'danger'    => AUI_DANGER_COLOR,
255
+                'success'   => AUI_SUCCESS_COLOR,
256
+                'light'     => AUI_LIGHT_COLOR,
257
+                'dark'      => AUI_DARK_COLOR,
258
+                'white'     => AUI_WHITE_COLOR,
259
+                'purple'    => AUI_PURPLE_COLOR,
260
+                'salmon'    => AUI_SALMON_COLOR,
261
+                'cyan'      => AUI_CYAN_COLOR,
262
+                'gray'      => AUI_GRAY_COLOR,
263
+                'indigo'    => AUI_INDIGO_COLOR,
264
+                'orange'    => AUI_ORANGE_COLOR,
265
+                'black'     => AUI_BLACK_COLOR,
266
+            );
267
+        }
268
+
269
+        /**
270
+         * Initiate the settings and add the required action hooks.
271
+         */
272
+        public function init() {
273
+
274
+            // Maybe fix settings
275
+            if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) {
276
+                $db_settings = get_option( 'ayecode-ui-settings' );
277
+                if ( ! empty( $db_settings ) ) {
278
+                    $db_settings['css_backend'] = 'compatibility';
279
+                    $db_settings['js_backend'] = 'core-popper';
280
+                    update_option( 'ayecode-ui-settings', $db_settings );
281
+                    wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true"));
282
+                }
283
+            }
284
+
285
+            $this->constants();
286
+            $this->settings = $this->get_settings();
287
+            $this->url = $this->get_url();
288
+
289
+            /**
290
+             * Maybe load CSS
291
+             *
292
+             * We load super early in case there is a theme version that might change the colors
293
+             */
294
+            if ( $this->settings['css'] ) {
295
+                $priority = $this->is_bs3_compat() ? 100 : 1;
296
+                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority );
297
+            }
298
+            if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
299
+                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
300
+            }
301
+
302
+            // maybe load JS
303
+            if ( $this->settings['js'] ) {
304
+                $priority = $this->is_bs3_compat() ? 100 : 1;
305
+                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
306
+            }
307
+            if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
308
+                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
309
+            }
310
+
311
+            // Maybe set the HTML font size
312
+            if ( $this->settings['html_font_size'] ) {
313
+                add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
314
+            }
315
+
316
+            // Maybe show backend style error
317
+            if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){
318
+                add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) );
319
+            }
320
+
321
+        }
322
+
323
+        /**
324
+         * Show admin notice if backend scripts not loaded.
325
+         */
326
+        public function show_admin_style_notice(){
327
+            $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin'));
328
+            $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>';
329
+            $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button;
330
+            echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>';
331
+        }
332
+
333
+        /**
334
+         * Check if we should load the admin scripts or not.
335
+         *
336
+         * @return bool
337
+         */
338
+        public function load_admin_scripts(){
339
+            $result = true;
340
+
341
+            // check if specifically disabled
342
+            if(!empty($this->settings['disable_admin'])){
343
+                $url_parts = explode("\n",$this->settings['disable_admin']);
344
+                foreach($url_parts as $part){
345
+                    if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
346
+                        return false; // return early, no point checking further
347
+                    }
348
+                }
349
+            }
350
+
351
+            return $result;
352
+        }
353
+
354
+        /**
355
+         * Add a html font size to the footer.
356
+         */
357
+        public function html_font_size(){
358
+            $this->settings = $this->get_settings();
359
+            echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
360
+        }
361
+
362
+        /**
363
+         * Check if the current admin screen should load scripts.
364
+         *
365
+         * @return bool
366
+         */
367
+        public function is_aui_screen(){
368 368
 //			echo '###';exit;
369
-			$load = false;
370
-			// check if we should load or not
371
-			if ( is_admin() ) {
372
-				// Only enable on set pages
373
-				$aui_screens = array(
374
-					'page',
375
-					'post',
376
-					'settings_page_ayecode-ui-settings',
377
-					'appearance_page_gutenberg-widgets',
378
-					'widgets',
379
-					'ayecode-ui-settings',
380
-					'site-editor'
381
-				);
382
-				$screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
383
-
384
-				$screen = get_current_screen();
369
+            $load = false;
370
+            // check if we should load or not
371
+            if ( is_admin() ) {
372
+                // Only enable on set pages
373
+                $aui_screens = array(
374
+                    'page',
375
+                    'post',
376
+                    'settings_page_ayecode-ui-settings',
377
+                    'appearance_page_gutenberg-widgets',
378
+                    'widgets',
379
+                    'ayecode-ui-settings',
380
+                    'site-editor'
381
+                );
382
+                $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
383
+
384
+                $screen = get_current_screen();
385 385
 
386 386
 //				echo '###'.$screen->id;
387 387
 
388
-				// check if we are on a AUI screen
389
-				if ( $screen && in_array( $screen->id, $screen_ids ) ) {
390
-					$load = true;
391
-				}
388
+                // check if we are on a AUI screen
389
+                if ( $screen && in_array( $screen->id, $screen_ids ) ) {
390
+                    $load = true;
391
+                }
392 392
 
393
-				//load for widget previews in WP 5.8
394
-				if( !empty($_REQUEST['legacy-widget-preview'])){
395
-					$load = true;
396
-				}
397
-			}
393
+                //load for widget previews in WP 5.8
394
+                if( !empty($_REQUEST['legacy-widget-preview'])){
395
+                    $load = true;
396
+                }
397
+            }
398 398
 
399
-			return apply_filters( 'aui_load_on_admin' , $load );
400
-		}
399
+            return apply_filters( 'aui_load_on_admin' , $load );
400
+        }
401 401
 
402
-		/**
403
-		 * Check if the current theme is a block theme.
404
-		 *
405
-		 * @return bool
406
-		 */
407
-		public static function is_block_theme() {
408
-			if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) {
409
-				return true;
410
-			}
402
+        /**
403
+         * Check if the current theme is a block theme.
404
+         *
405
+         * @return bool
406
+         */
407
+        public static function is_block_theme() {
408
+            if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) {
409
+                return true;
410
+            }
411 411
 
412
-			return false;
413
-		}
412
+            return false;
413
+        }
414 414
 
415
-		/**
416
-		 * Adds the styles.
417
-		 */
418
-		public function enqueue_style() {
415
+        /**
416
+         * Adds the styles.
417
+         */
418
+        public function enqueue_style() {
419 419
 
420 420
 
421
-			if( is_admin() && !$this->is_aui_screen()){
422
-				// don't add wp-admin scripts if not requested to
423
-			}else{
424
-				$css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
421
+            if( is_admin() && !$this->is_aui_screen()){
422
+                // don't add wp-admin scripts if not requested to
423
+            }else{
424
+                $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
425 425
 
426
-				$rtl = is_rtl() ? '-rtl' : '';
426
+                $rtl = is_rtl() ? '-rtl' : '';
427 427
 
428
-				if($this->settings[$css_setting]){
429
-					$compatibility = $this->settings[$css_setting]=='core' ? false : true;
430
-					$url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css';
428
+                if($this->settings[$css_setting]){
429
+                    $compatibility = $this->settings[$css_setting]=='core' ? false : true;
430
+                    $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css';
431 431
 
432 432
 
433 433
 
434
-					wp_register_style( 'ayecode-ui', $url, array(), $this->version );
435
-					wp_enqueue_style( 'ayecode-ui' );
434
+                    wp_register_style( 'ayecode-ui', $url, array(), $this->version );
435
+                    wp_enqueue_style( 'ayecode-ui' );
436 436
 
437
-					$current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
437
+                    $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
438 438
 
439 439
 //					if ( is_admin() && !empty($_REQUEST['postType']) ) {
440
-					if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
441
-						$url = $this->url.'assets/css/ayecode-ui-fse.css';
442
-						wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version );
443
-						wp_enqueue_style( 'ayecode-ui-fse' );
444
-					}
440
+                    if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
441
+                        $url = $this->url.'assets/css/ayecode-ui-fse.css';
442
+                        wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version );
443
+                        wp_enqueue_style( 'ayecode-ui-fse' );
444
+                    }
445 445
 
446 446
 
447
-					// flatpickr
448
-					wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->version );
447
+                    // flatpickr
448
+                    wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->version );
449 449
 
450
-					// fix some wp-admin issues
451
-					if(is_admin()){
452
-						$custom_css = "
450
+                    // fix some wp-admin issues
451
+                    if(is_admin()){
452
+                        $custom_css = "
453 453
                 body{
454 454
                     background-color: #f1f1f1;
455 455
                     font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif;
@@ -495,35 +495,35 @@  discard block
 block discarded – undo
495 495
 				}
496 496
                 ";
497 497
 
498
-						// @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
499
-						$custom_css .= "
498
+                        // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
499
+                        $custom_css .= "
500 500
 						.edit-post-sidebar input[type=color].components-text-control__input{
501 501
 						    padding: 0;
502 502
 						}
503 503
 					";
504
-						wp_add_inline_style( 'ayecode-ui', $custom_css );
505
-					}
504
+                        wp_add_inline_style( 'ayecode-ui', $custom_css );
505
+                    }
506 506
 
507
-					// custom changes
508
-					wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
507
+                    // custom changes
508
+                    wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
509 509
 
510
-				}
511
-			}
510
+                }
511
+            }
512 512
 
513 513
 
514
-		}
514
+        }
515 515
 
516
-		/**
517
-		 * Get inline script used if bootstrap enqueued
518
-		 *
519
-		 * If this remains small then its best to use this than to add another JS file.
520
-		 */
521
-		public function inline_script() {
522
-			// Flatpickr calendar locale
523
-			$flatpickr_locale = self::flatpickr_locale();
516
+        /**
517
+         * Get inline script used if bootstrap enqueued
518
+         *
519
+         * If this remains small then its best to use this than to add another JS file.
520
+         */
521
+        public function inline_script() {
522
+            // Flatpickr calendar locale
523
+            $flatpickr_locale = self::flatpickr_locale();
524 524
 
525
-			ob_start();
526
-			?>
525
+            ob_start();
526
+            ?>
527 527
             <script>
528 528
                 /**
529 529
                  * An AUI bootstrap adaptation of GreedyNav.js ( by Luke Jackson ).
@@ -1460,8 +1460,8 @@  discard block
 block discarded – undo
1460 1460
                 aui_set_data_scroll();
1461 1461
 
1462 1462
 				<?php
1463
-				// FSE tweaks.
1464
-				if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?>
1463
+                // FSE tweaks.
1464
+                if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?>
1465 1465
                 function aui_fse_set_data_scroll() {
1466 1466
                     console.log('init scroll');
1467 1467
                     let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas");
@@ -1494,29 +1494,29 @@  discard block
 block discarded – undo
1494 1494
 
1495 1495
             </script>
1496 1496
 			<?php
1497
-			$output = ob_get_clean();
1497
+            $output = ob_get_clean();
1498 1498
 
1499 1499
 
1500 1500
 
1501
-			/*
1501
+            /*
1502 1502
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1503 1503
 			 */
1504
-			return str_replace( array(
1505
-				'<script>',
1506
-				'</script>'
1507
-			), '', self::minify_js($output) );
1508
-		}
1509
-
1510
-
1511
-		/**
1512
-		 * JS to help with conflict issues with other plugins and themes using bootstrap v3.
1513
-		 *
1514
-		 * @TODO we may need this when other conflicts arrise.
1515
-		 * @return mixed
1516
-		 */
1517
-		public static function bs3_compat_js() {
1518
-			ob_start();
1519
-			?>
1504
+            return str_replace( array(
1505
+                '<script>',
1506
+                '</script>'
1507
+            ), '', self::minify_js($output) );
1508
+        }
1509
+
1510
+
1511
+        /**
1512
+         * JS to help with conflict issues with other plugins and themes using bootstrap v3.
1513
+         *
1514
+         * @TODO we may need this when other conflicts arrise.
1515
+         * @return mixed
1516
+         */
1517
+        public static function bs3_compat_js() {
1518
+            ob_start();
1519
+            ?>
1520 1520
             <script>
1521 1521
 				<?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
1522 1522
                 /* With Avada builder */
@@ -1524,20 +1524,20 @@  discard block
 block discarded – undo
1524 1524
 				<?php } ?>
1525 1525
             </script>
1526 1526
 			<?php
1527
-			return str_replace( array(
1528
-				'<script>',
1529
-				'</script>'
1530
-			), '', ob_get_clean());
1531
-		}
1532
-
1533
-		/**
1534
-		 * Get inline script used if bootstrap file browser enqueued.
1535
-		 *
1536
-		 * If this remains small then its best to use this than to add another JS file.
1537
-		 */
1538
-		public function inline_script_file_browser(){
1539
-			ob_start();
1540
-			?>
1527
+            return str_replace( array(
1528
+                '<script>',
1529
+                '</script>'
1530
+            ), '', ob_get_clean());
1531
+        }
1532
+
1533
+        /**
1534
+         * Get inline script used if bootstrap file browser enqueued.
1535
+         *
1536
+         * If this remains small then its best to use this than to add another JS file.
1537
+         */
1538
+        public function inline_script_file_browser(){
1539
+            ob_start();
1540
+            ?>
1541 1541
             <script>
1542 1542
                 // run on doc ready
1543 1543
                 jQuery(document).ready(function () {
@@ -1545,227 +1545,227 @@  discard block
 block discarded – undo
1545 1545
                 });
1546 1546
             </script>
1547 1547
 			<?php
1548
-			$output = ob_get_clean();
1548
+            $output = ob_get_clean();
1549 1549
 
1550
-			/*
1550
+            /*
1551 1551
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1552 1552
 			 */
1553
-			return str_replace( array(
1554
-				'<script>',
1555
-				'</script>'
1556
-			), '', $output );
1557
-		}
1558
-
1559
-		/**
1560
-		 * Adds the Font Awesome JS.
1561
-		 */
1562
-		public function enqueue_scripts() {
1563
-
1564
-			if( is_admin() && !$this->is_aui_screen()){
1565
-				// don't add wp-admin scripts if not requested to
1566
-			}else {
1567
-
1568
-				$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
1569
-
1570
-				// select2
1571
-				wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
1572
-
1573
-				// flatpickr
1574
-				wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
1575
-
1576
-				// flatpickr
1577
-				wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
1578
-
1579
-				// Bootstrap file browser
1580
-				wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
1581
-				wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
1582
-
1583
-				$load_inline = false;
1584
-
1585
-				if ( $this->settings[ $js_setting ] == 'core-popper' ) {
1586
-					// Bootstrap bundle
1587
-					$url = $this->url . 'assets/js/bootstrap.bundle.min.js';
1588
-					wp_register_script( 'bootstrap-js-bundle', $url, array(
1589
-						'select2',
1590
-						'jquery'
1591
-					), $this->version, $this->is_bs3_compat() );
1592
-					// if in admin then add to footer for compatibility.
1593
-					is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
1594
-					$script = $this->inline_script();
1595
-					wp_add_inline_script( 'bootstrap-js-bundle', $script );
1596
-				} elseif ( $this->settings[ $js_setting ] == 'popper' ) {
1597
-					$url = $this->url . 'assets/js/popper.min.js';
1598
-					wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
1599
-					wp_enqueue_script( 'bootstrap-js-popper' );
1600
-					$load_inline = true;
1601
-				} else {
1602
-					$load_inline = true;
1603
-				}
1604
-
1605
-				// Load needed inline scripts by faking the loading of a script if the main script is not being loaded
1606
-				if ( $load_inline ) {
1607
-					wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
1608
-					wp_enqueue_script( 'bootstrap-dummy' );
1609
-					$script = $this->inline_script();
1610
-					wp_add_inline_script( 'bootstrap-dummy', $script );
1611
-				}
1612
-			}
1613
-
1614
-		}
1615
-
1616
-		/**
1617
-		 * Enqueue flatpickr if called.
1618
-		 */
1619
-		public function enqueue_flatpickr(){
1620
-			wp_enqueue_style( 'flatpickr' );
1621
-			wp_enqueue_script( 'flatpickr' );
1622
-		}
1623
-
1624
-		/**
1625
-		 * Enqueue iconpicker if called.
1626
-		 */
1627
-		public function enqueue_iconpicker(){
1628
-			wp_enqueue_style( 'iconpicker' );
1629
-			wp_enqueue_script( 'iconpicker' );
1630
-		}
1631
-
1632
-		/**
1633
-		 * Get the url path to the current folder.
1634
-		 *
1635
-		 * @return string
1636
-		 */
1637
-		public function get_url() {
1638
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1639
-			$content_url = untrailingslashit( WP_CONTENT_URL );
1640
-
1641
-			// Replace http:// to https://.
1642
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1643
-				$content_url = str_replace( 'http://', 'https://', $content_url );
1644
-			}
1645
-
1646
-			// Check if we are inside a plugin
1647
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1648
-			$url = str_replace( $content_dir, $content_url, $file_dir );
1649
-
1650
-			return trailingslashit( $url );
1651
-		}
1652
-
1653
-		/**
1654
-		 * Get the url path to the current folder.
1655
-		 *
1656
-		 * @return string
1657
-		 */
1658
-		public function get_url_old() {
1659
-
1660
-			$url = '';
1661
-			// check if we are inside a plugin
1662
-			$file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
1663
-
1664
-			// add check in-case user has changed wp-content dir name.
1665
-			$wp_content_folder_name = basename(WP_CONTENT_DIR);
1666
-			$dir_parts = explode("/$wp_content_folder_name/",$file_dir);
1667
-			$url_parts = explode("/$wp_content_folder_name/",plugins_url());
1668
-
1669
-			if(!empty($url_parts[0]) && !empty($dir_parts[1])){
1670
-				$url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
1671
-			}
1672
-
1673
-			return $url;
1674
-		}
1675
-
1676
-		/**
1677
-		 * Register the database settings with WordPress.
1678
-		 */
1679
-		public function register_settings() {
1680
-			register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
1681
-		}
1682
-
1683
-		/**
1684
-		 * Add the WordPress settings menu item.
1685
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
1686
-		 */
1687
-		public function menu_item() {
1688
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
1689
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
1690
-				$this,
1691
-				'settings_page'
1692
-			) );
1693
-		}
1694
-
1695
-		/**
1696
-		 * Get a list of themes and their default JS settings.
1697
-		 *
1698
-		 * @return array
1699
-		 */
1700
-		public function theme_js_settings(){
1701
-			return array(
1702
-				'ayetheme' => 'popper',
1703
-				'listimia' => 'required',
1704
-				'listimia_backend' => 'core-popper',
1705
-				//'avada'    => 'required', // removed as we now add compatibility
1706
-			);
1707
-		}
1708
-
1709
-		/**
1710
-		 * Get the current Font Awesome output settings.
1711
-		 *
1712
-		 * @return array The array of settings.
1713
-		 */
1714
-		public function get_settings() {
1715
-
1716
-			$db_settings = get_option( 'ayecode-ui-settings' );
1717
-			$js_default = 'core-popper';
1718
-			$js_default_backend = $js_default;
1719
-
1720
-			// maybe set defaults (if no settings set)
1721
-			if(empty($db_settings)){
1722
-				$active_theme = strtolower( get_template() ); // active parent theme.
1723
-				$theme_js_settings = self::theme_js_settings();
1724
-				if(isset($theme_js_settings[$active_theme])){
1725
-					$js_default = $theme_js_settings[$active_theme];
1726
-					$js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
1727
-				}
1728
-			}
1553
+            return str_replace( array(
1554
+                '<script>',
1555
+                '</script>'
1556
+            ), '', $output );
1557
+        }
1558
+
1559
+        /**
1560
+         * Adds the Font Awesome JS.
1561
+         */
1562
+        public function enqueue_scripts() {
1563
+
1564
+            if( is_admin() && !$this->is_aui_screen()){
1565
+                // don't add wp-admin scripts if not requested to
1566
+            }else {
1567
+
1568
+                $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
1569
+
1570
+                // select2
1571
+                wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
1572
+
1573
+                // flatpickr
1574
+                wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
1575
+
1576
+                // flatpickr
1577
+                wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
1578
+
1579
+                // Bootstrap file browser
1580
+                wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
1581
+                wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
1582
+
1583
+                $load_inline = false;
1584
+
1585
+                if ( $this->settings[ $js_setting ] == 'core-popper' ) {
1586
+                    // Bootstrap bundle
1587
+                    $url = $this->url . 'assets/js/bootstrap.bundle.min.js';
1588
+                    wp_register_script( 'bootstrap-js-bundle', $url, array(
1589
+                        'select2',
1590
+                        'jquery'
1591
+                    ), $this->version, $this->is_bs3_compat() );
1592
+                    // if in admin then add to footer for compatibility.
1593
+                    is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
1594
+                    $script = $this->inline_script();
1595
+                    wp_add_inline_script( 'bootstrap-js-bundle', $script );
1596
+                } elseif ( $this->settings[ $js_setting ] == 'popper' ) {
1597
+                    $url = $this->url . 'assets/js/popper.min.js';
1598
+                    wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
1599
+                    wp_enqueue_script( 'bootstrap-js-popper' );
1600
+                    $load_inline = true;
1601
+                } else {
1602
+                    $load_inline = true;
1603
+                }
1729 1604
 
1730
-			/**
1731
-			 * Filter the default settings.
1732
-			 */
1733
-			$defaults = apply_filters( 'ayecode-ui-default-settings', array(
1734
-				'css'            => 'compatibility', // core, compatibility
1735
-				'js'             => $js_default, // js to load, core-popper, popper
1736
-				'html_font_size' => '16', // js to load, core-popper, popper
1737
-				'css_backend'    => 'compatibility', // core, compatibility
1738
-				'js_backend'     => $js_default_backend, // js to load, core-popper, popper
1739
-				'disable_admin'  => '', // URL snippets to disable loading on admin
1740
-			), $db_settings );
1741
-
1742
-			$settings = wp_parse_args( $db_settings, $defaults );
1743
-
1744
-			/**
1745
-			 * Filter the Bootstrap settings.
1746
-			 *
1747
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
1748
-			 */
1749
-			return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
1750
-		}
1751
-
1752
-
1753
-		/**
1754
-		 * The settings page html output.
1755
-		 */
1756
-		public function settings_page() {
1757
-			if ( ! current_user_can( 'manage_options' ) ) {
1758
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) );
1759
-			}
1760
-			?>
1605
+                // Load needed inline scripts by faking the loading of a script if the main script is not being loaded
1606
+                if ( $load_inline ) {
1607
+                    wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
1608
+                    wp_enqueue_script( 'bootstrap-dummy' );
1609
+                    $script = $this->inline_script();
1610
+                    wp_add_inline_script( 'bootstrap-dummy', $script );
1611
+                }
1612
+            }
1613
+
1614
+        }
1615
+
1616
+        /**
1617
+         * Enqueue flatpickr if called.
1618
+         */
1619
+        public function enqueue_flatpickr(){
1620
+            wp_enqueue_style( 'flatpickr' );
1621
+            wp_enqueue_script( 'flatpickr' );
1622
+        }
1623
+
1624
+        /**
1625
+         * Enqueue iconpicker if called.
1626
+         */
1627
+        public function enqueue_iconpicker(){
1628
+            wp_enqueue_style( 'iconpicker' );
1629
+            wp_enqueue_script( 'iconpicker' );
1630
+        }
1631
+
1632
+        /**
1633
+         * Get the url path to the current folder.
1634
+         *
1635
+         * @return string
1636
+         */
1637
+        public function get_url() {
1638
+            $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1639
+            $content_url = untrailingslashit( WP_CONTENT_URL );
1640
+
1641
+            // Replace http:// to https://.
1642
+            if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1643
+                $content_url = str_replace( 'http://', 'https://', $content_url );
1644
+            }
1645
+
1646
+            // Check if we are inside a plugin
1647
+            $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1648
+            $url = str_replace( $content_dir, $content_url, $file_dir );
1649
+
1650
+            return trailingslashit( $url );
1651
+        }
1652
+
1653
+        /**
1654
+         * Get the url path to the current folder.
1655
+         *
1656
+         * @return string
1657
+         */
1658
+        public function get_url_old() {
1659
+
1660
+            $url = '';
1661
+            // check if we are inside a plugin
1662
+            $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
1663
+
1664
+            // add check in-case user has changed wp-content dir name.
1665
+            $wp_content_folder_name = basename(WP_CONTENT_DIR);
1666
+            $dir_parts = explode("/$wp_content_folder_name/",$file_dir);
1667
+            $url_parts = explode("/$wp_content_folder_name/",plugins_url());
1668
+
1669
+            if(!empty($url_parts[0]) && !empty($dir_parts[1])){
1670
+                $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
1671
+            }
1672
+
1673
+            return $url;
1674
+        }
1675
+
1676
+        /**
1677
+         * Register the database settings with WordPress.
1678
+         */
1679
+        public function register_settings() {
1680
+            register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
1681
+        }
1682
+
1683
+        /**
1684
+         * Add the WordPress settings menu item.
1685
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
1686
+         */
1687
+        public function menu_item() {
1688
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
1689
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
1690
+                $this,
1691
+                'settings_page'
1692
+            ) );
1693
+        }
1694
+
1695
+        /**
1696
+         * Get a list of themes and their default JS settings.
1697
+         *
1698
+         * @return array
1699
+         */
1700
+        public function theme_js_settings(){
1701
+            return array(
1702
+                'ayetheme' => 'popper',
1703
+                'listimia' => 'required',
1704
+                'listimia_backend' => 'core-popper',
1705
+                //'avada'    => 'required', // removed as we now add compatibility
1706
+            );
1707
+        }
1708
+
1709
+        /**
1710
+         * Get the current Font Awesome output settings.
1711
+         *
1712
+         * @return array The array of settings.
1713
+         */
1714
+        public function get_settings() {
1715
+
1716
+            $db_settings = get_option( 'ayecode-ui-settings' );
1717
+            $js_default = 'core-popper';
1718
+            $js_default_backend = $js_default;
1719
+
1720
+            // maybe set defaults (if no settings set)
1721
+            if(empty($db_settings)){
1722
+                $active_theme = strtolower( get_template() ); // active parent theme.
1723
+                $theme_js_settings = self::theme_js_settings();
1724
+                if(isset($theme_js_settings[$active_theme])){
1725
+                    $js_default = $theme_js_settings[$active_theme];
1726
+                    $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
1727
+                }
1728
+            }
1729
+
1730
+            /**
1731
+             * Filter the default settings.
1732
+             */
1733
+            $defaults = apply_filters( 'ayecode-ui-default-settings', array(
1734
+                'css'            => 'compatibility', // core, compatibility
1735
+                'js'             => $js_default, // js to load, core-popper, popper
1736
+                'html_font_size' => '16', // js to load, core-popper, popper
1737
+                'css_backend'    => 'compatibility', // core, compatibility
1738
+                'js_backend'     => $js_default_backend, // js to load, core-popper, popper
1739
+                'disable_admin'  => '', // URL snippets to disable loading on admin
1740
+            ), $db_settings );
1741
+
1742
+            $settings = wp_parse_args( $db_settings, $defaults );
1743
+
1744
+            /**
1745
+             * Filter the Bootstrap settings.
1746
+             *
1747
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
1748
+             */
1749
+            return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
1750
+        }
1751
+
1752
+
1753
+        /**
1754
+         * The settings page html output.
1755
+         */
1756
+        public function settings_page() {
1757
+            if ( ! current_user_can( 'manage_options' ) ) {
1758
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) );
1759
+            }
1760
+            ?>
1761 1761
             <div class="wrap">
1762 1762
                 <h1><?php echo $this->name; ?></h1>
1763 1763
                 <p><?php echo apply_filters( 'ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.",'aui') );?></p>
1764 1764
                 <form method="post" action="options.php">
1765 1765
 					<?php
1766
-					settings_fields( 'ayecode-ui-settings' );
1767
-					do_settings_sections( 'ayecode-ui-settings' );
1768
-					?>
1766
+                    settings_fields( 'ayecode-ui-settings' );
1767
+                    do_settings_sections( 'ayecode-ui-settings' );
1768
+                    ?>
1769 1769
 
1770 1770
                     <h2><?php _e( 'Frontend', 'aui' ); ?></h2>
1771 1771
                     <table class="form-table wpbs-table-settings">
@@ -1845,60 +1845,60 @@  discard block
 block discarded – undo
1845 1845
                     </table>
1846 1846
 
1847 1847
 					<?php
1848
-					submit_button();
1849
-					?>
1848
+                    submit_button();
1849
+                    ?>
1850 1850
                 </form>
1851 1851
 
1852 1852
                 <div id="wpbs-version"><?php echo $this->version; ?></div>
1853 1853
             </div>
1854 1854
 
1855 1855
 			<?php
1856
-		}
1857
-
1858
-		public function customizer_settings($wp_customize){
1859
-			$wp_customize->add_section('aui_settings', array(
1860
-				'title'    => __('AyeCode UI','aui'),
1861
-				'priority' => 120,
1862
-			));
1863
-
1864
-			//  =============================
1865
-			//  = Color Picker              =
1866
-			//  =============================
1867
-			$wp_customize->add_setting('aui_options[color_primary]', array(
1868
-				'default'           => AUI_PRIMARY_COLOR,
1869
-				'sanitize_callback' => 'sanitize_hex_color',
1870
-				'capability'        => 'edit_theme_options',
1871
-				'type'              => 'option',
1872
-				'transport'         => 'refresh',
1873
-			));
1874
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1875
-				'label'    => __('Primary Color','aui'),
1876
-				'section'  => 'aui_settings',
1877
-				'settings' => 'aui_options[color_primary]',
1878
-			)));
1879
-
1880
-			$wp_customize->add_setting('aui_options[color_secondary]', array(
1881
-				'default'           => '#6c757d',
1882
-				'sanitize_callback' => 'sanitize_hex_color',
1883
-				'capability'        => 'edit_theme_options',
1884
-				'type'              => 'option',
1885
-				'transport'         => 'refresh',
1886
-			));
1887
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1888
-				'label'    => __('Secondary Color','aui'),
1889
-				'section'  => 'aui_settings',
1890
-				'settings' => 'aui_options[color_secondary]',
1891
-			)));
1892
-		}
1893
-
1894
-		/**
1895
-		 * CSS to help with conflict issues with other plugins and themes using bootstrap v3.
1896
-		 *
1897
-		 * @return mixed
1898
-		 */
1899
-		public static function bs3_compat_css() {
1900
-			ob_start();
1901
-			?>
1856
+        }
1857
+
1858
+        public function customizer_settings($wp_customize){
1859
+            $wp_customize->add_section('aui_settings', array(
1860
+                'title'    => __('AyeCode UI','aui'),
1861
+                'priority' => 120,
1862
+            ));
1863
+
1864
+            //  =============================
1865
+            //  = Color Picker              =
1866
+            //  =============================
1867
+            $wp_customize->add_setting('aui_options[color_primary]', array(
1868
+                'default'           => AUI_PRIMARY_COLOR,
1869
+                'sanitize_callback' => 'sanitize_hex_color',
1870
+                'capability'        => 'edit_theme_options',
1871
+                'type'              => 'option',
1872
+                'transport'         => 'refresh',
1873
+            ));
1874
+            $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1875
+                'label'    => __('Primary Color','aui'),
1876
+                'section'  => 'aui_settings',
1877
+                'settings' => 'aui_options[color_primary]',
1878
+            )));
1879
+
1880
+            $wp_customize->add_setting('aui_options[color_secondary]', array(
1881
+                'default'           => '#6c757d',
1882
+                'sanitize_callback' => 'sanitize_hex_color',
1883
+                'capability'        => 'edit_theme_options',
1884
+                'type'              => 'option',
1885
+                'transport'         => 'refresh',
1886
+            ));
1887
+            $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1888
+                'label'    => __('Secondary Color','aui'),
1889
+                'section'  => 'aui_settings',
1890
+                'settings' => 'aui_options[color_secondary]',
1891
+            )));
1892
+        }
1893
+
1894
+        /**
1895
+         * CSS to help with conflict issues with other plugins and themes using bootstrap v3.
1896
+         *
1897
+         * @return mixed
1898
+         */
1899
+        public static function bs3_compat_css() {
1900
+            ob_start();
1901
+            ?>
1902 1902
             <style>
1903 1903
                 /* Bootstrap 3 compatibility */
1904 1904
                 body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;}
@@ -1927,825 +1927,825 @@  discard block
 block discarded – undo
1927 1927
                 <?php } ?>
1928 1928
             </style>
1929 1929
 			<?php
1930
-			return str_replace( array(
1931
-				'<style>',
1932
-				'</style>'
1933
-			), '', self::minify_css( ob_get_clean() ) );
1934
-		}
1935
-
1936
-
1937
-		public static function custom_css($compatibility = true) {
1938
-			$colors = array();
1939
-			if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1940
-
1941
-				$setting = wp_get_global_settings();
1942
-				if(!empty($setting['color']['palette']['theme'])){
1943
-					foreach($setting['color']['palette']['theme'] as $color){
1944
-						$colors[$color['slug']] = esc_attr($color['color']);
1945
-					}
1946
-				}
1930
+            return str_replace( array(
1931
+                '<style>',
1932
+                '</style>'
1933
+            ), '', self::minify_css( ob_get_clean() ) );
1934
+        }
1947 1935
 
1948
-				if(!empty($setting['color']['palette']['custom'])){
1949
-					foreach($setting['color']['palette']['custom'] as $color){
1950
-						$colors[$color['slug']] = esc_attr($color['color']);
1951
-					}
1952
-				}
1953
-			}else{
1954
-				$settings = get_option('aui_options');
1955
-				$colors = array(
1956
-					'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1957
-					'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1958
-				);
1959
-			}
1960 1936
 
1961
-			ob_start();
1937
+        public static function custom_css($compatibility = true) {
1938
+            $colors = array();
1939
+            if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1940
+
1941
+                $setting = wp_get_global_settings();
1942
+                if(!empty($setting['color']['palette']['theme'])){
1943
+                    foreach($setting['color']['palette']['theme'] as $color){
1944
+                        $colors[$color['slug']] = esc_attr($color['color']);
1945
+                    }
1946
+                }
1947
+
1948
+                if(!empty($setting['color']['palette']['custom'])){
1949
+                    foreach($setting['color']['palette']['custom'] as $color){
1950
+                        $colors[$color['slug']] = esc_attr($color['color']);
1951
+                    }
1952
+                }
1953
+            }else{
1954
+                $settings = get_option('aui_options');
1955
+                $colors = array(
1956
+                    'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1957
+                    'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1958
+                );
1959
+            }
1962 1960
 
1963
-			?>
1961
+            ob_start();
1962
+
1963
+            ?>
1964 1964
             <style>
1965 1965
                 <?php
1966 1966
 
1967
-					// BS v3 compat
1968
-					if( self::is_bs3_compat() ){
1969
-						echo self::bs3_compat_css();
1970
-					}
1967
+                    // BS v3 compat
1968
+                    if( self::is_bs3_compat() ){
1969
+                        echo self::bs3_compat_css();
1970
+                    }
1971 1971
 
1972
-					if(!empty($colors)){
1973
-						$d_colors = self::get_colors(true);
1974
-						//print_r($d_colors );exit;
1972
+                    if(!empty($colors)){
1973
+                        $d_colors = self::get_colors(true);
1974
+                        //print_r($d_colors );exit;
1975 1975
 //                        print_r($colors );exit;
1976
-						$is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template';
1977
-						foreach($colors as $key => $color ){
1978
-							if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1979
-								$var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1980
-								$compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1981
-								echo self::css_overwrite($key,$var,$compat);
1982
-							}
1983
-						}
1984
-					   // exit;
1985
-					}
1976
+                        $is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template';
1977
+                        foreach($colors as $key => $color ){
1978
+                            if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1979
+                                $var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1980
+                                $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1981
+                                echo self::css_overwrite($key,$var,$compat);
1982
+                            }
1983
+                        }
1984
+                        // exit;
1985
+                    }
1986 1986
 
1987
-					// Set admin bar z-index lower when modal is open.
1988
-					echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1987
+                    // Set admin bar z-index lower when modal is open.
1988
+                    echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1989 1989
 
1990
-					if(is_admin()){
1991
-						echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1992
-					}
1993
-				?>
1990
+                    if(is_admin()){
1991
+                        echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1992
+                    }
1993
+                ?>
1994 1994
             </style>
1995 1995
 			<?php
1996 1996
 
1997 1997
 
1998
-			/*
1998
+            /*
1999 1999
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
2000 2000
 			 */
2001
-			return str_replace( array(
2002
-				'<style>',
2003
-				'</style>'
2004
-			), '', self::minify_css( ob_get_clean() ) );
2005
-		}
2006
-
2007
-
2008
-
2009
-		/**
2010
-		 * Check if we should add booststrap 3 compatibility changes.
2011
-		 *
2012
-		 * @return bool
2013
-		 */
2014
-		public static function is_bs3_compat(){
2015
-			return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
2016
-		}
2017
-
2018
-		/**
2019
-		 * Build the CSS to overwrite a bootstrap color variable.
2020
-		 *
2021
-		 * @param $type
2022
-		 * @param $color_code
2023
-		 * @param $compatibility
2024
-		 *
2025
-		 * @return string
2026
-		 */
2027
-		public static function css_overwrite($type,$color_code,$compatibility){
2028
-
2029
-			$is_var = false;
2030
-			if(!$color_code){return '';}
2031
-			if(!sanitize_hex_color($color_code)){
2032
-				$color_code = esc_attr($color_code);
2033
-				$is_var = true;
2001
+            return str_replace( array(
2002
+                '<style>',
2003
+                '</style>'
2004
+            ), '', self::minify_css( ob_get_clean() ) );
2005
+        }
2006
+
2007
+
2008
+
2009
+        /**
2010
+         * Check if we should add booststrap 3 compatibility changes.
2011
+         *
2012
+         * @return bool
2013
+         */
2014
+        public static function is_bs3_compat(){
2015
+            return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
2016
+        }
2017
+
2018
+        /**
2019
+         * Build the CSS to overwrite a bootstrap color variable.
2020
+         *
2021
+         * @param $type
2022
+         * @param $color_code
2023
+         * @param $compatibility
2024
+         *
2025
+         * @return string
2026
+         */
2027
+        public static function css_overwrite($type,$color_code,$compatibility){
2028
+
2029
+            $is_var = false;
2030
+            if(!$color_code){return '';}
2031
+            if(!sanitize_hex_color($color_code)){
2032
+                $color_code = esc_attr($color_code);
2033
+                $is_var = true;
2034 2034
 //                echo '###1'.$color_code;//exit;
2035
-			}
2036
-			if(!$color_code){return '';}
2035
+            }
2036
+            if(!$color_code){return '';}
2037 2037
 
2038
-			if($compatibility===true || $compatibility===1){
2039
-				$compatibility = '.bsui';
2040
-			}elseif(!$compatibility){
2041
-				$compatibility = '';
2042
-			}else{
2043
-				$compatibility = esc_attr($compatibility);
2044
-			}
2038
+            if($compatibility===true || $compatibility===1){
2039
+                $compatibility = '.bsui';
2040
+            }elseif(!$compatibility){
2041
+                $compatibility = '';
2042
+            }else{
2043
+                $compatibility = esc_attr($compatibility);
2044
+            }
2045 2045
 
2046 2046
 //            echo '####'.$color_code;exit;
2047 2047
 
2048
-			$type = sanitize_html_class($type);
2049
-
2050
-			/**
2051
-			 * c = color, b = background color, o = border-color, f = fill
2052
-			 */
2053
-			$selectors = array(
2054
-				".btn-{$type}"                                              => array( 'b', 'o' ),
2055
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
2056
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
2057
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
2058
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
2059
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
2060
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
2061
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
2062
-				".badge-{$type}"                                            => array( 'b' ),
2063
-				".alert-{$type}"                                            => array( 'b', 'o' ),
2064
-				".bg-{$type}"                                               => array( 'b', 'f' ),
2065
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
2066
-			);
2067
-
2068
-			if ( $type == 'primary' ) {
2069
-				$selectors = $selectors + array(
2070
-						'a'                                                                                                    => array( 'c' ),
2071
-						'.btn-link'                                                                                            => array( 'c' ),
2072
-						'.dropdown-item.active'                                                                                => array( 'b' ),
2073
-						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
2074
-							'b',
2075
-							'o'
2076
-						),
2077
-						'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
2078
-							'b',
2079
-							'o'
2080
-						),
2081
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
2082
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
2083
-						'.page-link'                                                                                           => array( 'c' ),
2084
-						'.page-item.active .page-link'                                                                         => array(
2085
-							'b',
2086
-							'o'
2087
-						),
2088
-						'.progress-bar'                                                                                        => array( 'b' ),
2089
-						'.list-group-item.active'                                                                              => array(
2090
-							'b',
2091
-							'o'
2092
-						),
2093
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
2048
+            $type = sanitize_html_class($type);
2049
+
2050
+            /**
2051
+             * c = color, b = background color, o = border-color, f = fill
2052
+             */
2053
+            $selectors = array(
2054
+                ".btn-{$type}"                                              => array( 'b', 'o' ),
2055
+                ".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
2056
+                ".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
2057
+                ".btn-outline-{$type}"                                      => array( 'c', 'o' ),
2058
+                ".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
2059
+                ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
2060
+                ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
2061
+                ".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
2062
+                ".badge-{$type}"                                            => array( 'b' ),
2063
+                ".alert-{$type}"                                            => array( 'b', 'o' ),
2064
+                ".bg-{$type}"                                               => array( 'b', 'f' ),
2065
+                ".btn-link.btn-{$type}"                                     => array( 'c' ),
2066
+            );
2067
+
2068
+            if ( $type == 'primary' ) {
2069
+                $selectors = $selectors + array(
2070
+                        'a'                                                                                                    => array( 'c' ),
2071
+                        '.btn-link'                                                                                            => array( 'c' ),
2072
+                        '.dropdown-item.active'                                                                                => array( 'b' ),
2073
+                        '.custom-control-input:checked~.custom-control-label::before'                                          => array(
2074
+                            'b',
2075
+                            'o'
2076
+                        ),
2077
+                        '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
2078
+                            'b',
2079
+                            'o'
2080
+                        ),
2081
+                        '.nav-pills .nav-link.active'                                                                          => array( 'b' ),
2082
+                        '.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
2083
+                        '.page-link'                                                                                           => array( 'c' ),
2084
+                        '.page-item.active .page-link'                                                                         => array(
2085
+                            'b',
2086
+                            'o'
2087
+                        ),
2088
+                        '.progress-bar'                                                                                        => array( 'b' ),
2089
+                        '.list-group-item.active'                                                                              => array(
2090
+                            'b',
2091
+                            'o'
2092
+                        ),
2093
+                        '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
2094 2094
 //				    '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
2095 2095
 //				    '.custom-range::-moz-range-thumb' => array('b'),
2096 2096
 //				    '.custom-range::-ms-thumb' => array('b'),
2097
-					);
2098
-			}
2099
-
2100
-			$important_selectors = array(
2101
-				".bg-{$type}" => array('b','f'),
2102
-				".border-{$type}" => array('o'),
2103
-				".text-{$type}" => array('c'),
2104
-			);
2105
-
2106
-			$color = array();
2107
-			$color_i = array();
2108
-			$background = array();
2109
-			$background_i = array();
2110
-			$border = array();
2111
-			$border_i = array();
2112
-			$fill = array();
2113
-			$fill_i = array();
2114
-
2115
-			$output = '';
2116
-
2117
-			// build rules into each type
2118
-			foreach($selectors as $selector => $types){
2119
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
2120
-				$types = array_combine($types,$types);
2121
-				if(isset($types['c'])){$color[] = $selector;}
2122
-				if(isset($types['b'])){$background[] = $selector;}
2123
-				if(isset($types['o'])){$border[] = $selector;}
2124
-				if(isset($types['f'])){$fill[] = $selector;}
2125
-			}
2126
-
2127
-			// build rules into each type
2128
-			foreach($important_selectors as $selector => $types){
2129
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
2130
-				$types = array_combine($types,$types);
2131
-				if(isset($types['c'])){$color_i[] = $selector;}
2132
-				if(isset($types['b'])){$background_i[] = $selector;}
2133
-				if(isset($types['o'])){$border_i[] = $selector;}
2134
-				if(isset($types['f'])){$fill_i[] = $selector;}
2135
-			}
2136
-
2137
-			// add any color rules
2138
-			if(!empty($color)){
2139
-				$output .= implode(",",$color) . "{color: $color_code;} ";
2140
-			}
2141
-			if(!empty($color_i)){
2142
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2143
-			}
2144
-
2145
-			// add any background color rules
2146
-			if(!empty($background)){
2147
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
2148
-			}
2149
-			if(!empty($background_i)){
2150
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2151
-			}
2152
-
2153
-			// add any border color rules
2154
-			if(!empty($border)){
2155
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
2156
-			}
2157
-			if(!empty($border_i)){
2158
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2159
-			}
2160
-
2161
-			// add any fill color rules
2162
-			if(!empty($fill)){
2163
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
2164
-			}
2165
-			if(!empty($fill_i)){
2166
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2167
-			}
2168
-
2169
-
2170
-			$prefix = $compatibility ? $compatibility . " " : "";
2171
-
2172
-			$transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
2173
-			// darken
2174
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
2175
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
2176
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
2177
-
2178
-			// lighten
2179
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
2180
-
2181
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
2182
-			$op_25 = $color_code."40"; // 25% opacity
2183
-
2184
-
2185
-			// button states
2186
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
2187
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2097
+                    );
2098
+            }
2099
+
2100
+            $important_selectors = array(
2101
+                ".bg-{$type}" => array('b','f'),
2102
+                ".border-{$type}" => array('o'),
2103
+                ".text-{$type}" => array('c'),
2104
+            );
2105
+
2106
+            $color = array();
2107
+            $color_i = array();
2108
+            $background = array();
2109
+            $background_i = array();
2110
+            $border = array();
2111
+            $border_i = array();
2112
+            $fill = array();
2113
+            $fill_i = array();
2114
+
2115
+            $output = '';
2116
+
2117
+            // build rules into each type
2118
+            foreach($selectors as $selector => $types){
2119
+                $selector = $compatibility ? $compatibility . " ".$selector : $selector;
2120
+                $types = array_combine($types,$types);
2121
+                if(isset($types['c'])){$color[] = $selector;}
2122
+                if(isset($types['b'])){$background[] = $selector;}
2123
+                if(isset($types['o'])){$border[] = $selector;}
2124
+                if(isset($types['f'])){$fill[] = $selector;}
2125
+            }
2126
+
2127
+            // build rules into each type
2128
+            foreach($important_selectors as $selector => $types){
2129
+                $selector = $compatibility ? $compatibility . " ".$selector : $selector;
2130
+                $types = array_combine($types,$types);
2131
+                if(isset($types['c'])){$color_i[] = $selector;}
2132
+                if(isset($types['b'])){$background_i[] = $selector;}
2133
+                if(isset($types['o'])){$border_i[] = $selector;}
2134
+                if(isset($types['f'])){$fill_i[] = $selector;}
2135
+            }
2136
+
2137
+            // add any color rules
2138
+            if(!empty($color)){
2139
+                $output .= implode(",",$color) . "{color: $color_code;} ";
2140
+            }
2141
+            if(!empty($color_i)){
2142
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2143
+            }
2144
+
2145
+            // add any background color rules
2146
+            if(!empty($background)){
2147
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
2148
+            }
2149
+            if(!empty($background_i)){
2150
+                $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2151
+            }
2152
+
2153
+            // add any border color rules
2154
+            if(!empty($border)){
2155
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
2156
+            }
2157
+            if(!empty($border_i)){
2158
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2159
+            }
2160
+
2161
+            // add any fill color rules
2162
+            if(!empty($fill)){
2163
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
2164
+            }
2165
+            if(!empty($fill_i)){
2166
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2167
+            }
2168
+
2169
+
2170
+            $prefix = $compatibility ? $compatibility . " " : "";
2171
+
2172
+            $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
2173
+            // darken
2174
+            $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
2175
+            $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
2176
+            $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
2177
+
2178
+            // lighten
2179
+            $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
2180
+
2181
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
2182
+            $op_25 = $color_code."40"; // 25% opacity
2183
+
2184
+
2185
+            // button states
2186
+            $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
2187
+            $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2188 2188
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
2189
-			$output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2190
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2191
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2192
-
2193
-			if ( $type == 'primary' ) {
2194
-				// dropdown's
2195
-				$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
2196
-
2197
-				// input states
2198
-				$output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
2199
-
2200
-				// page link
2201
-				$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2202
-			}
2203
-
2204
-			return $output;
2205
-		}
2206
-
2207
-		/**
2208
-		 *
2209
-		 * @deprecated 0.1.76 Use css_overwrite()
2210
-		 *
2211
-		 * @param $color_code
2212
-		 * @param $compatibility
2213
-		 * @param $use_variable
2214
-		 *
2215
-		 * @return string
2216
-		 */
2217
-		public static function css_primary($color_code,$compatibility, $use_variable = false){
2218
-
2219
-			if(!$use_variable){
2220
-				$color_code = sanitize_hex_color($color_code);
2221
-				if(!$color_code){return '';}
2222
-			}
2223
-
2224
-			/**
2225
-			 * c = color, b = background color, o = border-color, f = fill
2226
-			 */
2227
-			$selectors = array(
2228
-				'a' => array('c'),
2229
-				'.btn-primary' => array('b','o'),
2230
-				'.btn-primary.disabled' => array('b','o'),
2231
-				'.btn-primary:disabled' => array('b','o'),
2232
-				'.btn-outline-primary' => array('c','o'),
2233
-				'.btn-outline-primary:hover' => array('b','o'),
2234
-				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
2235
-				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
2236
-				'.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
2237
-				'.btn-link' => array('c'),
2238
-				'.dropdown-item.active' => array('b'),
2239
-				'.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
2240
-				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
2189
+            $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2190
+            $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2191
+            $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2192
+
2193
+            if ( $type == 'primary' ) {
2194
+                // dropdown's
2195
+                $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
2196
+
2197
+                // input states
2198
+                $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
2199
+
2200
+                // page link
2201
+                $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2202
+            }
2203
+
2204
+            return $output;
2205
+        }
2206
+
2207
+        /**
2208
+         *
2209
+         * @deprecated 0.1.76 Use css_overwrite()
2210
+         *
2211
+         * @param $color_code
2212
+         * @param $compatibility
2213
+         * @param $use_variable
2214
+         *
2215
+         * @return string
2216
+         */
2217
+        public static function css_primary($color_code,$compatibility, $use_variable = false){
2218
+
2219
+            if(!$use_variable){
2220
+                $color_code = sanitize_hex_color($color_code);
2221
+                if(!$color_code){return '';}
2222
+            }
2223
+
2224
+            /**
2225
+             * c = color, b = background color, o = border-color, f = fill
2226
+             */
2227
+            $selectors = array(
2228
+                'a' => array('c'),
2229
+                '.btn-primary' => array('b','o'),
2230
+                '.btn-primary.disabled' => array('b','o'),
2231
+                '.btn-primary:disabled' => array('b','o'),
2232
+                '.btn-outline-primary' => array('c','o'),
2233
+                '.btn-outline-primary:hover' => array('b','o'),
2234
+                '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
2235
+                '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
2236
+                '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
2237
+                '.btn-link' => array('c'),
2238
+                '.dropdown-item.active' => array('b'),
2239
+                '.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
2240
+                '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
2241 2241
 //				'.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
2242 2242
 //				'.custom-range::-moz-range-thumb' => array('b'),
2243 2243
 //				'.custom-range::-ms-thumb' => array('b'),
2244
-				'.nav-pills .nav-link.active' => array('b'),
2245
-				'.nav-pills .show>.nav-link' => array('b'),
2246
-				'.page-link' => array('c'),
2247
-				'.page-item.active .page-link' => array('b','o'),
2248
-				'.badge-primary' => array('b'),
2249
-				'.alert-primary' => array('b','o'),
2250
-				'.progress-bar' => array('b'),
2251
-				'.list-group-item.active' => array('b','o'),
2252
-				'.bg-primary' => array('b','f'),
2253
-				'.btn-link.btn-primary' => array('c'),
2254
-				'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
2255
-			);
2256
-
2257
-			$important_selectors = array(
2258
-				'.bg-primary' => array('b','f'),
2259
-				'.border-primary' => array('o'),
2260
-				'.text-primary' => array('c'),
2261
-			);
2262
-
2263
-			$color = array();
2264
-			$color_i = array();
2265
-			$background = array();
2266
-			$background_i = array();
2267
-			$border = array();
2268
-			$border_i = array();
2269
-			$fill = array();
2270
-			$fill_i = array();
2271
-
2272
-			$output = '';
2273
-
2274
-			// build rules into each type
2275
-			foreach($selectors as $selector => $types){
2276
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2277
-				$types = array_combine($types,$types);
2278
-				if(isset($types['c'])){$color[] = $selector;}
2279
-				if(isset($types['b'])){$background[] = $selector;}
2280
-				if(isset($types['o'])){$border[] = $selector;}
2281
-				if(isset($types['f'])){$fill[] = $selector;}
2282
-			}
2283
-
2284
-			// build rules into each type
2285
-			foreach($important_selectors as $selector => $types){
2286
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2287
-				$types = array_combine($types,$types);
2288
-				if(isset($types['c'])){$color_i[] = $selector;}
2289
-				if(isset($types['b'])){$background_i[] = $selector;}
2290
-				if(isset($types['o'])){$border_i[] = $selector;}
2291
-				if(isset($types['f'])){$fill_i[] = $selector;}
2292
-			}
2293
-
2294
-			// add any color rules
2295
-			if(!empty($color)){
2296
-				$output .= implode(",",$color) . "{color: $color_code;} ";
2297
-			}
2298
-			if(!empty($color_i)){
2299
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2300
-			}
2301
-
2302
-			// add any background color rules
2303
-			if(!empty($background)){
2304
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
2305
-			}
2306
-			if(!empty($background_i)){
2307
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2308
-			}
2309
-
2310
-			// add any border color rules
2311
-			if(!empty($border)){
2312
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
2313
-			}
2314
-			if(!empty($border_i)){
2315
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2316
-			}
2317
-
2318
-			// add any fill color rules
2319
-			if(!empty($fill)){
2320
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
2321
-			}
2322
-			if(!empty($fill_i)){
2323
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2324
-			}
2325
-
2326
-
2327
-			$prefix = $compatibility ? ".bsui " : "";
2328
-
2329
-			// darken
2330
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2331
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2332
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2333
-
2334
-			// lighten
2335
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2336
-
2337
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
2338
-			$op_25 = $color_code."40"; // 25% opacity
2339
-
2340
-
2341
-			// button states
2342
-			$output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2343
-			$output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2344
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2345
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2346
-
2347
-
2348
-			// dropdown's
2349
-			$output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
2350
-
2351
-
2352
-			// input states
2353
-			$output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
2354
-
2355
-			// page link
2356
-			$output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2357
-
2358
-			return $output;
2359
-		}
2360
-
2361
-		/**
2362
-		 *
2363
-		 * @deprecated 0.1.76 Use css_overwrite()
2364
-		 *
2365
-		 * @param $color_code
2366
-		 * @param $compatibility
2367
-		 *
2368
-		 * @return string
2369
-		 */
2370
-		public static function css_secondary($color_code,$compatibility){;
2371
-			$color_code = sanitize_hex_color($color_code);
2372
-			if(!$color_code){return '';}
2373
-			/**
2374
-			 * c = color, b = background color, o = border-color, f = fill
2375
-			 */
2376
-			$selectors = array(
2377
-				'.btn-secondary' => array('b','o'),
2378
-				'.btn-secondary.disabled' => array('b','o'),
2379
-				'.btn-secondary:disabled' => array('b','o'),
2380
-				'.btn-outline-secondary' => array('c','o'),
2381
-				'.btn-outline-secondary:hover' => array('b','o'),
2382
-				'.btn-outline-secondary.disabled' => array('c'),
2383
-				'.btn-outline-secondary:disabled' => array('c'),
2384
-				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
2385
-				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
2386
-				'.btn-outline-secondary.dropdown-toggle' => array('b','o'),
2387
-				'.badge-secondary' => array('b'),
2388
-				'.alert-secondary' => array('b','o'),
2389
-				'.btn-link.btn-secondary' => array('c'),
2390
-			);
2391
-
2392
-			$important_selectors = array(
2393
-				'.bg-secondary' => array('b','f'),
2394
-				'.border-secondary' => array('o'),
2395
-				'.text-secondary' => array('c'),
2396
-			);
2397
-
2398
-			$color = array();
2399
-			$color_i = array();
2400
-			$background = array();
2401
-			$background_i = array();
2402
-			$border = array();
2403
-			$border_i = array();
2404
-			$fill = array();
2405
-			$fill_i = array();
2406
-
2407
-			$output = '';
2408
-
2409
-			// build rules into each type
2410
-			foreach($selectors as $selector => $types){
2411
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2412
-				$types = array_combine($types,$types);
2413
-				if(isset($types['c'])){$color[] = $selector;}
2414
-				if(isset($types['b'])){$background[] = $selector;}
2415
-				if(isset($types['o'])){$border[] = $selector;}
2416
-				if(isset($types['f'])){$fill[] = $selector;}
2417
-			}
2418
-
2419
-			// build rules into each type
2420
-			foreach($important_selectors as $selector => $types){
2421
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2422
-				$types = array_combine($types,$types);
2423
-				if(isset($types['c'])){$color_i[] = $selector;}
2424
-				if(isset($types['b'])){$background_i[] = $selector;}
2425
-				if(isset($types['o'])){$border_i[] = $selector;}
2426
-				if(isset($types['f'])){$fill_i[] = $selector;}
2427
-			}
2428
-
2429
-			// add any color rules
2430
-			if(!empty($color)){
2431
-				$output .= implode(",",$color) . "{color: $color_code;} ";
2432
-			}
2433
-			if(!empty($color_i)){
2434
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2435
-			}
2436
-
2437
-			// add any background color rules
2438
-			if(!empty($background)){
2439
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
2440
-			}
2441
-			if(!empty($background_i)){
2442
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2443
-			}
2444
-
2445
-			// add any border color rules
2446
-			if(!empty($border)){
2447
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
2448
-			}
2449
-			if(!empty($border_i)){
2450
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2451
-			}
2452
-
2453
-			// add any fill color rules
2454
-			if(!empty($fill)){
2455
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
2456
-			}
2457
-			if(!empty($fill_i)){
2458
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2459
-			}
2460
-
2461
-
2462
-			$prefix = $compatibility ? ".bsui " : "";
2463
-
2464
-			// darken
2465
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2466
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2467
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2468
-
2469
-			// lighten
2470
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2471
-
2472
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
2473
-			$op_25 = $color_code."40"; // 25% opacity
2474
-
2475
-
2476
-			// button states
2477
-			$output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2478
-			$output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2479
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2480
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2481
-
2482
-
2483
-			return $output;
2484
-		}
2485
-
2486
-		/**
2487
-		 * Increases or decreases the brightness of a color by a percentage of the current brightness.
2488
-		 *
2489
-		 * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
2490
-		 * @param   float   $adjustPercent  A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
2491
-		 *
2492
-		 * @return  string
2493
-		 */
2494
-		public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
2495
-			$hexCode = ltrim($hexCode, '#');
2496
-
2497
-			if (strlen($hexCode) == 3) {
2498
-				$hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
2499
-			}
2500
-
2501
-			$hexCode = array_map('hexdec', str_split($hexCode, 2));
2502
-
2503
-			foreach ($hexCode as & $color) {
2504
-				$adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
2505
-				$adjustAmount = ceil($adjustableLimit * $adjustPercent);
2506
-
2507
-				$color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
2508
-			}
2509
-
2510
-			return '#' . implode($hexCode);
2511
-		}
2512
-
2513
-		/**
2514
-		 * Check if we should display examples.
2515
-		 */
2516
-		public function maybe_show_examples(){
2517
-			if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2518
-				echo "<head>";
2519
-				wp_head();
2520
-				echo "</head>";
2521
-				echo "<body>";
2522
-				echo $this->get_examples();
2523
-				echo "</body>";
2524
-				exit;
2525
-			}
2526
-		}
2527
-
2528
-		/**
2529
-		 * Get developer examples.
2530
-		 *
2531
-		 * @return string
2532
-		 */
2533
-		public function get_examples(){
2534
-			$output = '';
2535
-
2536
-
2537
-			// open form
2538
-			$output .= "<form class='p-5 m-5 border rounded'>";
2539
-
2540
-			// input example
2541
-			$output .= aui()->input(array(
2542
-				'type'  =>  'text',
2543
-				'id'    =>  'text-example',
2544
-				'name'    =>  'text-example',
2545
-				'placeholder'   => 'text placeholder',
2546
-				'title'   => 'Text input example',
2547
-				'value' =>  '',
2548
-				'required'  => false,
2549
-				'help_text' => 'help text',
2550
-				'label' => 'Text input example label'
2551
-			));
2552
-
2553
-			// input example
2554
-			$output .= aui()->input(array(
2555
-				'type'  =>  'url',
2556
-				'id'    =>  'text-example2',
2557
-				'name'    =>  'text-example',
2558
-				'placeholder'   => 'url placeholder',
2559
-				'title'   => 'Text input example',
2560
-				'value' =>  '',
2561
-				'required'  => false,
2562
-				'help_text' => 'help text',
2563
-				'label' => 'Text input example label'
2564
-			));
2565
-
2566
-			// checkbox example
2567
-			$output .= aui()->input(array(
2568
-				'type'  =>  'checkbox',
2569
-				'id'    =>  'checkbox-example',
2570
-				'name'    =>  'checkbox-example',
2571
-				'placeholder'   => 'checkbox-example',
2572
-				'title'   => 'Checkbox example',
2573
-				'value' =>  '1',
2574
-				'checked'   => true,
2575
-				'required'  => false,
2576
-				'help_text' => 'help text',
2577
-				'label' => 'Checkbox checked'
2578
-			));
2579
-
2580
-			// checkbox example
2581
-			$output .= aui()->input(array(
2582
-				'type'  =>  'checkbox',
2583
-				'id'    =>  'checkbox-example2',
2584
-				'name'    =>  'checkbox-example2',
2585
-				'placeholder'   => 'checkbox-example',
2586
-				'title'   => 'Checkbox example',
2587
-				'value' =>  '1',
2588
-				'checked'   => false,
2589
-				'required'  => false,
2590
-				'help_text' => 'help text',
2591
-				'label' => 'Checkbox un-checked'
2592
-			));
2593
-
2594
-			// switch example
2595
-			$output .= aui()->input(array(
2596
-				'type'  =>  'checkbox',
2597
-				'id'    =>  'switch-example',
2598
-				'name'    =>  'switch-example',
2599
-				'placeholder'   => 'checkbox-example',
2600
-				'title'   => 'Switch example',
2601
-				'value' =>  '1',
2602
-				'checked'   => true,
2603
-				'switch'    => true,
2604
-				'required'  => false,
2605
-				'help_text' => 'help text',
2606
-				'label' => 'Switch on'
2607
-			));
2608
-
2609
-			// switch example
2610
-			$output .= aui()->input(array(
2611
-				'type'  =>  'checkbox',
2612
-				'id'    =>  'switch-example2',
2613
-				'name'    =>  'switch-example2',
2614
-				'placeholder'   => 'checkbox-example',
2615
-				'title'   => 'Switch example',
2616
-				'value' =>  '1',
2617
-				'checked'   => false,
2618
-				'switch'    => true,
2619
-				'required'  => false,
2620
-				'help_text' => 'help text',
2621
-				'label' => 'Switch off'
2622
-			));
2623
-
2624
-			// close form
2625
-			$output .= "</form>";
2626
-
2627
-			return $output;
2628
-		}
2629
-
2630
-		/**
2631
-		 * Calendar params.
2632
-		 *
2633
-		 * @since 0.1.44
2634
-		 *
2635
-		 * @return array Calendar params.
2636
-		 */
2637
-		public static function calendar_params() {
2638
-			$params = array(
2639
-				'month_long_1' => __( 'January', 'aui' ),
2640
-				'month_long_2' => __( 'February', 'aui' ),
2641
-				'month_long_3' => __( 'March', 'aui' ),
2642
-				'month_long_4' => __( 'April', 'aui' ),
2643
-				'month_long_5' => __( 'May', 'aui' ),
2644
-				'month_long_6' => __( 'June', 'aui' ),
2645
-				'month_long_7' => __( 'July', 'aui' ),
2646
-				'month_long_8' => __( 'August', 'aui' ),
2647
-				'month_long_9' => __( 'September', 'aui' ),
2648
-				'month_long_10' => __( 'October', 'aui' ),
2649
-				'month_long_11' => __( 'November', 'aui' ),
2650
-				'month_long_12' => __( 'December', 'aui' ),
2651
-				'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ),
2652
-				'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ),
2653
-				'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ),
2654
-				'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ),
2655
-				'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ),
2656
-				'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ),
2657
-				'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ),
2658
-				'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ),
2659
-				'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ),
2660
-				'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ),
2661
-				'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ),
2662
-				'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ),
2663
-				'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ),
2664
-				'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ),
2665
-				'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ),
2666
-				'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ),
2667
-				'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ),
2668
-				'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ),
2669
-				'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ),
2670
-				'day_s2_1' => __( 'Su', 'aui' ),
2671
-				'day_s2_2' => __( 'Mo', 'aui' ),
2672
-				'day_s2_3' => __( 'Tu', 'aui' ),
2673
-				'day_s2_4' => __( 'We', 'aui' ),
2674
-				'day_s2_5' => __( 'Th', 'aui' ),
2675
-				'day_s2_6' => __( 'Fr', 'aui' ),
2676
-				'day_s2_7' => __( 'Sa', 'aui' ),
2677
-				'day_s3_1' => __( 'Sun', 'aui' ),
2678
-				'day_s3_2' => __( 'Mon', 'aui' ),
2679
-				'day_s3_3' => __( 'Tue', 'aui' ),
2680
-				'day_s3_4' => __( 'Wed', 'aui' ),
2681
-				'day_s3_5' => __( 'Thu', 'aui' ),
2682
-				'day_s3_6' => __( 'Fri', 'aui' ),
2683
-				'day_s3_7' => __( 'Sat', 'aui' ),
2684
-				'day_s5_1' => __( 'Sunday', 'aui' ),
2685
-				'day_s5_2' => __( 'Monday', 'aui' ),
2686
-				'day_s5_3' => __( 'Tuesday', 'aui' ),
2687
-				'day_s5_4' => __( 'Wednesday', 'aui' ),
2688
-				'day_s5_5' => __( 'Thursday', 'aui' ),
2689
-				'day_s5_6' => __( 'Friday', 'aui' ),
2690
-				'day_s5_7' => __( 'Saturday', 'aui' ),
2691
-				'am_lower' => __( 'am', 'aui' ),
2692
-				'pm_lower' => __( 'pm', 'aui' ),
2693
-				'am_upper' => __( 'AM', 'aui' ),
2694
-				'pm_upper' => __( 'PM', 'aui' ),
2695
-				'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2696
-				'time_24hr' => false,
2697
-				'year' => __( 'Year', 'aui' ),
2698
-				'hour' => __( 'Hour', 'aui' ),
2699
-				'minute' => __( 'Minute', 'aui' ),
2700
-				'weekAbbreviation' => __( 'Wk', 'aui' ),
2701
-				'rangeSeparator' => __( ' to ', 'aui' ),
2702
-				'scrollTitle' => __( 'Scroll to increment', 'aui' ),
2703
-				'toggleTitle' => __( 'Click to toggle', 'aui' )
2704
-			);
2705
-
2706
-			return apply_filters( 'ayecode_ui_calendar_params', $params );
2707
-		}
2708
-
2709
-		/**
2710
-		 * Flatpickr calendar localize.
2711
-		 *
2712
-		 * @since 0.1.44
2713
-		 *
2714
-		 * @return string Calendar locale.
2715
-		 */
2716
-		public static function flatpickr_locale() {
2717
-			$params = self::calendar_params();
2718
-
2719
-			if ( is_string( $params ) ) {
2720
-				$params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2721
-			} else {
2722
-				foreach ( (array) $params as $key => $value ) {
2723
-					if ( ! is_scalar( $value ) ) {
2724
-						continue;
2725
-					}
2726
-
2727
-					$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2728
-				}
2729
-			}
2244
+                '.nav-pills .nav-link.active' => array('b'),
2245
+                '.nav-pills .show>.nav-link' => array('b'),
2246
+                '.page-link' => array('c'),
2247
+                '.page-item.active .page-link' => array('b','o'),
2248
+                '.badge-primary' => array('b'),
2249
+                '.alert-primary' => array('b','o'),
2250
+                '.progress-bar' => array('b'),
2251
+                '.list-group-item.active' => array('b','o'),
2252
+                '.bg-primary' => array('b','f'),
2253
+                '.btn-link.btn-primary' => array('c'),
2254
+                '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
2255
+            );
2256
+
2257
+            $important_selectors = array(
2258
+                '.bg-primary' => array('b','f'),
2259
+                '.border-primary' => array('o'),
2260
+                '.text-primary' => array('c'),
2261
+            );
2262
+
2263
+            $color = array();
2264
+            $color_i = array();
2265
+            $background = array();
2266
+            $background_i = array();
2267
+            $border = array();
2268
+            $border_i = array();
2269
+            $fill = array();
2270
+            $fill_i = array();
2271
+
2272
+            $output = '';
2273
+
2274
+            // build rules into each type
2275
+            foreach($selectors as $selector => $types){
2276
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
2277
+                $types = array_combine($types,$types);
2278
+                if(isset($types['c'])){$color[] = $selector;}
2279
+                if(isset($types['b'])){$background[] = $selector;}
2280
+                if(isset($types['o'])){$border[] = $selector;}
2281
+                if(isset($types['f'])){$fill[] = $selector;}
2282
+            }
2283
+
2284
+            // build rules into each type
2285
+            foreach($important_selectors as $selector => $types){
2286
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
2287
+                $types = array_combine($types,$types);
2288
+                if(isset($types['c'])){$color_i[] = $selector;}
2289
+                if(isset($types['b'])){$background_i[] = $selector;}
2290
+                if(isset($types['o'])){$border_i[] = $selector;}
2291
+                if(isset($types['f'])){$fill_i[] = $selector;}
2292
+            }
2293
+
2294
+            // add any color rules
2295
+            if(!empty($color)){
2296
+                $output .= implode(",",$color) . "{color: $color_code;} ";
2297
+            }
2298
+            if(!empty($color_i)){
2299
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2300
+            }
2301
+
2302
+            // add any background color rules
2303
+            if(!empty($background)){
2304
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
2305
+            }
2306
+            if(!empty($background_i)){
2307
+                $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2308
+            }
2309
+
2310
+            // add any border color rules
2311
+            if(!empty($border)){
2312
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
2313
+            }
2314
+            if(!empty($border_i)){
2315
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2316
+            }
2317
+
2318
+            // add any fill color rules
2319
+            if(!empty($fill)){
2320
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
2321
+            }
2322
+            if(!empty($fill_i)){
2323
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2324
+            }
2325
+
2326
+
2327
+            $prefix = $compatibility ? ".bsui " : "";
2328
+
2329
+            // darken
2330
+            $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2331
+            $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2332
+            $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2333
+
2334
+            // lighten
2335
+            $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2336
+
2337
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
2338
+            $op_25 = $color_code."40"; // 25% opacity
2339
+
2340
+
2341
+            // button states
2342
+            $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2343
+            $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2344
+            $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2345
+            $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2346
+
2347
+
2348
+            // dropdown's
2349
+            $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
2350
+
2351
+
2352
+            // input states
2353
+            $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
2354
+
2355
+            // page link
2356
+            $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2357
+
2358
+            return $output;
2359
+        }
2360
+
2361
+        /**
2362
+         *
2363
+         * @deprecated 0.1.76 Use css_overwrite()
2364
+         *
2365
+         * @param $color_code
2366
+         * @param $compatibility
2367
+         *
2368
+         * @return string
2369
+         */
2370
+        public static function css_secondary($color_code,$compatibility){;
2371
+            $color_code = sanitize_hex_color($color_code);
2372
+            if(!$color_code){return '';}
2373
+            /**
2374
+             * c = color, b = background color, o = border-color, f = fill
2375
+             */
2376
+            $selectors = array(
2377
+                '.btn-secondary' => array('b','o'),
2378
+                '.btn-secondary.disabled' => array('b','o'),
2379
+                '.btn-secondary:disabled' => array('b','o'),
2380
+                '.btn-outline-secondary' => array('c','o'),
2381
+                '.btn-outline-secondary:hover' => array('b','o'),
2382
+                '.btn-outline-secondary.disabled' => array('c'),
2383
+                '.btn-outline-secondary:disabled' => array('c'),
2384
+                '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
2385
+                '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
2386
+                '.btn-outline-secondary.dropdown-toggle' => array('b','o'),
2387
+                '.badge-secondary' => array('b'),
2388
+                '.alert-secondary' => array('b','o'),
2389
+                '.btn-link.btn-secondary' => array('c'),
2390
+            );
2391
+
2392
+            $important_selectors = array(
2393
+                '.bg-secondary' => array('b','f'),
2394
+                '.border-secondary' => array('o'),
2395
+                '.text-secondary' => array('c'),
2396
+            );
2397
+
2398
+            $color = array();
2399
+            $color_i = array();
2400
+            $background = array();
2401
+            $background_i = array();
2402
+            $border = array();
2403
+            $border_i = array();
2404
+            $fill = array();
2405
+            $fill_i = array();
2406
+
2407
+            $output = '';
2408
+
2409
+            // build rules into each type
2410
+            foreach($selectors as $selector => $types){
2411
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
2412
+                $types = array_combine($types,$types);
2413
+                if(isset($types['c'])){$color[] = $selector;}
2414
+                if(isset($types['b'])){$background[] = $selector;}
2415
+                if(isset($types['o'])){$border[] = $selector;}
2416
+                if(isset($types['f'])){$fill[] = $selector;}
2417
+            }
2418
+
2419
+            // build rules into each type
2420
+            foreach($important_selectors as $selector => $types){
2421
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
2422
+                $types = array_combine($types,$types);
2423
+                if(isset($types['c'])){$color_i[] = $selector;}
2424
+                if(isset($types['b'])){$background_i[] = $selector;}
2425
+                if(isset($types['o'])){$border_i[] = $selector;}
2426
+                if(isset($types['f'])){$fill_i[] = $selector;}
2427
+            }
2428
+
2429
+            // add any color rules
2430
+            if(!empty($color)){
2431
+                $output .= implode(",",$color) . "{color: $color_code;} ";
2432
+            }
2433
+            if(!empty($color_i)){
2434
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2435
+            }
2436
+
2437
+            // add any background color rules
2438
+            if(!empty($background)){
2439
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
2440
+            }
2441
+            if(!empty($background_i)){
2442
+                $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2443
+            }
2444
+
2445
+            // add any border color rules
2446
+            if(!empty($border)){
2447
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
2448
+            }
2449
+            if(!empty($border_i)){
2450
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2451
+            }
2452
+
2453
+            // add any fill color rules
2454
+            if(!empty($fill)){
2455
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
2456
+            }
2457
+            if(!empty($fill_i)){
2458
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2459
+            }
2460
+
2461
+
2462
+            $prefix = $compatibility ? ".bsui " : "";
2463
+
2464
+            // darken
2465
+            $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2466
+            $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2467
+            $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2468
+
2469
+            // lighten
2470
+            $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2471
+
2472
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
2473
+            $op_25 = $color_code."40"; // 25% opacity
2474
+
2475
+
2476
+            // button states
2477
+            $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2478
+            $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2479
+            $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2480
+            $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2481
+
2482
+
2483
+            return $output;
2484
+        }
2485
+
2486
+        /**
2487
+         * Increases or decreases the brightness of a color by a percentage of the current brightness.
2488
+         *
2489
+         * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
2490
+         * @param   float   $adjustPercent  A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
2491
+         *
2492
+         * @return  string
2493
+         */
2494
+        public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
2495
+            $hexCode = ltrim($hexCode, '#');
2496
+
2497
+            if (strlen($hexCode) == 3) {
2498
+                $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
2499
+            }
2500
+
2501
+            $hexCode = array_map('hexdec', str_split($hexCode, 2));
2502
+
2503
+            foreach ($hexCode as & $color) {
2504
+                $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
2505
+                $adjustAmount = ceil($adjustableLimit * $adjustPercent);
2506
+
2507
+                $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
2508
+            }
2509
+
2510
+            return '#' . implode($hexCode);
2511
+        }
2512
+
2513
+        /**
2514
+         * Check if we should display examples.
2515
+         */
2516
+        public function maybe_show_examples(){
2517
+            if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2518
+                echo "<head>";
2519
+                wp_head();
2520
+                echo "</head>";
2521
+                echo "<body>";
2522
+                echo $this->get_examples();
2523
+                echo "</body>";
2524
+                exit;
2525
+            }
2526
+        }
2527
+
2528
+        /**
2529
+         * Get developer examples.
2530
+         *
2531
+         * @return string
2532
+         */
2533
+        public function get_examples(){
2534
+            $output = '';
2535
+
2536
+
2537
+            // open form
2538
+            $output .= "<form class='p-5 m-5 border rounded'>";
2539
+
2540
+            // input example
2541
+            $output .= aui()->input(array(
2542
+                'type'  =>  'text',
2543
+                'id'    =>  'text-example',
2544
+                'name'    =>  'text-example',
2545
+                'placeholder'   => 'text placeholder',
2546
+                'title'   => 'Text input example',
2547
+                'value' =>  '',
2548
+                'required'  => false,
2549
+                'help_text' => 'help text',
2550
+                'label' => 'Text input example label'
2551
+            ));
2552
+
2553
+            // input example
2554
+            $output .= aui()->input(array(
2555
+                'type'  =>  'url',
2556
+                'id'    =>  'text-example2',
2557
+                'name'    =>  'text-example',
2558
+                'placeholder'   => 'url placeholder',
2559
+                'title'   => 'Text input example',
2560
+                'value' =>  '',
2561
+                'required'  => false,
2562
+                'help_text' => 'help text',
2563
+                'label' => 'Text input example label'
2564
+            ));
2565
+
2566
+            // checkbox example
2567
+            $output .= aui()->input(array(
2568
+                'type'  =>  'checkbox',
2569
+                'id'    =>  'checkbox-example',
2570
+                'name'    =>  'checkbox-example',
2571
+                'placeholder'   => 'checkbox-example',
2572
+                'title'   => 'Checkbox example',
2573
+                'value' =>  '1',
2574
+                'checked'   => true,
2575
+                'required'  => false,
2576
+                'help_text' => 'help text',
2577
+                'label' => 'Checkbox checked'
2578
+            ));
2579
+
2580
+            // checkbox example
2581
+            $output .= aui()->input(array(
2582
+                'type'  =>  'checkbox',
2583
+                'id'    =>  'checkbox-example2',
2584
+                'name'    =>  'checkbox-example2',
2585
+                'placeholder'   => 'checkbox-example',
2586
+                'title'   => 'Checkbox example',
2587
+                'value' =>  '1',
2588
+                'checked'   => false,
2589
+                'required'  => false,
2590
+                'help_text' => 'help text',
2591
+                'label' => 'Checkbox un-checked'
2592
+            ));
2593
+
2594
+            // switch example
2595
+            $output .= aui()->input(array(
2596
+                'type'  =>  'checkbox',
2597
+                'id'    =>  'switch-example',
2598
+                'name'    =>  'switch-example',
2599
+                'placeholder'   => 'checkbox-example',
2600
+                'title'   => 'Switch example',
2601
+                'value' =>  '1',
2602
+                'checked'   => true,
2603
+                'switch'    => true,
2604
+                'required'  => false,
2605
+                'help_text' => 'help text',
2606
+                'label' => 'Switch on'
2607
+            ));
2608
+
2609
+            // switch example
2610
+            $output .= aui()->input(array(
2611
+                'type'  =>  'checkbox',
2612
+                'id'    =>  'switch-example2',
2613
+                'name'    =>  'switch-example2',
2614
+                'placeholder'   => 'checkbox-example',
2615
+                'title'   => 'Switch example',
2616
+                'value' =>  '1',
2617
+                'checked'   => false,
2618
+                'switch'    => true,
2619
+                'required'  => false,
2620
+                'help_text' => 'help text',
2621
+                'label' => 'Switch off'
2622
+            ));
2623
+
2624
+            // close form
2625
+            $output .= "</form>";
2626
+
2627
+            return $output;
2628
+        }
2629
+
2630
+        /**
2631
+         * Calendar params.
2632
+         *
2633
+         * @since 0.1.44
2634
+         *
2635
+         * @return array Calendar params.
2636
+         */
2637
+        public static function calendar_params() {
2638
+            $params = array(
2639
+                'month_long_1' => __( 'January', 'aui' ),
2640
+                'month_long_2' => __( 'February', 'aui' ),
2641
+                'month_long_3' => __( 'March', 'aui' ),
2642
+                'month_long_4' => __( 'April', 'aui' ),
2643
+                'month_long_5' => __( 'May', 'aui' ),
2644
+                'month_long_6' => __( 'June', 'aui' ),
2645
+                'month_long_7' => __( 'July', 'aui' ),
2646
+                'month_long_8' => __( 'August', 'aui' ),
2647
+                'month_long_9' => __( 'September', 'aui' ),
2648
+                'month_long_10' => __( 'October', 'aui' ),
2649
+                'month_long_11' => __( 'November', 'aui' ),
2650
+                'month_long_12' => __( 'December', 'aui' ),
2651
+                'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ),
2652
+                'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ),
2653
+                'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ),
2654
+                'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ),
2655
+                'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ),
2656
+                'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ),
2657
+                'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ),
2658
+                'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ),
2659
+                'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ),
2660
+                'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ),
2661
+                'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ),
2662
+                'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ),
2663
+                'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ),
2664
+                'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ),
2665
+                'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ),
2666
+                'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ),
2667
+                'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ),
2668
+                'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ),
2669
+                'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ),
2670
+                'day_s2_1' => __( 'Su', 'aui' ),
2671
+                'day_s2_2' => __( 'Mo', 'aui' ),
2672
+                'day_s2_3' => __( 'Tu', 'aui' ),
2673
+                'day_s2_4' => __( 'We', 'aui' ),
2674
+                'day_s2_5' => __( 'Th', 'aui' ),
2675
+                'day_s2_6' => __( 'Fr', 'aui' ),
2676
+                'day_s2_7' => __( 'Sa', 'aui' ),
2677
+                'day_s3_1' => __( 'Sun', 'aui' ),
2678
+                'day_s3_2' => __( 'Mon', 'aui' ),
2679
+                'day_s3_3' => __( 'Tue', 'aui' ),
2680
+                'day_s3_4' => __( 'Wed', 'aui' ),
2681
+                'day_s3_5' => __( 'Thu', 'aui' ),
2682
+                'day_s3_6' => __( 'Fri', 'aui' ),
2683
+                'day_s3_7' => __( 'Sat', 'aui' ),
2684
+                'day_s5_1' => __( 'Sunday', 'aui' ),
2685
+                'day_s5_2' => __( 'Monday', 'aui' ),
2686
+                'day_s5_3' => __( 'Tuesday', 'aui' ),
2687
+                'day_s5_4' => __( 'Wednesday', 'aui' ),
2688
+                'day_s5_5' => __( 'Thursday', 'aui' ),
2689
+                'day_s5_6' => __( 'Friday', 'aui' ),
2690
+                'day_s5_7' => __( 'Saturday', 'aui' ),
2691
+                'am_lower' => __( 'am', 'aui' ),
2692
+                'pm_lower' => __( 'pm', 'aui' ),
2693
+                'am_upper' => __( 'AM', 'aui' ),
2694
+                'pm_upper' => __( 'PM', 'aui' ),
2695
+                'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2696
+                'time_24hr' => false,
2697
+                'year' => __( 'Year', 'aui' ),
2698
+                'hour' => __( 'Hour', 'aui' ),
2699
+                'minute' => __( 'Minute', 'aui' ),
2700
+                'weekAbbreviation' => __( 'Wk', 'aui' ),
2701
+                'rangeSeparator' => __( ' to ', 'aui' ),
2702
+                'scrollTitle' => __( 'Scroll to increment', 'aui' ),
2703
+                'toggleTitle' => __( 'Click to toggle', 'aui' )
2704
+            );
2705
+
2706
+            return apply_filters( 'ayecode_ui_calendar_params', $params );
2707
+        }
2708
+
2709
+        /**
2710
+         * Flatpickr calendar localize.
2711
+         *
2712
+         * @since 0.1.44
2713
+         *
2714
+         * @return string Calendar locale.
2715
+         */
2716
+        public static function flatpickr_locale() {
2717
+            $params = self::calendar_params();
2718
+
2719
+            if ( is_string( $params ) ) {
2720
+                $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2721
+            } else {
2722
+                foreach ( (array) $params as $key => $value ) {
2723
+                    if ( ! is_scalar( $value ) ) {
2724
+                        continue;
2725
+                    }
2726
+
2727
+                    $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2728
+                }
2729
+            }
2730 2730
 
2731
-			$day_s3 = array();
2732
-			$day_s5 = array();
2731
+            $day_s3 = array();
2732
+            $day_s5 = array();
2733 2733
 
2734
-			for ( $i = 1; $i <= 7; $i ++ ) {
2735
-				$day_s3[] = addslashes( $params[ 'day_s3_' . $i ] );
2736
-				$day_s5[] = addslashes( $params[ 'day_s3_' . $i ] );
2737
-			}
2734
+            for ( $i = 1; $i <= 7; $i ++ ) {
2735
+                $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] );
2736
+                $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] );
2737
+            }
2738 2738
 
2739
-			$month_s = array();
2740
-			$month_long = array();
2739
+            $month_s = array();
2740
+            $month_long = array();
2741 2741
 
2742
-			for ( $i = 1; $i <= 12; $i ++ ) {
2743
-				$month_s[] = addslashes( $params[ 'month_s_' . $i ] );
2744
-				$month_long[] = addslashes( $params[ 'month_long_' . $i ] );
2745
-			}
2742
+            for ( $i = 1; $i <= 12; $i ++ ) {
2743
+                $month_s[] = addslashes( $params[ 'month_s_' . $i ] );
2744
+                $month_long[] = addslashes( $params[ 'month_long_' . $i ] );
2745
+            }
2746 2746
 
2747
-			ob_start();
2748
-		if ( 0 ) { ?><script><?php } ?>
2747
+            ob_start();
2748
+        if ( 0 ) { ?><script><?php } ?>
2749 2749
                 {
2750 2750
                     weekdays: {
2751 2751
                         shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'],
@@ -2784,189 +2784,189 @@  discard block
 block discarded – undo
2784 2784
                 }
2785 2785
 				<?php if ( 0 ) { ?></script><?php } ?>
2786 2786
 			<?php
2787
-			$locale = ob_get_clean();
2788
-
2789
-			return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2790
-		}
2791
-
2792
-		/**
2793
-		 * Select2 JS params.
2794
-		 *
2795
-		 * @since 0.1.44
2796
-		 *
2797
-		 * @return array Select2 JS params.
2798
-		 */
2799
-		public static function select2_params() {
2800
-			$params = array(
2801
-				'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'aui' ),
2802
-				'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'aui' ),
2803
-				'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'aui' ),
2804
-				'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ),
2805
-				'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ),
2806
-				'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'aui' ),
2807
-				'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ),
2808
-				'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ),
2809
-				'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ),
2810
-				'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'aui' ),
2811
-				'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'aui' )
2812
-			);
2813
-
2814
-			return apply_filters( 'ayecode_ui_select2_params', $params );
2815
-		}
2816
-
2817
-		/**
2818
-		 * Select2 JS localize.
2819
-		 *
2820
-		 * @since 0.1.44
2821
-		 *
2822
-		 * @return string Select2 JS locale.
2823
-		 */
2824
-		public static function select2_locale() {
2825
-			$params = self::select2_params();
2826
-
2827
-			foreach ( (array) $params as $key => $value ) {
2828
-				if ( ! is_scalar( $value ) ) {
2829
-					continue;
2830
-				}
2787
+            $locale = ob_get_clean();
2788
+
2789
+            return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2790
+        }
2791
+
2792
+        /**
2793
+         * Select2 JS params.
2794
+         *
2795
+         * @since 0.1.44
2796
+         *
2797
+         * @return array Select2 JS params.
2798
+         */
2799
+        public static function select2_params() {
2800
+            $params = array(
2801
+                'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'aui' ),
2802
+                'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'aui' ),
2803
+                'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'aui' ),
2804
+                'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ),
2805
+                'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ),
2806
+                'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'aui' ),
2807
+                'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ),
2808
+                'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ),
2809
+                'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ),
2810
+                'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'aui' ),
2811
+                'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'aui' )
2812
+            );
2813
+
2814
+            return apply_filters( 'ayecode_ui_select2_params', $params );
2815
+        }
2816
+
2817
+        /**
2818
+         * Select2 JS localize.
2819
+         *
2820
+         * @since 0.1.44
2821
+         *
2822
+         * @return string Select2 JS locale.
2823
+         */
2824
+        public static function select2_locale() {
2825
+            $params = self::select2_params();
2826
+
2827
+            foreach ( (array) $params as $key => $value ) {
2828
+                if ( ! is_scalar( $value ) ) {
2829
+                    continue;
2830
+                }
2831 2831
 
2832
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2833
-			}
2834
-
2835
-			$locale = json_encode( $params );
2836
-
2837
-			return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2838
-		}
2839
-
2840
-		/**
2841
-		 * Time ago JS localize.
2842
-		 *
2843
-		 * @since 0.1.47
2844
-		 *
2845
-		 * @return string Time ago JS locale.
2846
-		 */
2847
-		public static function timeago_locale() {
2848
-			$params = array(
2849
-				'prefix_ago' => '',
2850
-				'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ),
2851
-				'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ',
2852
-				'suffix_after' => '',
2853
-				'seconds' => _x( 'less than a minute', 'time ago', 'aui' ),
2854
-				'minute' => _x( 'about a minute', 'time ago', 'aui' ),
2855
-				'minutes' => _x( '%d minutes', 'time ago', 'aui' ),
2856
-				'hour' => _x( 'about an hour', 'time ago', 'aui' ),
2857
-				'hours' => _x( 'about %d hours', 'time ago', 'aui' ),
2858
-				'day' => _x( 'a day', 'time ago', 'aui' ),
2859
-				'days' => _x( '%d days', 'time ago', 'aui' ),
2860
-				'month' => _x( 'about a month', 'time ago', 'aui' ),
2861
-				'months' => _x( '%d months', 'time ago', 'aui' ),
2862
-				'year' => _x( 'about a year', 'time ago', 'aui' ),
2863
-				'years' => _x( '%d years', 'time ago', 'aui' ),
2864
-			);
2865
-
2866
-			$params = apply_filters( 'ayecode_ui_timeago_params', $params );
2867
-
2868
-			foreach ( (array) $params as $key => $value ) {
2869
-				if ( ! is_scalar( $value ) ) {
2870
-					continue;
2871
-				}
2832
+                $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2833
+            }
2834
+
2835
+            $locale = json_encode( $params );
2836
+
2837
+            return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2838
+        }
2839
+
2840
+        /**
2841
+         * Time ago JS localize.
2842
+         *
2843
+         * @since 0.1.47
2844
+         *
2845
+         * @return string Time ago JS locale.
2846
+         */
2847
+        public static function timeago_locale() {
2848
+            $params = array(
2849
+                'prefix_ago' => '',
2850
+                'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ),
2851
+                'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ',
2852
+                'suffix_after' => '',
2853
+                'seconds' => _x( 'less than a minute', 'time ago', 'aui' ),
2854
+                'minute' => _x( 'about a minute', 'time ago', 'aui' ),
2855
+                'minutes' => _x( '%d minutes', 'time ago', 'aui' ),
2856
+                'hour' => _x( 'about an hour', 'time ago', 'aui' ),
2857
+                'hours' => _x( 'about %d hours', 'time ago', 'aui' ),
2858
+                'day' => _x( 'a day', 'time ago', 'aui' ),
2859
+                'days' => _x( '%d days', 'time ago', 'aui' ),
2860
+                'month' => _x( 'about a month', 'time ago', 'aui' ),
2861
+                'months' => _x( '%d months', 'time ago', 'aui' ),
2862
+                'year' => _x( 'about a year', 'time ago', 'aui' ),
2863
+                'years' => _x( '%d years', 'time ago', 'aui' ),
2864
+            );
2865
+
2866
+            $params = apply_filters( 'ayecode_ui_timeago_params', $params );
2867
+
2868
+            foreach ( (array) $params as $key => $value ) {
2869
+                if ( ! is_scalar( $value ) ) {
2870
+                    continue;
2871
+                }
2872 2872
 
2873
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2874
-			}
2875
-
2876
-			$locale = json_encode( $params );
2877
-
2878
-			return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2879
-		}
2880
-
2881
-		/**
2882
-		 * JavaScript Minifier
2883
-		 *
2884
-		 * @param $input
2885
-		 *
2886
-		 * @return mixed
2887
-		 */
2888
-		public static function minify_js($input) {
2889
-			if(trim($input) === "") return $input;
2890
-			return preg_replace(
2891
-				array(
2892
-					// Remove comment(s)
2893
-					'#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
2894
-					// Remove white-space(s) outside the string and regex
2895
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
2896
-					// Remove the last semicolon
2897
-					'#;+\}#',
2898
-					// Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}`
2899
-					'#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i',
2900
-					// --ibid. From `foo['bar']` to `foo.bar`
2901
-					'#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i'
2902
-				),
2903
-				array(
2904
-					'$1',
2905
-					'$1$2',
2906
-					'}',
2907
-					'$1$3',
2908
-					'$1.$3'
2909
-				),
2910
-				$input);
2911
-		}
2912
-
2913
-		/**
2914
-		 * Minify CSS
2915
-		 *
2916
-		 * @param $input
2917
-		 *
2918
-		 * @return mixed
2919
-		 */
2920
-		public static function minify_css($input) {
2921
-			if(trim($input) === "") return $input;
2922
-			return preg_replace(
2923
-				array(
2924
-					// Remove comment(s)
2925
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
2926
-					// Remove unused white-space(s)
2927
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
2928
-					// Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
2929
-					'#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
2930
-					// Replace `:0 0 0 0` with `:0`
2931
-					'#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
2932
-					// Replace `background-position:0` with `background-position:0 0`
2933
-					'#(background-position):0(?=[;\}])#si',
2934
-					// Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
2935
-					'#(?<=[\s:,\-])0+\.(\d+)#s',
2936
-					// Minify string value
2937
-					'#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
2938
-					'#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
2939
-					// Minify HEX color code
2940
-					'#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
2941
-					// Replace `(border|outline):none` with `(border|outline):0`
2942
-					'#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
2943
-					// Remove empty selector(s)
2944
-					'#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
2945
-				),
2946
-				array(
2947
-					'$1',
2948
-					'$1$2$3$4$5$6$7',
2949
-					'$1',
2950
-					':0',
2951
-					'$1:0 0',
2952
-					'.$1',
2953
-					'$1$3',
2954
-					'$1$2$4$5',
2955
-					'$1$2$3',
2956
-					'$1:0',
2957
-					'$1$2'
2958
-				),
2959
-				$input);
2960
-		}
2961
-
2962
-		/**
2963
-		 * Get the conditional fields JavaScript.
2964
-		 *
2965
-		 * @return mixed
2966
-		 */
2967
-		public function conditional_fields_js() {
2968
-			ob_start();
2969
-			?>
2873
+                $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2874
+            }
2875
+
2876
+            $locale = json_encode( $params );
2877
+
2878
+            return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2879
+        }
2880
+
2881
+        /**
2882
+         * JavaScript Minifier
2883
+         *
2884
+         * @param $input
2885
+         *
2886
+         * @return mixed
2887
+         */
2888
+        public static function minify_js($input) {
2889
+            if(trim($input) === "") return $input;
2890
+            return preg_replace(
2891
+                array(
2892
+                    // Remove comment(s)
2893
+                    '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
2894
+                    // Remove white-space(s) outside the string and regex
2895
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
2896
+                    // Remove the last semicolon
2897
+                    '#;+\}#',
2898
+                    // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}`
2899
+                    '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i',
2900
+                    // --ibid. From `foo['bar']` to `foo.bar`
2901
+                    '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i'
2902
+                ),
2903
+                array(
2904
+                    '$1',
2905
+                    '$1$2',
2906
+                    '}',
2907
+                    '$1$3',
2908
+                    '$1.$3'
2909
+                ),
2910
+                $input);
2911
+        }
2912
+
2913
+        /**
2914
+         * Minify CSS
2915
+         *
2916
+         * @param $input
2917
+         *
2918
+         * @return mixed
2919
+         */
2920
+        public static function minify_css($input) {
2921
+            if(trim($input) === "") return $input;
2922
+            return preg_replace(
2923
+                array(
2924
+                    // Remove comment(s)
2925
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
2926
+                    // Remove unused white-space(s)
2927
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
2928
+                    // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
2929
+                    '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
2930
+                    // Replace `:0 0 0 0` with `:0`
2931
+                    '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
2932
+                    // Replace `background-position:0` with `background-position:0 0`
2933
+                    '#(background-position):0(?=[;\}])#si',
2934
+                    // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
2935
+                    '#(?<=[\s:,\-])0+\.(\d+)#s',
2936
+                    // Minify string value
2937
+                    '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
2938
+                    '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
2939
+                    // Minify HEX color code
2940
+                    '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
2941
+                    // Replace `(border|outline):none` with `(border|outline):0`
2942
+                    '#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
2943
+                    // Remove empty selector(s)
2944
+                    '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
2945
+                ),
2946
+                array(
2947
+                    '$1',
2948
+                    '$1$2$3$4$5$6$7',
2949
+                    '$1',
2950
+                    ':0',
2951
+                    '$1:0 0',
2952
+                    '.$1',
2953
+                    '$1$3',
2954
+                    '$1$2$4$5',
2955
+                    '$1$2$3',
2956
+                    '$1:0',
2957
+                    '$1$2'
2958
+                ),
2959
+                $input);
2960
+        }
2961
+
2962
+        /**
2963
+         * Get the conditional fields JavaScript.
2964
+         *
2965
+         * @return mixed
2966
+         */
2967
+        public function conditional_fields_js() {
2968
+            ob_start();
2969
+            ?>
2970 2970
             <script>
2971 2971
                 /**
2972 2972
                  * Conditional Fields
@@ -3469,14 +3469,14 @@  discard block
 block discarded – undo
3469 3469
 				<?php do_action( 'aui_conditional_fields_js', $this ); ?>
3470 3470
             </script>
3471 3471
 			<?php
3472
-			$output = ob_get_clean();
3472
+            $output = ob_get_clean();
3473 3473
 
3474
-			return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
3475
-		}
3476
-	}
3474
+            return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
3475
+        }
3476
+    }
3477 3477
 
3478
-	/**
3479
-	 * Run the class if found.
3480
-	 */
3481
-	AyeCode_UI_Settings::instance();
3478
+    /**
3479
+     * Run the class if found.
3480
+     */
3481
+    AyeCode_UI_Settings::instance();
3482 3482
 }
3483 3483
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +553 added lines, -553 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'AyeCode_UI_Settings' ) ) {
22
+if (!class_exists('AyeCode_UI_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -99,27 +99,27 @@  discard block
 block discarded – undo
99 99
 		 * @return AyeCode_UI_Settings - Main instance.
100 100
 		 */
101 101
 		public static function instance() {
102
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
102
+			if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) {
103 103
 
104 104
 				self::$instance = new AyeCode_UI_Settings;
105 105
 
106
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
106
+				add_action('init', array(self::$instance, 'init')); // set settings
107 107
 
108
-				if ( is_admin() ) {
109
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
110
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
108
+				if (is_admin()) {
109
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
110
+					add_action('admin_init', array(self::$instance, 'register_settings'));
111 111
 
112 112
 					// Maybe show example page
113
-					add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
113
+					add_action('template_redirect', array(self::$instance, 'maybe_show_examples'));
114 114
 
115
-					if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
116
-						add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 );
115
+					if (defined('BLOCKSTRAP_VERSION')) {
116
+						add_filter('sd_aui_colors', array(self::$instance, 'sd_aui_colors'), 10, 3);
117 117
 					}
118 118
 				}
119 119
 
120
-				add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
120
+				add_action('customize_register', array(self::$instance, 'customizer_settings'));
121 121
 
122
-				do_action( 'ayecode_ui_settings_loaded' );
122
+				do_action('ayecode_ui_settings_loaded');
123 123
 			}
124 124
 
125 125
 			return self::$instance;
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 		 *
135 135
 		 * @return mixed
136 136
 		 */
137
-		public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){
137
+		public function sd_aui_colors($theme_colors, $include_outlines, $include_branding) {
138 138
 
139 139
 
140 140
 			$setting = wp_get_global_settings();
141 141
 
142
-			if(!empty($setting['color']['palette']['custom'])){
143
-				foreach($setting['color']['palette']['custom'] as $color){
142
+			if (!empty($setting['color']['palette']['custom'])) {
143
+				foreach ($setting['color']['palette']['custom'] as $color) {
144 144
 					$theme_colors[$color['slug']] = esc_attr($color['name']);
145 145
 				}
146 146
 			}
@@ -151,81 +151,81 @@  discard block
 block discarded – undo
151 151
 		/**
152 152
 		 * Setup some constants.
153 153
 		 */
154
-		public function constants(){
155
-			define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" );
156
-			define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' );
157
-			define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' );
158
-			define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' );
159
-			define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' );
160
-			define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' );
161
-			define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' );
162
-			define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' );
163
-			define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' );
164
-			define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' );
165
-			define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' );
166
-			define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' );
167
-			define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' );
168
-			define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' );
169
-			define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' );
170
-			define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' );
154
+		public function constants() {
155
+			define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be");
156
+			define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d');
157
+			define('AUI_INFO_COLOR_ORIGINAL', '#17a2b8');
158
+			define('AUI_WARNING_COLOR_ORIGINAL', '#ffc107');
159
+			define('AUI_DANGER_COLOR_ORIGINAL', '#dc3545');
160
+			define('AUI_SUCCESS_COLOR_ORIGINAL', '#44c553');
161
+			define('AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa');
162
+			define('AUI_DARK_COLOR_ORIGINAL', '#343a40');
163
+			define('AUI_WHITE_COLOR_ORIGINAL', '#fff');
164
+			define('AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd');
165
+			define('AUI_SALMON_COLOR_ORIGINAL', '#ff977a');
166
+			define('AUI_CYAN_COLOR_ORIGINAL', '#35bdff');
167
+			define('AUI_GRAY_COLOR_ORIGINAL', '#ced4da');
168
+			define('AUI_INDIGO_COLOR_ORIGINAL', '#502c6c');
169
+			define('AUI_ORANGE_COLOR_ORIGINAL', '#orange');
170
+			define('AUI_BLACK_COLOR_ORIGINAL', '#000');
171 171
 
172
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173
-				define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
172
+			if (!defined('AUI_PRIMARY_COLOR')) {
173
+				define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL);
174 174
 			}
175
-			if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) {
176
-				define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL );
175
+			if (!defined('AUI_SECONDARY_COLOR')) {
176
+				define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL);
177 177
 			}
178
-			if ( ! defined( 'AUI_INFO_COLOR' ) ) {
179
-				define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL );
178
+			if (!defined('AUI_INFO_COLOR')) {
179
+				define('AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL);
180 180
 			}
181
-			if ( ! defined( 'AUI_WARNING_COLOR' ) ) {
182
-				define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL );
181
+			if (!defined('AUI_WARNING_COLOR')) {
182
+				define('AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL);
183 183
 			}
184
-			if ( ! defined( 'AUI_DANGER_COLOR' ) ) {
185
-				define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL );
184
+			if (!defined('AUI_DANGER_COLOR')) {
185
+				define('AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL);
186 186
 			}
187
-			if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) {
188
-				define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL );
187
+			if (!defined('AUI_SUCCESS_COLOR')) {
188
+				define('AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL);
189 189
 			}
190
-			if ( ! defined( 'AUI_LIGHT_COLOR' ) ) {
191
-				define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL );
190
+			if (!defined('AUI_LIGHT_COLOR')) {
191
+				define('AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL);
192 192
 			}
193
-			if ( ! defined( 'AUI_DARK_COLOR' ) ) {
194
-				define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL );
193
+			if (!defined('AUI_DARK_COLOR')) {
194
+				define('AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL);
195 195
 			}
196
-			if ( ! defined( 'AUI_WHITE_COLOR' ) ) {
197
-				define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL );
196
+			if (!defined('AUI_WHITE_COLOR')) {
197
+				define('AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL);
198 198
 			}
199
-			if ( ! defined( 'AUI_PURPLE_COLOR' ) ) {
200
-				define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL );
199
+			if (!defined('AUI_PURPLE_COLOR')) {
200
+				define('AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL);
201 201
 			}
202
-			if ( ! defined( 'AUI_SALMON_COLOR' ) ) {
203
-				define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL );
202
+			if (!defined('AUI_SALMON_COLOR')) {
203
+				define('AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL);
204 204
 			}
205
-			if ( ! defined( 'AUI_CYAN_COLOR' ) ) {
206
-				define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL );
205
+			if (!defined('AUI_CYAN_COLOR')) {
206
+				define('AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL);
207 207
 			}
208
-			if ( ! defined( 'AUI_GRAY_COLOR' ) ) {
209
-				define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL );
208
+			if (!defined('AUI_GRAY_COLOR')) {
209
+				define('AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL);
210 210
 			}
211
-			if ( ! defined( 'AUI_INDIGO_COLOR' ) ) {
212
-				define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL );
211
+			if (!defined('AUI_INDIGO_COLOR')) {
212
+				define('AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL);
213 213
 			}
214
-			if ( ! defined( 'AUI_ORANGE_COLOR' ) ) {
215
-				define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL );
214
+			if (!defined('AUI_ORANGE_COLOR')) {
215
+				define('AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL);
216 216
 			}
217
-			if ( ! defined( 'AUI_BLACK_COLOR' ) ) {
218
-				define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL );
217
+			if (!defined('AUI_BLACK_COLOR')) {
218
+				define('AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL);
219 219
 			}
220 220
 
221 221
 		}
222 222
 
223
-		public static function get_colors( $original = false){
223
+		public static function get_colors($original = false) {
224 224
 
225
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
225
+			if (!defined('AUI_PRIMARY_COLOR')) {
226 226
 				return array();
227 227
 			}
228
-			if ( $original ) {
228
+			if ($original) {
229 229
 				return array(
230 230
 					'primary'   => AUI_PRIMARY_COLOR_ORIGINAL,
231 231
 					'secondary' => AUI_SECONDARY_COLOR_ORIGINAL,
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
 		public function init() {
273 273
 
274 274
 			// Maybe fix settings
275
-			if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) {
276
-				$db_settings = get_option( 'ayecode-ui-settings' );
277
-				if ( ! empty( $db_settings ) ) {
275
+			if (!empty($_REQUEST['aui-fix-admin']) && !empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], "aui-fix-admin")) {
276
+				$db_settings = get_option('ayecode-ui-settings');
277
+				if (!empty($db_settings)) {
278 278
 					$db_settings['css_backend'] = 'compatibility';
279 279
 					$db_settings['js_backend'] = 'core-popper';
280
-					update_option( 'ayecode-ui-settings', $db_settings );
280
+					update_option('ayecode-ui-settings', $db_settings);
281 281
 					wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true"));
282 282
 				}
283 283
 			}
@@ -291,31 +291,31 @@  discard block
 block discarded – undo
291 291
 			 *
292 292
 			 * We load super early in case there is a theme version that might change the colors
293 293
 			 */
294
-			if ( $this->settings['css'] ) {
294
+			if ($this->settings['css']) {
295 295
 				$priority = $this->is_bs3_compat() ? 100 : 1;
296
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority );
296
+				add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), $priority);
297 297
 			}
298
-			if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
299
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
298
+			if ($this->settings['css_backend'] && $this->load_admin_scripts()) {
299
+				add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1);
300 300
 			}
301 301
 
302 302
 			// maybe load JS
303
-			if ( $this->settings['js'] ) {
303
+			if ($this->settings['js']) {
304 304
 				$priority = $this->is_bs3_compat() ? 100 : 1;
305
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
305
+				add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), $priority);
306 306
 			}
307
-			if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
308
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
307
+			if ($this->settings['js_backend'] && $this->load_admin_scripts()) {
308
+				add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1);
309 309
 			}
310 310
 
311 311
 			// Maybe set the HTML font size
312
-			if ( $this->settings['html_font_size'] ) {
313
-				add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
312
+			if ($this->settings['html_font_size']) {
313
+				add_action('wp_footer', array($this, 'html_font_size'), 10);
314 314
 			}
315 315
 
316 316
 			// Maybe show backend style error
317
-			if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){
318
-				add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) );
317
+			if ($this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper') {
318
+				add_action('admin_notices', array($this, 'show_admin_style_notice'));
319 319
 			}
320 320
 
321 321
 		}
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
 		/**
324 324
 		 * Show admin notice if backend scripts not loaded.
325 325
 		 */
326
-		public function show_admin_style_notice(){
327
-			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin'));
328
-			$button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>';
329
-			$message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button;
330
-			echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>';
326
+		public function show_admin_style_notice() {
327
+			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=" . wp_create_nonce('aui-fix-admin'));
328
+			$button = '<a href="' . esc_url($fix_url) . '" class="button-primary">Fix Now</a>';
329
+			$message = __('<b>Style Issue:</b> AyeCode UI is disable or set wrong.') . " " . $button;
330
+			echo '<div class="notice notice-error aui-settings-error-notice"><p>' . $message . '</p></div>';
331 331
 		}
332 332
 
333 333
 		/**
@@ -335,14 +335,14 @@  discard block
 block discarded – undo
335 335
 		 *
336 336
 		 * @return bool
337 337
 		 */
338
-		public function load_admin_scripts(){
338
+		public function load_admin_scripts() {
339 339
 			$result = true;
340 340
 
341 341
 			// check if specifically disabled
342
-			if(!empty($this->settings['disable_admin'])){
343
-				$url_parts = explode("\n",$this->settings['disable_admin']);
344
-				foreach($url_parts as $part){
345
-					if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
342
+			if (!empty($this->settings['disable_admin'])) {
343
+				$url_parts = explode("\n", $this->settings['disable_admin']);
344
+				foreach ($url_parts as $part) {
345
+					if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) {
346 346
 						return false; // return early, no point checking further
347 347
 					}
348 348
 				}
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
 		/**
355 355
 		 * Add a html font size to the footer.
356 356
 		 */
357
-		public function html_font_size(){
357
+		public function html_font_size() {
358 358
 			$this->settings = $this->get_settings();
359
-			echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
359
+			echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>";
360 360
 		}
361 361
 
362 362
 		/**
@@ -364,11 +364,11 @@  discard block
 block discarded – undo
364 364
 		 *
365 365
 		 * @return bool
366 366
 		 */
367
-		public function is_aui_screen(){
367
+		public function is_aui_screen() {
368 368
 //			echo '###';exit;
369 369
 			$load = false;
370 370
 			// check if we should load or not
371
-			if ( is_admin() ) {
371
+			if (is_admin()) {
372 372
 				// Only enable on set pages
373 373
 				$aui_screens = array(
374 374
 					'page',
@@ -379,24 +379,24 @@  discard block
 block discarded – undo
379 379
 					'ayecode-ui-settings',
380 380
 					'site-editor'
381 381
 				);
382
-				$screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
382
+				$screen_ids = apply_filters('aui_screen_ids', $aui_screens);
383 383
 
384 384
 				$screen = get_current_screen();
385 385
 
386 386
 //				echo '###'.$screen->id;
387 387
 
388 388
 				// check if we are on a AUI screen
389
-				if ( $screen && in_array( $screen->id, $screen_ids ) ) {
389
+				if ($screen && in_array($screen->id, $screen_ids)) {
390 390
 					$load = true;
391 391
 				}
392 392
 
393 393
 				//load for widget previews in WP 5.8
394
-				if( !empty($_REQUEST['legacy-widget-preview'])){
394
+				if (!empty($_REQUEST['legacy-widget-preview'])) {
395 395
 					$load = true;
396 396
 				}
397 397
 			}
398 398
 
399
-			return apply_filters( 'aui_load_on_admin' , $load );
399
+			return apply_filters('aui_load_on_admin', $load);
400 400
 		}
401 401
 
402 402
 		/**
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 		 * @return bool
406 406
 		 */
407 407
 		public static function is_block_theme() {
408
-			if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) {
408
+			if (function_exists('wp_is_block_theme' && wp_is_block_theme())) {
409 409
 				return true;
410 410
 			}
411 411
 
@@ -418,37 +418,37 @@  discard block
 block discarded – undo
418 418
 		public function enqueue_style() {
419 419
 
420 420
 
421
-			if( is_admin() && !$this->is_aui_screen()){
421
+			if (is_admin() && !$this->is_aui_screen()) {
422 422
 				// don't add wp-admin scripts if not requested to
423
-			}else{
423
+			} else {
424 424
 				$css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
425 425
 
426 426
 				$rtl = is_rtl() ? '-rtl' : '';
427 427
 
428
-				if($this->settings[$css_setting]){
429
-					$compatibility = $this->settings[$css_setting]=='core' ? false : true;
430
-					$url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css';
428
+				if ($this->settings[$css_setting]) {
429
+					$compatibility = $this->settings[$css_setting] == 'core' ? false : true;
430
+					$url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets/css/ayecode-ui' . $rtl . '.css' : $this->url . 'assets/css/ayecode-ui-compatibility' . $rtl . '.css';
431 431
 
432 432
 
433 433
 
434
-					wp_register_style( 'ayecode-ui', $url, array(), $this->version );
435
-					wp_enqueue_style( 'ayecode-ui' );
434
+					wp_register_style('ayecode-ui', $url, array(), $this->version);
435
+					wp_enqueue_style('ayecode-ui');
436 436
 
437
-					$current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
437
+					$current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
438 438
 
439 439
 //					if ( is_admin() && !empty($_REQUEST['postType']) ) {
440
-					if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
441
-						$url = $this->url.'assets/css/ayecode-ui-fse.css';
442
-						wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version );
443
-						wp_enqueue_style( 'ayecode-ui-fse' );
440
+					if (is_admin() && (!empty($_REQUEST['postType']) || $current_screen->is_block_editor()) && (defined('BLOCKSTRAP_VERSION') || defined('AUI_FSE'))) {
441
+						$url = $this->url . 'assets/css/ayecode-ui-fse.css';
442
+						wp_register_style('ayecode-ui-fse', $url, array(), $this->version);
443
+						wp_enqueue_style('ayecode-ui-fse');
444 444
 					}
445 445
 
446 446
 
447 447
 					// flatpickr
448
-					wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->version );
448
+					wp_register_style('flatpickr', $this->url . 'assets/css/flatpickr.min.css', array(), $this->version);
449 449
 
450 450
 					// fix some wp-admin issues
451
-					if(is_admin()){
451
+					if (is_admin()) {
452 452
 						$custom_css = "
453 453
                 body{
454 454
                     background-color: #f1f1f1;
@@ -501,11 +501,11 @@  discard block
 block discarded – undo
501 501
 						    padding: 0;
502 502
 						}
503 503
 					";
504
-						wp_add_inline_style( 'ayecode-ui', $custom_css );
504
+						wp_add_inline_style('ayecode-ui', $custom_css);
505 505
 					}
506 506
 
507 507
 					// custom changes
508
-					wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
508
+					wp_add_inline_style('ayecode-ui', self::custom_css($compatibility));
509 509
 
510 510
 				}
511 511
 			}
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
                 function aui_init_flatpickr(){
769 769
                     if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) {
770 770
                         $aui_doing_init_flatpickr = true;
771
-						<?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?>
771
+						<?php if (!empty($flatpickr_locale)) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?>
772 772
                         jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr();
773 773
                     }
774 774
                     $aui_doing_init_flatpickr = false;
@@ -1461,7 +1461,7 @@  discard block
 block discarded – undo
1461 1461
 
1462 1462
 				<?php
1463 1463
 				// FSE tweaks.
1464
-				if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?>
1464
+				if (!empty($_REQUEST['postType']) && $_REQUEST['postType'] == 'wp_template') { ?>
1465 1465
                 function aui_fse_set_data_scroll() {
1466 1466
                     console.log('init scroll');
1467 1467
                     let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas");
@@ -1501,10 +1501,10 @@  discard block
 block discarded – undo
1501 1501
 			/*
1502 1502
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1503 1503
 			 */
1504
-			return str_replace( array(
1504
+			return str_replace(array(
1505 1505
 				'<script>',
1506 1506
 				'</script>'
1507
-			), '', self::minify_js($output) );
1507
+			), '', self::minify_js($output));
1508 1508
 		}
1509 1509
 
1510 1510
 
@@ -1518,13 +1518,13 @@  discard block
 block discarded – undo
1518 1518
 			ob_start();
1519 1519
 			?>
1520 1520
             <script>
1521
-				<?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
1521
+				<?php if (defined('FUSION_BUILDER_VERSION')) { ?>
1522 1522
                 /* With Avada builder */
1523 1523
 
1524 1524
 				<?php } ?>
1525 1525
             </script>
1526 1526
 			<?php
1527
-			return str_replace( array(
1527
+			return str_replace(array(
1528 1528
 				'<script>',
1529 1529
 				'</script>'
1530 1530
 			), '', ob_get_clean());
@@ -1535,7 +1535,7 @@  discard block
 block discarded – undo
1535 1535
 		 *
1536 1536
 		 * If this remains small then its best to use this than to add another JS file.
1537 1537
 		 */
1538
-		public function inline_script_file_browser(){
1538
+		public function inline_script_file_browser() {
1539 1539
 			ob_start();
1540 1540
 			?>
1541 1541
             <script>
@@ -1550,10 +1550,10 @@  discard block
 block discarded – undo
1550 1550
 			/*
1551 1551
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1552 1552
 			 */
1553
-			return str_replace( array(
1553
+			return str_replace(array(
1554 1554
 				'<script>',
1555 1555
 				'</script>'
1556
-			), '', $output );
1556
+			), '', $output);
1557 1557
 		}
1558 1558
 
1559 1559
 		/**
@@ -1561,53 +1561,53 @@  discard block
 block discarded – undo
1561 1561
 		 */
1562 1562
 		public function enqueue_scripts() {
1563 1563
 
1564
-			if( is_admin() && !$this->is_aui_screen()){
1564
+			if (is_admin() && !$this->is_aui_screen()) {
1565 1565
 				// don't add wp-admin scripts if not requested to
1566
-			}else {
1566
+			} else {
1567 1567
 
1568 1568
 				$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
1569 1569
 
1570 1570
 				// select2
1571
-				wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
1571
+				wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version);
1572 1572
 
1573 1573
 				// flatpickr
1574
-				wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
1574
+				wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version);
1575 1575
 
1576 1576
 				// flatpickr
1577
-				wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
1577
+				wp_register_script('iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version);
1578 1578
 
1579 1579
 				// Bootstrap file browser
1580
-				wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
1581
-				wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
1580
+				wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version);
1581
+				wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser());
1582 1582
 
1583 1583
 				$load_inline = false;
1584 1584
 
1585
-				if ( $this->settings[ $js_setting ] == 'core-popper' ) {
1585
+				if ($this->settings[$js_setting] == 'core-popper') {
1586 1586
 					// Bootstrap bundle
1587 1587
 					$url = $this->url . 'assets/js/bootstrap.bundle.min.js';
1588
-					wp_register_script( 'bootstrap-js-bundle', $url, array(
1588
+					wp_register_script('bootstrap-js-bundle', $url, array(
1589 1589
 						'select2',
1590 1590
 						'jquery'
1591
-					), $this->version, $this->is_bs3_compat() );
1591
+					), $this->version, $this->is_bs3_compat());
1592 1592
 					// if in admin then add to footer for compatibility.
1593
-					is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
1593
+					is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle');
1594 1594
 					$script = $this->inline_script();
1595
-					wp_add_inline_script( 'bootstrap-js-bundle', $script );
1596
-				} elseif ( $this->settings[ $js_setting ] == 'popper' ) {
1595
+					wp_add_inline_script('bootstrap-js-bundle', $script);
1596
+				} elseif ($this->settings[$js_setting] == 'popper') {
1597 1597
 					$url = $this->url . 'assets/js/popper.min.js';
1598
-					wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
1599
-					wp_enqueue_script( 'bootstrap-js-popper' );
1598
+					wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->version);
1599
+					wp_enqueue_script('bootstrap-js-popper');
1600 1600
 					$load_inline = true;
1601 1601
 				} else {
1602 1602
 					$load_inline = true;
1603 1603
 				}
1604 1604
 
1605 1605
 				// Load needed inline scripts by faking the loading of a script if the main script is not being loaded
1606
-				if ( $load_inline ) {
1607
-					wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
1608
-					wp_enqueue_script( 'bootstrap-dummy' );
1606
+				if ($load_inline) {
1607
+					wp_register_script('bootstrap-dummy', '', array('select2', 'jquery'));
1608
+					wp_enqueue_script('bootstrap-dummy');
1609 1609
 					$script = $this->inline_script();
1610
-					wp_add_inline_script( 'bootstrap-dummy', $script );
1610
+					wp_add_inline_script('bootstrap-dummy', $script);
1611 1611
 				}
1612 1612
 			}
1613 1613
 
@@ -1616,17 +1616,17 @@  discard block
 block discarded – undo
1616 1616
 		/**
1617 1617
 		 * Enqueue flatpickr if called.
1618 1618
 		 */
1619
-		public function enqueue_flatpickr(){
1620
-			wp_enqueue_style( 'flatpickr' );
1621
-			wp_enqueue_script( 'flatpickr' );
1619
+		public function enqueue_flatpickr() {
1620
+			wp_enqueue_style('flatpickr');
1621
+			wp_enqueue_script('flatpickr');
1622 1622
 		}
1623 1623
 
1624 1624
 		/**
1625 1625
 		 * Enqueue iconpicker if called.
1626 1626
 		 */
1627
-		public function enqueue_iconpicker(){
1628
-			wp_enqueue_style( 'iconpicker' );
1629
-			wp_enqueue_script( 'iconpicker' );
1627
+		public function enqueue_iconpicker() {
1628
+			wp_enqueue_style('iconpicker');
1629
+			wp_enqueue_script('iconpicker');
1630 1630
 		}
1631 1631
 
1632 1632
 		/**
@@ -1635,19 +1635,19 @@  discard block
 block discarded – undo
1635 1635
 		 * @return string
1636 1636
 		 */
1637 1637
 		public function get_url() {
1638
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1639
-			$content_url = untrailingslashit( WP_CONTENT_URL );
1638
+			$content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR));
1639
+			$content_url = untrailingslashit(WP_CONTENT_URL);
1640 1640
 
1641 1641
 			// Replace http:// to https://.
1642
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1643
-				$content_url = str_replace( 'http://', 'https://', $content_url );
1642
+			if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) {
1643
+				$content_url = str_replace('http://', 'https://', $content_url);
1644 1644
 			}
1645 1645
 
1646 1646
 			// Check if we are inside a plugin
1647
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1648
-			$url = str_replace( $content_dir, $content_url, $file_dir );
1647
+			$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
1648
+			$url = str_replace($content_dir, $content_url, $file_dir);
1649 1649
 
1650
-			return trailingslashit( $url );
1650
+			return trailingslashit($url);
1651 1651
 		}
1652 1652
 
1653 1653
 		/**
@@ -1659,15 +1659,15 @@  discard block
 block discarded – undo
1659 1659
 
1660 1660
 			$url = '';
1661 1661
 			// check if we are inside a plugin
1662
-			$file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
1662
+			$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
1663 1663
 
1664 1664
 			// add check in-case user has changed wp-content dir name.
1665 1665
 			$wp_content_folder_name = basename(WP_CONTENT_DIR);
1666
-			$dir_parts = explode("/$wp_content_folder_name/",$file_dir);
1667
-			$url_parts = explode("/$wp_content_folder_name/",plugins_url());
1666
+			$dir_parts = explode("/$wp_content_folder_name/", $file_dir);
1667
+			$url_parts = explode("/$wp_content_folder_name/", plugins_url());
1668 1668
 
1669
-			if(!empty($url_parts[0]) && !empty($dir_parts[1])){
1670
-				$url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
1669
+			if (!empty($url_parts[0]) && !empty($dir_parts[1])) {
1670
+				$url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]);
1671 1671
 			}
1672 1672
 
1673 1673
 			return $url;
@@ -1677,7 +1677,7 @@  discard block
 block discarded – undo
1677 1677
 		 * Register the database settings with WordPress.
1678 1678
 		 */
1679 1679
 		public function register_settings() {
1680
-			register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
1680
+			register_setting('ayecode-ui-settings', 'ayecode-ui-settings');
1681 1681
 		}
1682 1682
 
1683 1683
 		/**
@@ -1686,10 +1686,10 @@  discard block
 block discarded – undo
1686 1686
 		 */
1687 1687
 		public function menu_item() {
1688 1688
 			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
1689
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
1689
+			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
1690 1690
 				$this,
1691 1691
 				'settings_page'
1692
-			) );
1692
+			));
1693 1693
 		}
1694 1694
 
1695 1695
 		/**
@@ -1697,7 +1697,7 @@  discard block
 block discarded – undo
1697 1697
 		 *
1698 1698
 		 * @return array
1699 1699
 		 */
1700
-		public function theme_js_settings(){
1700
+		public function theme_js_settings() {
1701 1701
 			return array(
1702 1702
 				'ayetheme' => 'popper',
1703 1703
 				'listimia' => 'required',
@@ -1713,40 +1713,40 @@  discard block
 block discarded – undo
1713 1713
 		 */
1714 1714
 		public function get_settings() {
1715 1715
 
1716
-			$db_settings = get_option( 'ayecode-ui-settings' );
1716
+			$db_settings = get_option('ayecode-ui-settings');
1717 1717
 			$js_default = 'core-popper';
1718 1718
 			$js_default_backend = $js_default;
1719 1719
 
1720 1720
 			// maybe set defaults (if no settings set)
1721
-			if(empty($db_settings)){
1722
-				$active_theme = strtolower( get_template() ); // active parent theme.
1721
+			if (empty($db_settings)) {
1722
+				$active_theme = strtolower(get_template()); // active parent theme.
1723 1723
 				$theme_js_settings = self::theme_js_settings();
1724
-				if(isset($theme_js_settings[$active_theme])){
1724
+				if (isset($theme_js_settings[$active_theme])) {
1725 1725
 					$js_default = $theme_js_settings[$active_theme];
1726
-					$js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
1726
+					$js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default;
1727 1727
 				}
1728 1728
 			}
1729 1729
 
1730 1730
 			/**
1731 1731
 			 * Filter the default settings.
1732 1732
 			 */
1733
-			$defaults = apply_filters( 'ayecode-ui-default-settings', array(
1733
+			$defaults = apply_filters('ayecode-ui-default-settings', array(
1734 1734
 				'css'            => 'compatibility', // core, compatibility
1735 1735
 				'js'             => $js_default, // js to load, core-popper, popper
1736 1736
 				'html_font_size' => '16', // js to load, core-popper, popper
1737 1737
 				'css_backend'    => 'compatibility', // core, compatibility
1738 1738
 				'js_backend'     => $js_default_backend, // js to load, core-popper, popper
1739 1739
 				'disable_admin'  => '', // URL snippets to disable loading on admin
1740
-			), $db_settings );
1740
+			), $db_settings);
1741 1741
 
1742
-			$settings = wp_parse_args( $db_settings, $defaults );
1742
+			$settings = wp_parse_args($db_settings, $defaults);
1743 1743
 
1744 1744
 			/**
1745 1745
 			 * Filter the Bootstrap settings.
1746 1746
 			 *
1747 1747
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
1748 1748
 			 */
1749
-			return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
1749
+			return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults);
1750 1750
 		}
1751 1751
 
1752 1752
 
@@ -1754,90 +1754,90 @@  discard block
 block discarded – undo
1754 1754
 		 * The settings page html output.
1755 1755
 		 */
1756 1756
 		public function settings_page() {
1757
-			if ( ! current_user_can( 'manage_options' ) ) {
1758
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) );
1757
+			if (!current_user_can('manage_options')) {
1758
+				wp_die(__('You do not have sufficient permissions to access this page.', 'aui'));
1759 1759
 			}
1760 1760
 			?>
1761 1761
             <div class="wrap">
1762 1762
                 <h1><?php echo $this->name; ?></h1>
1763
-                <p><?php echo apply_filters( 'ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.",'aui') );?></p>
1763
+                <p><?php echo apply_filters('ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.", 'aui')); ?></p>
1764 1764
                 <form method="post" action="options.php">
1765 1765
 					<?php
1766
-					settings_fields( 'ayecode-ui-settings' );
1767
-					do_settings_sections( 'ayecode-ui-settings' );
1766
+					settings_fields('ayecode-ui-settings');
1767
+					do_settings_sections('ayecode-ui-settings');
1768 1768
 					?>
1769 1769
 
1770
-                    <h2><?php _e( 'Frontend', 'aui' ); ?></h2>
1770
+                    <h2><?php _e('Frontend', 'aui'); ?></h2>
1771 1771
                     <table class="form-table wpbs-table-settings">
1772 1772
                         <tr valign="top">
1773 1773
                             <th scope="row"><label
1774
-                                        for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th>
1774
+                                        for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th>
1775 1775
                             <td>
1776 1776
                                 <select name="ayecode-ui-settings[css]" id="wpbs-css">
1777
-                                    <option	value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option>
1778
-                                    <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option>
1779
-                                    <option	value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option>
1777
+                                    <option	value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option>
1778
+                                    <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option>
1779
+                                    <option	value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option>
1780 1780
                                 </select>
1781 1781
                             </td>
1782 1782
                         </tr>
1783 1783
 
1784 1784
                         <tr valign="top">
1785 1785
                             <th scope="row"><label
1786
-                                        for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th>
1786
+                                        for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th>
1787 1787
                             <td>
1788 1788
                                 <select name="ayecode-ui-settings[js]" id="wpbs-js">
1789
-                                    <option	value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option>
1790
-                                    <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option>
1791
-                                    <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option>
1792
-                                    <option	value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option>
1789
+                                    <option	value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option>
1790
+                                    <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option>
1791
+                                    <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option>
1792
+                                    <option	value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option>
1793 1793
                                 </select>
1794 1794
                             </td>
1795 1795
                         </tr>
1796 1796
 
1797 1797
                         <tr valign="top">
1798 1798
                             <th scope="row"><label
1799
-                                        for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th>
1799
+                                        for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th>
1800 1800
                             <td>
1801
-                                <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" />
1802
-                                <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.",'aui');?></p>
1801
+                                <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint($this->settings['html_font_size']); ?>" placeholder="16" />
1802
+                                <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", 'aui'); ?></p>
1803 1803
                             </td>
1804 1804
                         </tr>
1805 1805
 
1806 1806
                     </table>
1807 1807
 
1808
-                    <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2>
1808
+                    <h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2>
1809 1809
                     <table class="form-table wpbs-table-settings">
1810 1810
                         <tr valign="top">
1811 1811
                             <th scope="row"><label
1812
-                                        for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th>
1812
+                                        for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th>
1813 1813
                             <td>
1814 1814
                                 <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin">
1815
-                                    <option	value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option>
1816
-                                    <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode (will cause style issues)', 'aui' ); ?></option>
1817
-                                    <option	value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option>
1815
+                                    <option	value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option>
1816
+                                    <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode (will cause style issues)', 'aui'); ?></option>
1817
+                                    <option	value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option>
1818 1818
                                 </select>
1819 1819
                             </td>
1820 1820
                         </tr>
1821 1821
 
1822 1822
                         <tr valign="top">
1823 1823
                             <th scope="row"><label
1824
-                                        for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th>
1824
+                                        for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th>
1825 1825
                             <td>
1826 1826
                                 <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin">
1827
-                                    <option	value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option>
1828
-                                    <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option>
1829
-                                    <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option>
1830
-                                    <option	value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option>
1827
+                                    <option	value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option>
1828
+                                    <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option>
1829
+                                    <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option>
1830
+                                    <option	value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option>
1831 1831
                                 </select>
1832 1832
                             </td>
1833 1833
                         </tr>
1834 1834
 
1835 1835
                         <tr valign="top">
1836 1836
                             <th scope="row"><label
1837
-                                        for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th>
1837
+                                        for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th>
1838 1838
                             <td>
1839
-                                <p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui' ); ?></p>
1840
-                                <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php &#10;action=go"><?php echo $this->settings['disable_admin'];?></textarea>
1839
+                                <p><?php _e('If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui'); ?></p>
1840
+                                <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php &#10;action=go"><?php echo $this->settings['disable_admin']; ?></textarea>
1841 1841
 
1842 1842
                             </td>
1843 1843
                         </tr>
@@ -1855,9 +1855,9 @@  discard block
 block discarded – undo
1855 1855
 			<?php
1856 1856
 		}
1857 1857
 
1858
-		public function customizer_settings($wp_customize){
1858
+		public function customizer_settings($wp_customize) {
1859 1859
 			$wp_customize->add_section('aui_settings', array(
1860
-				'title'    => __('AyeCode UI','aui'),
1860
+				'title'    => __('AyeCode UI', 'aui'),
1861 1861
 				'priority' => 120,
1862 1862
 			));
1863 1863
 
@@ -1871,8 +1871,8 @@  discard block
 block discarded – undo
1871 1871
 				'type'              => 'option',
1872 1872
 				'transport'         => 'refresh',
1873 1873
 			));
1874
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1875
-				'label'    => __('Primary Color','aui'),
1874
+			$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1875
+				'label'    => __('Primary Color', 'aui'),
1876 1876
 				'section'  => 'aui_settings',
1877 1877
 				'settings' => 'aui_options[color_primary]',
1878 1878
 			)));
@@ -1884,8 +1884,8 @@  discard block
 block discarded – undo
1884 1884
 				'type'              => 'option',
1885 1885
 				'transport'         => 'refresh',
1886 1886
 			));
1887
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1888
-				'label'    => __('Secondary Color','aui'),
1887
+			$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1888
+				'label'    => __('Secondary Color', 'aui'),
1889 1889
 				'section'  => 'aui_settings',
1890 1890
 				'settings' => 'aui_options[color_secondary]',
1891 1891
 			)));
@@ -1911,12 +1911,12 @@  discard block
 block discarded – undo
1911 1911
                 .collapse.show:not(.in){display: inherit;}
1912 1912
                 .fade.show{opacity: 1;}
1913 1913
 
1914
-                <?php if( defined( 'SVQ_THEME_VERSION' ) ){ ?>
1914
+                <?php if (defined('SVQ_THEME_VERSION')) { ?>
1915 1915
                 /* KLEO theme specific */
1916 1916
                 .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: block !important;}
1917 1917
                 <?php } ?>
1918 1918
 
1919
-                <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
1919
+                <?php if (defined('FUSION_BUILDER_VERSION')) { ?>
1920 1920
                 /* With Avada builder */
1921 1921
                 body.modal-open .modal.in  {opacity:1;z-index: 99999}
1922 1922
                 body.modal-open .modal.bsui.in .modal-content  {box-shadow: none;}
@@ -1927,34 +1927,34 @@  discard block
 block discarded – undo
1927 1927
                 <?php } ?>
1928 1928
             </style>
1929 1929
 			<?php
1930
-			return str_replace( array(
1930
+			return str_replace(array(
1931 1931
 				'<style>',
1932 1932
 				'</style>'
1933
-			), '', self::minify_css( ob_get_clean() ) );
1933
+			), '', self::minify_css(ob_get_clean()));
1934 1934
 		}
1935 1935
 
1936 1936
 
1937 1937
 		public static function custom_css($compatibility = true) {
1938 1938
 			$colors = array();
1939
-			if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1939
+			if (defined('BLOCKSTRAP_VERSION')) {
1940 1940
 
1941 1941
 				$setting = wp_get_global_settings();
1942
-				if(!empty($setting['color']['palette']['theme'])){
1943
-					foreach($setting['color']['palette']['theme'] as $color){
1942
+				if (!empty($setting['color']['palette']['theme'])) {
1943
+					foreach ($setting['color']['palette']['theme'] as $color) {
1944 1944
 						$colors[$color['slug']] = esc_attr($color['color']);
1945 1945
 					}
1946 1946
 				}
1947 1947
 
1948
-				if(!empty($setting['color']['palette']['custom'])){
1949
-					foreach($setting['color']['palette']['custom'] as $color){
1948
+				if (!empty($setting['color']['palette']['custom'])) {
1949
+					foreach ($setting['color']['palette']['custom'] as $color) {
1950 1950
 						$colors[$color['slug']] = esc_attr($color['color']);
1951 1951
 					}
1952 1952
 				}
1953
-			}else{
1953
+			} else {
1954 1954
 				$settings = get_option('aui_options');
1955 1955
 				$colors = array(
1956
-					'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1957
-					'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1956
+					'primary'   => !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1957
+					'secondary' => !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1958 1958
 				);
1959 1959
 			}
1960 1960
 
@@ -1965,20 +1965,20 @@  discard block
 block discarded – undo
1965 1965
                 <?php
1966 1966
 
1967 1967
 					// BS v3 compat
1968
-					if( self::is_bs3_compat() ){
1968
+					if (self::is_bs3_compat()) {
1969 1969
 						echo self::bs3_compat_css();
1970 1970
 					}
1971 1971
 
1972
-					if(!empty($colors)){
1972
+					if (!empty($colors)) {
1973 1973
 						$d_colors = self::get_colors(true);
1974 1974
 						//print_r($d_colors );exit;
1975 1975
 //                        print_r($colors );exit;
1976
-						$is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template';
1977
-						foreach($colors as $key => $color ){
1978
-							if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1976
+						$is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType'] == 'wp_template';
1977
+						foreach ($colors as $key => $color) {
1978
+							if ((empty($d_colors[$key]) || $d_colors[$key] != $color) || $is_fse) {
1979 1979
 								$var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1980 1980
 								$compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1981
-								echo self::css_overwrite($key,$var,$compat);
1981
+								echo self::css_overwrite($key, $var, $compat);
1982 1982
 							}
1983 1983
 						}
1984 1984
 					   // exit;
@@ -1987,7 +1987,7 @@  discard block
 block discarded – undo
1987 1987
 					// Set admin bar z-index lower when modal is open.
1988 1988
 					echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1989 1989
 
1990
-					if(is_admin()){
1990
+					if (is_admin()) {
1991 1991
 						echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1992 1992
 					}
1993 1993
 				?>
@@ -1998,10 +1998,10 @@  discard block
 block discarded – undo
1998 1998
 			/*
1999 1999
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
2000 2000
 			 */
2001
-			return str_replace( array(
2001
+			return str_replace(array(
2002 2002
 				'<style>',
2003 2003
 				'</style>'
2004
-			), '', self::minify_css( ob_get_clean() ) );
2004
+			), '', self::minify_css(ob_get_clean()));
2005 2005
 		}
2006 2006
 
2007 2007
 
@@ -2011,7 +2011,7 @@  discard block
 block discarded – undo
2011 2011
 		 *
2012 2012
 		 * @return bool
2013 2013
 		 */
2014
-		public static function is_bs3_compat(){
2014
+		public static function is_bs3_compat() {
2015 2015
 			return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
2016 2016
 		}
2017 2017
 
@@ -2024,22 +2024,22 @@  discard block
 block discarded – undo
2024 2024
 		 *
2025 2025
 		 * @return string
2026 2026
 		 */
2027
-		public static function css_overwrite($type,$color_code,$compatibility){
2027
+		public static function css_overwrite($type, $color_code, $compatibility) {
2028 2028
 
2029 2029
 			$is_var = false;
2030
-			if(!$color_code){return '';}
2031
-			if(!sanitize_hex_color($color_code)){
2030
+			if (!$color_code) {return ''; }
2031
+			if (!sanitize_hex_color($color_code)) {
2032 2032
 				$color_code = esc_attr($color_code);
2033 2033
 				$is_var = true;
2034 2034
 //                echo '###1'.$color_code;//exit;
2035 2035
 			}
2036
-			if(!$color_code){return '';}
2036
+			if (!$color_code) {return ''; }
2037 2037
 
2038
-			if($compatibility===true || $compatibility===1){
2038
+			if ($compatibility === true || $compatibility === 1) {
2039 2039
 				$compatibility = '.bsui';
2040
-			}elseif(!$compatibility){
2040
+			}elseif (!$compatibility) {
2041 2041
 				$compatibility = '';
2042
-			}else{
2042
+			} else {
2043 2043
 				$compatibility = esc_attr($compatibility);
2044 2044
 			}
2045 2045
 
@@ -2051,25 +2051,25 @@  discard block
 block discarded – undo
2051 2051
 			 * c = color, b = background color, o = border-color, f = fill
2052 2052
 			 */
2053 2053
 			$selectors = array(
2054
-				".btn-{$type}"                                              => array( 'b', 'o' ),
2055
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
2056
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
2057
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
2058
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
2059
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
2060
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
2061
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
2062
-				".badge-{$type}"                                            => array( 'b' ),
2063
-				".alert-{$type}"                                            => array( 'b', 'o' ),
2064
-				".bg-{$type}"                                               => array( 'b', 'f' ),
2065
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
2054
+				".btn-{$type}"                                              => array('b', 'o'),
2055
+				".btn-{$type}.disabled"                                     => array('b', 'o'),
2056
+				".btn-{$type}:disabled"                                     => array('b', 'o'),
2057
+				".btn-outline-{$type}"                                      => array('c', 'o'),
2058
+				".btn-outline-{$type}:hover"                                => array('b', 'o'),
2059
+				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array('b', 'o'),
2060
+				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array('b', 'o'),
2061
+				".show>.btn-outline-{$type}.dropdown-toggle"                => array('b', 'o'),
2062
+				".badge-{$type}"                                            => array('b'),
2063
+				".alert-{$type}"                                            => array('b', 'o'),
2064
+				".bg-{$type}"                                               => array('b', 'f'),
2065
+				".btn-link.btn-{$type}"                                     => array('c'),
2066 2066
 			);
2067 2067
 
2068
-			if ( $type == 'primary' ) {
2068
+			if ($type == 'primary') {
2069 2069
 				$selectors = $selectors + array(
2070
-						'a'                                                                                                    => array( 'c' ),
2071
-						'.btn-link'                                                                                            => array( 'c' ),
2072
-						'.dropdown-item.active'                                                                                => array( 'b' ),
2070
+						'a'                                                                                                    => array('c'),
2071
+						'.btn-link'                                                                                            => array('c'),
2072
+						'.dropdown-item.active'                                                                                => array('b'),
2073 2073
 						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
2074 2074
 							'b',
2075 2075
 							'o'
@@ -2078,19 +2078,19 @@  discard block
 block discarded – undo
2078 2078
 							'b',
2079 2079
 							'o'
2080 2080
 						),
2081
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
2082
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
2083
-						'.page-link'                                                                                           => array( 'c' ),
2081
+						'.nav-pills .nav-link.active'                                                                          => array('b'),
2082
+						'.nav-pills .show>.nav-link'                                                                           => array('b'),
2083
+						'.page-link'                                                                                           => array('c'),
2084 2084
 						'.page-item.active .page-link'                                                                         => array(
2085 2085
 							'b',
2086 2086
 							'o'
2087 2087
 						),
2088
-						'.progress-bar'                                                                                        => array( 'b' ),
2088
+						'.progress-bar'                                                                                        => array('b'),
2089 2089
 						'.list-group-item.active'                                                                              => array(
2090 2090
 							'b',
2091 2091
 							'o'
2092 2092
 						),
2093
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
2093
+						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
2094 2094
 //				    '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
2095 2095
 //				    '.custom-range::-moz-range-thumb' => array('b'),
2096 2096
 //				    '.custom-range::-ms-thumb' => array('b'),
@@ -2098,7 +2098,7 @@  discard block
 block discarded – undo
2098 2098
 			}
2099 2099
 
2100 2100
 			$important_selectors = array(
2101
-				".bg-{$type}" => array('b','f'),
2101
+				".bg-{$type}" => array('b', 'f'),
2102 2102
 				".border-{$type}" => array('o'),
2103 2103
 				".text-{$type}" => array('c'),
2104 2104
 			);
@@ -2115,55 +2115,55 @@  discard block
 block discarded – undo
2115 2115
 			$output = '';
2116 2116
 
2117 2117
 			// build rules into each type
2118
-			foreach($selectors as $selector => $types){
2119
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
2120
-				$types = array_combine($types,$types);
2121
-				if(isset($types['c'])){$color[] = $selector;}
2122
-				if(isset($types['b'])){$background[] = $selector;}
2123
-				if(isset($types['o'])){$border[] = $selector;}
2124
-				if(isset($types['f'])){$fill[] = $selector;}
2118
+			foreach ($selectors as $selector => $types) {
2119
+				$selector = $compatibility ? $compatibility . " " . $selector : $selector;
2120
+				$types = array_combine($types, $types);
2121
+				if (isset($types['c'])) {$color[] = $selector; }
2122
+				if (isset($types['b'])) {$background[] = $selector; }
2123
+				if (isset($types['o'])) {$border[] = $selector; }
2124
+				if (isset($types['f'])) {$fill[] = $selector; }
2125 2125
 			}
2126 2126
 
2127 2127
 			// build rules into each type
2128
-			foreach($important_selectors as $selector => $types){
2129
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
2130
-				$types = array_combine($types,$types);
2131
-				if(isset($types['c'])){$color_i[] = $selector;}
2132
-				if(isset($types['b'])){$background_i[] = $selector;}
2133
-				if(isset($types['o'])){$border_i[] = $selector;}
2134
-				if(isset($types['f'])){$fill_i[] = $selector;}
2128
+			foreach ($important_selectors as $selector => $types) {
2129
+				$selector = $compatibility ? $compatibility . " " . $selector : $selector;
2130
+				$types = array_combine($types, $types);
2131
+				if (isset($types['c'])) {$color_i[] = $selector; }
2132
+				if (isset($types['b'])) {$background_i[] = $selector; }
2133
+				if (isset($types['o'])) {$border_i[] = $selector; }
2134
+				if (isset($types['f'])) {$fill_i[] = $selector; }
2135 2135
 			}
2136 2136
 
2137 2137
 			// add any color rules
2138
-			if(!empty($color)){
2139
-				$output .= implode(",",$color) . "{color: $color_code;} ";
2138
+			if (!empty($color)) {
2139
+				$output .= implode(",", $color) . "{color: $color_code;} ";
2140 2140
 			}
2141
-			if(!empty($color_i)){
2142
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2141
+			if (!empty($color_i)) {
2142
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
2143 2143
 			}
2144 2144
 
2145 2145
 			// add any background color rules
2146
-			if(!empty($background)){
2147
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
2146
+			if (!empty($background)) {
2147
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
2148 2148
 			}
2149
-			if(!empty($background_i)){
2150
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2149
+			if (!empty($background_i)) {
2150
+				$output .= implode(",", $background_i) . "{background-color: $color_code !important;} ";
2151 2151
 			}
2152 2152
 
2153 2153
 			// add any border color rules
2154
-			if(!empty($border)){
2155
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
2154
+			if (!empty($border)) {
2155
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
2156 2156
 			}
2157
-			if(!empty($border_i)){
2158
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2157
+			if (!empty($border_i)) {
2158
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
2159 2159
 			}
2160 2160
 
2161 2161
 			// add any fill color rules
2162
-			if(!empty($fill)){
2163
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
2162
+			if (!empty($fill)) {
2163
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
2164 2164
 			}
2165
-			if(!empty($fill_i)){
2166
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2165
+			if (!empty($fill_i)) {
2166
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
2167 2167
 			}
2168 2168
 
2169 2169
 
@@ -2171,26 +2171,26 @@  discard block
 block discarded – undo
2171 2171
 
2172 2172
 			$transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
2173 2173
 			// darken
2174
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
2175
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
2176
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
2174
+			$darker_075 = $is_var ? $color_code . ';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code, "-0.075");
2175
+			$darker_10 = $is_var ? $color_code . ';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code, "-0.10");
2176
+			$darker_125 = $is_var ? $color_code . ';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code, "-0.125");
2177 2177
 
2178 2178
 			// lighten
2179
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
2179
+			$lighten_25 = $is_var ? $color_code . ';filter:brightness(1.25)' : self::css_hex_lighten_darken($color_code, "0.25");
2180 2180
 
2181 2181
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
2182
-			$op_25 = $color_code."40"; // 25% opacity
2182
+			$op_25 = $color_code . "40"; // 25% opacity
2183 2183
 
2184 2184
 
2185 2185
 			// button states
2186
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
2187
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2186
+			$output .= $is_var ? $prefix . " .btn-{$type}{{$transition }} " : '';
2187
+			$output .= $prefix . " .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
2188 2188
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
2189
-			$output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2190
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2191
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2189
+			$output .= $prefix . " .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2190
+			$output .= $prefix . " .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: " . $darker_10 . ";    border-color: " . $darker_125 . ";} ";
2191
+			$output .= $prefix . " .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2192 2192
 
2193
-			if ( $type == 'primary' ) {
2193
+			if ($type == 'primary') {
2194 2194
 				// dropdown's
2195 2195
 				$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
2196 2196
 
@@ -2214,11 +2214,11 @@  discard block
 block discarded – undo
2214 2214
 		 *
2215 2215
 		 * @return string
2216 2216
 		 */
2217
-		public static function css_primary($color_code,$compatibility, $use_variable = false){
2217
+		public static function css_primary($color_code, $compatibility, $use_variable = false) {
2218 2218
 
2219
-			if(!$use_variable){
2219
+			if (!$use_variable) {
2220 2220
 				$color_code = sanitize_hex_color($color_code);
2221
-				if(!$color_code){return '';}
2221
+				if (!$color_code) {return ''; }
2222 2222
 			}
2223 2223
 
2224 2224
 			/**
@@ -2226,36 +2226,36 @@  discard block
 block discarded – undo
2226 2226
 			 */
2227 2227
 			$selectors = array(
2228 2228
 				'a' => array('c'),
2229
-				'.btn-primary' => array('b','o'),
2230
-				'.btn-primary.disabled' => array('b','o'),
2231
-				'.btn-primary:disabled' => array('b','o'),
2232
-				'.btn-outline-primary' => array('c','o'),
2233
-				'.btn-outline-primary:hover' => array('b','o'),
2234
-				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
2235
-				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
2236
-				'.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
2229
+				'.btn-primary' => array('b', 'o'),
2230
+				'.btn-primary.disabled' => array('b', 'o'),
2231
+				'.btn-primary:disabled' => array('b', 'o'),
2232
+				'.btn-outline-primary' => array('c', 'o'),
2233
+				'.btn-outline-primary:hover' => array('b', 'o'),
2234
+				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'),
2235
+				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'),
2236
+				'.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'),
2237 2237
 				'.btn-link' => array('c'),
2238 2238
 				'.dropdown-item.active' => array('b'),
2239
-				'.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
2240
-				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
2239
+				'.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'),
2240
+				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'),
2241 2241
 //				'.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
2242 2242
 //				'.custom-range::-moz-range-thumb' => array('b'),
2243 2243
 //				'.custom-range::-ms-thumb' => array('b'),
2244 2244
 				'.nav-pills .nav-link.active' => array('b'),
2245 2245
 				'.nav-pills .show>.nav-link' => array('b'),
2246 2246
 				'.page-link' => array('c'),
2247
-				'.page-item.active .page-link' => array('b','o'),
2247
+				'.page-item.active .page-link' => array('b', 'o'),
2248 2248
 				'.badge-primary' => array('b'),
2249
-				'.alert-primary' => array('b','o'),
2249
+				'.alert-primary' => array('b', 'o'),
2250 2250
 				'.progress-bar' => array('b'),
2251
-				'.list-group-item.active' => array('b','o'),
2252
-				'.bg-primary' => array('b','f'),
2251
+				'.list-group-item.active' => array('b', 'o'),
2252
+				'.bg-primary' => array('b', 'f'),
2253 2253
 				'.btn-link.btn-primary' => array('c'),
2254 2254
 				'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
2255 2255
 			);
2256 2256
 
2257 2257
 			$important_selectors = array(
2258
-				'.bg-primary' => array('b','f'),
2258
+				'.bg-primary' => array('b', 'f'),
2259 2259
 				'.border-primary' => array('o'),
2260 2260
 				'.text-primary' => array('c'),
2261 2261
 			);
@@ -2272,88 +2272,88 @@  discard block
 block discarded – undo
2272 2272
 			$output = '';
2273 2273
 
2274 2274
 			// build rules into each type
2275
-			foreach($selectors as $selector => $types){
2276
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2277
-				$types = array_combine($types,$types);
2278
-				if(isset($types['c'])){$color[] = $selector;}
2279
-				if(isset($types['b'])){$background[] = $selector;}
2280
-				if(isset($types['o'])){$border[] = $selector;}
2281
-				if(isset($types['f'])){$fill[] = $selector;}
2275
+			foreach ($selectors as $selector => $types) {
2276
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
2277
+				$types = array_combine($types, $types);
2278
+				if (isset($types['c'])) {$color[] = $selector; }
2279
+				if (isset($types['b'])) {$background[] = $selector; }
2280
+				if (isset($types['o'])) {$border[] = $selector; }
2281
+				if (isset($types['f'])) {$fill[] = $selector; }
2282 2282
 			}
2283 2283
 
2284 2284
 			// build rules into each type
2285
-			foreach($important_selectors as $selector => $types){
2286
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2287
-				$types = array_combine($types,$types);
2288
-				if(isset($types['c'])){$color_i[] = $selector;}
2289
-				if(isset($types['b'])){$background_i[] = $selector;}
2290
-				if(isset($types['o'])){$border_i[] = $selector;}
2291
-				if(isset($types['f'])){$fill_i[] = $selector;}
2285
+			foreach ($important_selectors as $selector => $types) {
2286
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
2287
+				$types = array_combine($types, $types);
2288
+				if (isset($types['c'])) {$color_i[] = $selector; }
2289
+				if (isset($types['b'])) {$background_i[] = $selector; }
2290
+				if (isset($types['o'])) {$border_i[] = $selector; }
2291
+				if (isset($types['f'])) {$fill_i[] = $selector; }
2292 2292
 			}
2293 2293
 
2294 2294
 			// add any color rules
2295
-			if(!empty($color)){
2296
-				$output .= implode(",",$color) . "{color: $color_code;} ";
2295
+			if (!empty($color)) {
2296
+				$output .= implode(",", $color) . "{color: $color_code;} ";
2297 2297
 			}
2298
-			if(!empty($color_i)){
2299
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2298
+			if (!empty($color_i)) {
2299
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
2300 2300
 			}
2301 2301
 
2302 2302
 			// add any background color rules
2303
-			if(!empty($background)){
2304
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
2303
+			if (!empty($background)) {
2304
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
2305 2305
 			}
2306
-			if(!empty($background_i)){
2307
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2306
+			if (!empty($background_i)) {
2307
+				$output .= implode(",", $background_i) . "{background-color: $color_code !important;} ";
2308 2308
 			}
2309 2309
 
2310 2310
 			// add any border color rules
2311
-			if(!empty($border)){
2312
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
2311
+			if (!empty($border)) {
2312
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
2313 2313
 			}
2314
-			if(!empty($border_i)){
2315
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2314
+			if (!empty($border_i)) {
2315
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
2316 2316
 			}
2317 2317
 
2318 2318
 			// add any fill color rules
2319
-			if(!empty($fill)){
2320
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
2319
+			if (!empty($fill)) {
2320
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
2321 2321
 			}
2322
-			if(!empty($fill_i)){
2323
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2322
+			if (!empty($fill_i)) {
2323
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
2324 2324
 			}
2325 2325
 
2326 2326
 
2327 2327
 			$prefix = $compatibility ? ".bsui " : "";
2328 2328
 
2329 2329
 			// darken
2330
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2331
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2332
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2330
+			$darker_075 = self::css_hex_lighten_darken($color_code, "-0.075");
2331
+			$darker_10 = self::css_hex_lighten_darken($color_code, "-0.10");
2332
+			$darker_125 = self::css_hex_lighten_darken($color_code, "-0.125");
2333 2333
 
2334 2334
 			// lighten
2335
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2335
+			$lighten_25 = self::css_hex_lighten_darken($color_code, "0.25");
2336 2336
 
2337 2337
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
2338
-			$op_25 = $color_code."40"; // 25% opacity
2338
+			$op_25 = $color_code . "40"; // 25% opacity
2339 2339
 
2340 2340
 
2341 2341
 			// button states
2342
-			$output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2343
-			$output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2344
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2345
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2342
+			$output .= $prefix . " .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
2343
+			$output .= $prefix . " .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2344
+			$output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: " . $darker_10 . ";    border-color: " . $darker_125 . ";} ";
2345
+			$output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2346 2346
 
2347 2347
 
2348 2348
 			// dropdown's
2349
-			$output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
2349
+			$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
2350 2350
 
2351 2351
 
2352 2352
 			// input states
2353
-			$output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
2353
+			$output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
2354 2354
 
2355 2355
 			// page link
2356
-			$output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2356
+			$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2357 2357
 
2358 2358
 			return $output;
2359 2359
 		}
@@ -2367,30 +2367,30 @@  discard block
 block discarded – undo
2367 2367
 		 *
2368 2368
 		 * @return string
2369 2369
 		 */
2370
-		public static function css_secondary($color_code,$compatibility){;
2370
+		public static function css_secondary($color_code, $compatibility) {;
2371 2371
 			$color_code = sanitize_hex_color($color_code);
2372
-			if(!$color_code){return '';}
2372
+			if (!$color_code) {return ''; }
2373 2373
 			/**
2374 2374
 			 * c = color, b = background color, o = border-color, f = fill
2375 2375
 			 */
2376 2376
 			$selectors = array(
2377
-				'.btn-secondary' => array('b','o'),
2378
-				'.btn-secondary.disabled' => array('b','o'),
2379
-				'.btn-secondary:disabled' => array('b','o'),
2380
-				'.btn-outline-secondary' => array('c','o'),
2381
-				'.btn-outline-secondary:hover' => array('b','o'),
2377
+				'.btn-secondary' => array('b', 'o'),
2378
+				'.btn-secondary.disabled' => array('b', 'o'),
2379
+				'.btn-secondary:disabled' => array('b', 'o'),
2380
+				'.btn-outline-secondary' => array('c', 'o'),
2381
+				'.btn-outline-secondary:hover' => array('b', 'o'),
2382 2382
 				'.btn-outline-secondary.disabled' => array('c'),
2383 2383
 				'.btn-outline-secondary:disabled' => array('c'),
2384
-				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
2385
-				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
2386
-				'.btn-outline-secondary.dropdown-toggle' => array('b','o'),
2384
+				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'),
2385
+				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'),
2386
+				'.btn-outline-secondary.dropdown-toggle' => array('b', 'o'),
2387 2387
 				'.badge-secondary' => array('b'),
2388
-				'.alert-secondary' => array('b','o'),
2388
+				'.alert-secondary' => array('b', 'o'),
2389 2389
 				'.btn-link.btn-secondary' => array('c'),
2390 2390
 			);
2391 2391
 
2392 2392
 			$important_selectors = array(
2393
-				'.bg-secondary' => array('b','f'),
2393
+				'.bg-secondary' => array('b', 'f'),
2394 2394
 				'.border-secondary' => array('o'),
2395 2395
 				'.text-secondary' => array('c'),
2396 2396
 			);
@@ -2407,77 +2407,77 @@  discard block
 block discarded – undo
2407 2407
 			$output = '';
2408 2408
 
2409 2409
 			// build rules into each type
2410
-			foreach($selectors as $selector => $types){
2411
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2412
-				$types = array_combine($types,$types);
2413
-				if(isset($types['c'])){$color[] = $selector;}
2414
-				if(isset($types['b'])){$background[] = $selector;}
2415
-				if(isset($types['o'])){$border[] = $selector;}
2416
-				if(isset($types['f'])){$fill[] = $selector;}
2410
+			foreach ($selectors as $selector => $types) {
2411
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
2412
+				$types = array_combine($types, $types);
2413
+				if (isset($types['c'])) {$color[] = $selector; }
2414
+				if (isset($types['b'])) {$background[] = $selector; }
2415
+				if (isset($types['o'])) {$border[] = $selector; }
2416
+				if (isset($types['f'])) {$fill[] = $selector; }
2417 2417
 			}
2418 2418
 
2419 2419
 			// build rules into each type
2420
-			foreach($important_selectors as $selector => $types){
2421
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2422
-				$types = array_combine($types,$types);
2423
-				if(isset($types['c'])){$color_i[] = $selector;}
2424
-				if(isset($types['b'])){$background_i[] = $selector;}
2425
-				if(isset($types['o'])){$border_i[] = $selector;}
2426
-				if(isset($types['f'])){$fill_i[] = $selector;}
2420
+			foreach ($important_selectors as $selector => $types) {
2421
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
2422
+				$types = array_combine($types, $types);
2423
+				if (isset($types['c'])) {$color_i[] = $selector; }
2424
+				if (isset($types['b'])) {$background_i[] = $selector; }
2425
+				if (isset($types['o'])) {$border_i[] = $selector; }
2426
+				if (isset($types['f'])) {$fill_i[] = $selector; }
2427 2427
 			}
2428 2428
 
2429 2429
 			// add any color rules
2430
-			if(!empty($color)){
2431
-				$output .= implode(",",$color) . "{color: $color_code;} ";
2430
+			if (!empty($color)) {
2431
+				$output .= implode(",", $color) . "{color: $color_code;} ";
2432 2432
 			}
2433
-			if(!empty($color_i)){
2434
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2433
+			if (!empty($color_i)) {
2434
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
2435 2435
 			}
2436 2436
 
2437 2437
 			// add any background color rules
2438
-			if(!empty($background)){
2439
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
2438
+			if (!empty($background)) {
2439
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
2440 2440
 			}
2441
-			if(!empty($background_i)){
2442
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2441
+			if (!empty($background_i)) {
2442
+				$output .= implode(",", $background_i) . "{background-color: $color_code !important;} ";
2443 2443
 			}
2444 2444
 
2445 2445
 			// add any border color rules
2446
-			if(!empty($border)){
2447
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
2446
+			if (!empty($border)) {
2447
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
2448 2448
 			}
2449
-			if(!empty($border_i)){
2450
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2449
+			if (!empty($border_i)) {
2450
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
2451 2451
 			}
2452 2452
 
2453 2453
 			// add any fill color rules
2454
-			if(!empty($fill)){
2455
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
2454
+			if (!empty($fill)) {
2455
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
2456 2456
 			}
2457
-			if(!empty($fill_i)){
2458
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2457
+			if (!empty($fill_i)) {
2458
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
2459 2459
 			}
2460 2460
 
2461 2461
 
2462 2462
 			$prefix = $compatibility ? ".bsui " : "";
2463 2463
 
2464 2464
 			// darken
2465
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2466
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2467
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2465
+			$darker_075 = self::css_hex_lighten_darken($color_code, "-0.075");
2466
+			$darker_10 = self::css_hex_lighten_darken($color_code, "-0.10");
2467
+			$darker_125 = self::css_hex_lighten_darken($color_code, "-0.125");
2468 2468
 
2469 2469
 			// lighten
2470
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2470
+			$lighten_25 = self::css_hex_lighten_darken($color_code, "0.25");
2471 2471
 
2472 2472
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
2473
-			$op_25 = $color_code."40"; // 25% opacity
2473
+			$op_25 = $color_code . "40"; // 25% opacity
2474 2474
 
2475 2475
 
2476 2476
 			// button states
2477
-			$output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2478
-			$output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2479
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2480
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2477
+			$output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
2478
+			$output .= $prefix . " .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2479
+			$output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: " . $darker_10 . ";    border-color: " . $darker_125 . ";} ";
2480
+			$output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2481 2481
 
2482 2482
 
2483 2483
 			return $output;
@@ -2513,8 +2513,8 @@  discard block
 block discarded – undo
2513 2513
 		/**
2514 2514
 		 * Check if we should display examples.
2515 2515
 		 */
2516
-		public function maybe_show_examples(){
2517
-			if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2516
+		public function maybe_show_examples() {
2517
+			if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) {
2518 2518
 				echo "<head>";
2519 2519
 				wp_head();
2520 2520
 				echo "</head>";
@@ -2530,7 +2530,7 @@  discard block
 block discarded – undo
2530 2530
 		 *
2531 2531
 		 * @return string
2532 2532
 		 */
2533
-		public function get_examples(){
2533
+		public function get_examples() {
2534 2534
 			$output = '';
2535 2535
 
2536 2536
 
@@ -2636,74 +2636,74 @@  discard block
 block discarded – undo
2636 2636
 		 */
2637 2637
 		public static function calendar_params() {
2638 2638
 			$params = array(
2639
-				'month_long_1' => __( 'January', 'aui' ),
2640
-				'month_long_2' => __( 'February', 'aui' ),
2641
-				'month_long_3' => __( 'March', 'aui' ),
2642
-				'month_long_4' => __( 'April', 'aui' ),
2643
-				'month_long_5' => __( 'May', 'aui' ),
2644
-				'month_long_6' => __( 'June', 'aui' ),
2645
-				'month_long_7' => __( 'July', 'aui' ),
2646
-				'month_long_8' => __( 'August', 'aui' ),
2647
-				'month_long_9' => __( 'September', 'aui' ),
2648
-				'month_long_10' => __( 'October', 'aui' ),
2649
-				'month_long_11' => __( 'November', 'aui' ),
2650
-				'month_long_12' => __( 'December', 'aui' ),
2651
-				'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ),
2652
-				'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ),
2653
-				'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ),
2654
-				'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ),
2655
-				'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ),
2656
-				'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ),
2657
-				'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ),
2658
-				'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ),
2659
-				'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ),
2660
-				'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ),
2661
-				'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ),
2662
-				'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ),
2663
-				'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ),
2664
-				'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ),
2665
-				'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ),
2666
-				'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ),
2667
-				'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ),
2668
-				'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ),
2669
-				'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ),
2670
-				'day_s2_1' => __( 'Su', 'aui' ),
2671
-				'day_s2_2' => __( 'Mo', 'aui' ),
2672
-				'day_s2_3' => __( 'Tu', 'aui' ),
2673
-				'day_s2_4' => __( 'We', 'aui' ),
2674
-				'day_s2_5' => __( 'Th', 'aui' ),
2675
-				'day_s2_6' => __( 'Fr', 'aui' ),
2676
-				'day_s2_7' => __( 'Sa', 'aui' ),
2677
-				'day_s3_1' => __( 'Sun', 'aui' ),
2678
-				'day_s3_2' => __( 'Mon', 'aui' ),
2679
-				'day_s3_3' => __( 'Tue', 'aui' ),
2680
-				'day_s3_4' => __( 'Wed', 'aui' ),
2681
-				'day_s3_5' => __( 'Thu', 'aui' ),
2682
-				'day_s3_6' => __( 'Fri', 'aui' ),
2683
-				'day_s3_7' => __( 'Sat', 'aui' ),
2684
-				'day_s5_1' => __( 'Sunday', 'aui' ),
2685
-				'day_s5_2' => __( 'Monday', 'aui' ),
2686
-				'day_s5_3' => __( 'Tuesday', 'aui' ),
2687
-				'day_s5_4' => __( 'Wednesday', 'aui' ),
2688
-				'day_s5_5' => __( 'Thursday', 'aui' ),
2689
-				'day_s5_6' => __( 'Friday', 'aui' ),
2690
-				'day_s5_7' => __( 'Saturday', 'aui' ),
2691
-				'am_lower' => __( 'am', 'aui' ),
2692
-				'pm_lower' => __( 'pm', 'aui' ),
2693
-				'am_upper' => __( 'AM', 'aui' ),
2694
-				'pm_upper' => __( 'PM', 'aui' ),
2695
-				'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2639
+				'month_long_1' => __('January', 'aui'),
2640
+				'month_long_2' => __('February', 'aui'),
2641
+				'month_long_3' => __('March', 'aui'),
2642
+				'month_long_4' => __('April', 'aui'),
2643
+				'month_long_5' => __('May', 'aui'),
2644
+				'month_long_6' => __('June', 'aui'),
2645
+				'month_long_7' => __('July', 'aui'),
2646
+				'month_long_8' => __('August', 'aui'),
2647
+				'month_long_9' => __('September', 'aui'),
2648
+				'month_long_10' => __('October', 'aui'),
2649
+				'month_long_11' => __('November', 'aui'),
2650
+				'month_long_12' => __('December', 'aui'),
2651
+				'month_s_1' => _x('Jan', 'January abbreviation', 'aui'),
2652
+				'month_s_2' => _x('Feb', 'February abbreviation', 'aui'),
2653
+				'month_s_3' => _x('Mar', 'March abbreviation', 'aui'),
2654
+				'month_s_4' => _x('Apr', 'April abbreviation', 'aui'),
2655
+				'month_s_5' => _x('May', 'May abbreviation', 'aui'),
2656
+				'month_s_6' => _x('Jun', 'June abbreviation', 'aui'),
2657
+				'month_s_7' => _x('Jul', 'July abbreviation', 'aui'),
2658
+				'month_s_8' => _x('Aug', 'August abbreviation', 'aui'),
2659
+				'month_s_9' => _x('Sep', 'September abbreviation', 'aui'),
2660
+				'month_s_10' => _x('Oct', 'October abbreviation', 'aui'),
2661
+				'month_s_11' => _x('Nov', 'November abbreviation', 'aui'),
2662
+				'month_s_12' => _x('Dec', 'December abbreviation', 'aui'),
2663
+				'day_s1_1' => _x('S', 'Sunday initial', 'aui'),
2664
+				'day_s1_2' => _x('M', 'Monday initial', 'aui'),
2665
+				'day_s1_3' => _x('T', 'Tuesday initial', 'aui'),
2666
+				'day_s1_4' => _x('W', 'Wednesday initial', 'aui'),
2667
+				'day_s1_5' => _x('T', 'Friday initial', 'aui'),
2668
+				'day_s1_6' => _x('F', 'Thursday initial', 'aui'),
2669
+				'day_s1_7' => _x('S', 'Saturday initial', 'aui'),
2670
+				'day_s2_1' => __('Su', 'aui'),
2671
+				'day_s2_2' => __('Mo', 'aui'),
2672
+				'day_s2_3' => __('Tu', 'aui'),
2673
+				'day_s2_4' => __('We', 'aui'),
2674
+				'day_s2_5' => __('Th', 'aui'),
2675
+				'day_s2_6' => __('Fr', 'aui'),
2676
+				'day_s2_7' => __('Sa', 'aui'),
2677
+				'day_s3_1' => __('Sun', 'aui'),
2678
+				'day_s3_2' => __('Mon', 'aui'),
2679
+				'day_s3_3' => __('Tue', 'aui'),
2680
+				'day_s3_4' => __('Wed', 'aui'),
2681
+				'day_s3_5' => __('Thu', 'aui'),
2682
+				'day_s3_6' => __('Fri', 'aui'),
2683
+				'day_s3_7' => __('Sat', 'aui'),
2684
+				'day_s5_1' => __('Sunday', 'aui'),
2685
+				'day_s5_2' => __('Monday', 'aui'),
2686
+				'day_s5_3' => __('Tuesday', 'aui'),
2687
+				'day_s5_4' => __('Wednesday', 'aui'),
2688
+				'day_s5_5' => __('Thursday', 'aui'),
2689
+				'day_s5_6' => __('Friday', 'aui'),
2690
+				'day_s5_7' => __('Saturday', 'aui'),
2691
+				'am_lower' => __('am', 'aui'),
2692
+				'pm_lower' => __('pm', 'aui'),
2693
+				'am_upper' => __('AM', 'aui'),
2694
+				'pm_upper' => __('PM', 'aui'),
2695
+				'firstDayOfWeek' => (int) get_option('start_of_week'),
2696 2696
 				'time_24hr' => false,
2697
-				'year' => __( 'Year', 'aui' ),
2698
-				'hour' => __( 'Hour', 'aui' ),
2699
-				'minute' => __( 'Minute', 'aui' ),
2700
-				'weekAbbreviation' => __( 'Wk', 'aui' ),
2701
-				'rangeSeparator' => __( ' to ', 'aui' ),
2702
-				'scrollTitle' => __( 'Scroll to increment', 'aui' ),
2703
-				'toggleTitle' => __( 'Click to toggle', 'aui' )
2697
+				'year' => __('Year', 'aui'),
2698
+				'hour' => __('Hour', 'aui'),
2699
+				'minute' => __('Minute', 'aui'),
2700
+				'weekAbbreviation' => __('Wk', 'aui'),
2701
+				'rangeSeparator' => __(' to ', 'aui'),
2702
+				'scrollTitle' => __('Scroll to increment', 'aui'),
2703
+				'toggleTitle' => __('Click to toggle', 'aui')
2704 2704
 			);
2705 2705
 
2706
-			return apply_filters( 'ayecode_ui_calendar_params', $params );
2706
+			return apply_filters('ayecode_ui_calendar_params', $params);
2707 2707
 		}
2708 2708
 
2709 2709
 		/**
@@ -2716,47 +2716,47 @@  discard block
 block discarded – undo
2716 2716
 		public static function flatpickr_locale() {
2717 2717
 			$params = self::calendar_params();
2718 2718
 
2719
-			if ( is_string( $params ) ) {
2720
-				$params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2719
+			if (is_string($params)) {
2720
+				$params = html_entity_decode($params, ENT_QUOTES, 'UTF-8');
2721 2721
 			} else {
2722
-				foreach ( (array) $params as $key => $value ) {
2723
-					if ( ! is_scalar( $value ) ) {
2722
+				foreach ((array) $params as $key => $value) {
2723
+					if (!is_scalar($value)) {
2724 2724
 						continue;
2725 2725
 					}
2726 2726
 
2727
-					$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2727
+					$params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
2728 2728
 				}
2729 2729
 			}
2730 2730
 
2731 2731
 			$day_s3 = array();
2732 2732
 			$day_s5 = array();
2733 2733
 
2734
-			for ( $i = 1; $i <= 7; $i ++ ) {
2735
-				$day_s3[] = addslashes( $params[ 'day_s3_' . $i ] );
2736
-				$day_s5[] = addslashes( $params[ 'day_s3_' . $i ] );
2734
+			for ($i = 1; $i <= 7; $i++) {
2735
+				$day_s3[] = addslashes($params['day_s3_' . $i]);
2736
+				$day_s5[] = addslashes($params['day_s3_' . $i]);
2737 2737
 			}
2738 2738
 
2739 2739
 			$month_s = array();
2740 2740
 			$month_long = array();
2741 2741
 
2742
-			for ( $i = 1; $i <= 12; $i ++ ) {
2743
-				$month_s[] = addslashes( $params[ 'month_s_' . $i ] );
2744
-				$month_long[] = addslashes( $params[ 'month_long_' . $i ] );
2742
+			for ($i = 1; $i <= 12; $i++) {
2743
+				$month_s[] = addslashes($params['month_s_' . $i]);
2744
+				$month_long[] = addslashes($params['month_long_' . $i]);
2745 2745
 			}
2746 2746
 
2747 2747
 			ob_start();
2748
-		if ( 0 ) { ?><script><?php } ?>
2748
+		if (0) { ?><script><?php } ?>
2749 2749
                 {
2750 2750
                     weekdays: {
2751
-                        shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'],
2752
-                            longhand: ['<?php echo implode( "','", $day_s5 ); ?>'],
2751
+                        shorthand: ['<?php echo implode("','", $day_s3); ?>'],
2752
+                            longhand: ['<?php echo implode("','", $day_s5); ?>'],
2753 2753
                     },
2754 2754
                     months: {
2755
-                        shorthand: ['<?php echo implode( "','", $month_s ); ?>'],
2756
-                            longhand: ['<?php echo implode( "','", $month_long ); ?>'],
2755
+                        shorthand: ['<?php echo implode("','", $month_s); ?>'],
2756
+                            longhand: ['<?php echo implode("','", $month_long); ?>'],
2757 2757
                     },
2758 2758
                     daysInMonth: [31,28,31,30,31,30,31,31,30,31,30,31],
2759
-                        firstDayOfWeek: <?php echo (int) $params[ 'firstDayOfWeek' ]; ?>,
2759
+                        firstDayOfWeek: <?php echo (int) $params['firstDayOfWeek']; ?>,
2760 2760
                     ordinal: function (nth) {
2761 2761
                         var s = nth % 100;
2762 2762
                         if (s > 3 && s < 21)
@@ -2772,21 +2772,21 @@  discard block
 block discarded – undo
2772 2772
                                 return "th";
2773 2773
                         }
2774 2774
                     },
2775
-                    rangeSeparator: '<?php echo addslashes( $params[ 'rangeSeparator' ] ); ?>',
2776
-                        weekAbbreviation: '<?php echo addslashes( $params[ 'weekAbbreviation' ] ); ?>',
2777
-                    scrollTitle: '<?php echo addslashes( $params[ 'scrollTitle' ] ); ?>',
2778
-                    toggleTitle: '<?php echo addslashes( $params[ 'toggleTitle' ] ); ?>',
2779
-                    amPM: ['<?php echo addslashes( $params[ 'am_upper' ] ); ?>','<?php echo addslashes( $params[ 'pm_upper' ] ); ?>'],
2780
-                    yearAriaLabel: '<?php echo addslashes( $params[ 'year' ] ); ?>',
2781
-                    hourAriaLabel: '<?php echo addslashes( $params[ 'hour' ] ); ?>',
2782
-                    minuteAriaLabel: '<?php echo addslashes( $params[ 'minute' ] ); ?>',
2783
-                    time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?>
2775
+                    rangeSeparator: '<?php echo addslashes($params['rangeSeparator']); ?>',
2776
+                        weekAbbreviation: '<?php echo addslashes($params['weekAbbreviation']); ?>',
2777
+                    scrollTitle: '<?php echo addslashes($params['scrollTitle']); ?>',
2778
+                    toggleTitle: '<?php echo addslashes($params['toggleTitle']); ?>',
2779
+                    amPM: ['<?php echo addslashes($params['am_upper']); ?>','<?php echo addslashes($params['pm_upper']); ?>'],
2780
+                    yearAriaLabel: '<?php echo addslashes($params['year']); ?>',
2781
+                    hourAriaLabel: '<?php echo addslashes($params['hour']); ?>',
2782
+                    minuteAriaLabel: '<?php echo addslashes($params['minute']); ?>',
2783
+                    time_24hr: <?php echo ($params['time_24hr'] ? 'true' : 'false'); ?>
2784 2784
                 }
2785
-				<?php if ( 0 ) { ?></script><?php } ?>
2785
+				<?php if (0) { ?></script><?php } ?>
2786 2786
 			<?php
2787 2787
 			$locale = ob_get_clean();
2788 2788
 
2789
-			return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2789
+			return apply_filters('ayecode_ui_flatpickr_locale', trim($locale));
2790 2790
 		}
2791 2791
 
2792 2792
 		/**
@@ -2798,20 +2798,20 @@  discard block
 block discarded – undo
2798 2798
 		 */
2799 2799
 		public static function select2_params() {
2800 2800
 			$params = array(
2801
-				'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'aui' ),
2802
-				'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'aui' ),
2803
-				'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'aui' ),
2804
-				'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ),
2805
-				'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ),
2806
-				'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'aui' ),
2807
-				'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ),
2808
-				'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ),
2809
-				'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ),
2810
-				'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'aui' ),
2811
-				'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'aui' )
2801
+				'i18n_select_state_text'    => esc_attr__('Select an option&hellip;', 'aui'),
2802
+				'i18n_no_matches'           => _x('No matches found', 'enhanced select', 'aui'),
2803
+				'i18n_ajax_error'           => _x('Loading failed', 'enhanced select', 'aui'),
2804
+				'i18n_input_too_short_1'    => _x('Please enter 1 or more characters', 'enhanced select', 'aui'),
2805
+				'i18n_input_too_short_n'    => _x('Please enter %item% or more characters', 'enhanced select', 'aui'),
2806
+				'i18n_input_too_long_1'     => _x('Please delete 1 character', 'enhanced select', 'aui'),
2807
+				'i18n_input_too_long_n'     => _x('Please delete %item% characters', 'enhanced select', 'aui'),
2808
+				'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'aui'),
2809
+				'i18n_selection_too_long_n' => _x('You can only select %item% items', 'enhanced select', 'aui'),
2810
+				'i18n_load_more'            => _x('Loading more results&hellip;', 'enhanced select', 'aui'),
2811
+				'i18n_searching'            => _x('Searching&hellip;', 'enhanced select', 'aui')
2812 2812
 			);
2813 2813
 
2814
-			return apply_filters( 'ayecode_ui_select2_params', $params );
2814
+			return apply_filters('ayecode_ui_select2_params', $params);
2815 2815
 		}
2816 2816
 
2817 2817
 		/**
@@ -2824,17 +2824,17 @@  discard block
 block discarded – undo
2824 2824
 		public static function select2_locale() {
2825 2825
 			$params = self::select2_params();
2826 2826
 
2827
-			foreach ( (array) $params as $key => $value ) {
2828
-				if ( ! is_scalar( $value ) ) {
2827
+			foreach ((array) $params as $key => $value) {
2828
+				if (!is_scalar($value)) {
2829 2829
 					continue;
2830 2830
 				}
2831 2831
 
2832
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2832
+				$params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
2833 2833
 			}
2834 2834
 
2835
-			$locale = json_encode( $params );
2835
+			$locale = json_encode($params);
2836 2836
 
2837
-			return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2837
+			return apply_filters('ayecode_ui_select2_locale', trim($locale));
2838 2838
 		}
2839 2839
 
2840 2840
 		/**
@@ -2847,35 +2847,35 @@  discard block
 block discarded – undo
2847 2847
 		public static function timeago_locale() {
2848 2848
 			$params = array(
2849 2849
 				'prefix_ago' => '',
2850
-				'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ),
2851
-				'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ',
2850
+				'suffix_ago' => ' ' . _x('ago', 'time ago', 'aui'),
2851
+				'prefix_after' => _x('after', 'time ago', 'aui') . ' ',
2852 2852
 				'suffix_after' => '',
2853
-				'seconds' => _x( 'less than a minute', 'time ago', 'aui' ),
2854
-				'minute' => _x( 'about a minute', 'time ago', 'aui' ),
2855
-				'minutes' => _x( '%d minutes', 'time ago', 'aui' ),
2856
-				'hour' => _x( 'about an hour', 'time ago', 'aui' ),
2857
-				'hours' => _x( 'about %d hours', 'time ago', 'aui' ),
2858
-				'day' => _x( 'a day', 'time ago', 'aui' ),
2859
-				'days' => _x( '%d days', 'time ago', 'aui' ),
2860
-				'month' => _x( 'about a month', 'time ago', 'aui' ),
2861
-				'months' => _x( '%d months', 'time ago', 'aui' ),
2862
-				'year' => _x( 'about a year', 'time ago', 'aui' ),
2863
-				'years' => _x( '%d years', 'time ago', 'aui' ),
2853
+				'seconds' => _x('less than a minute', 'time ago', 'aui'),
2854
+				'minute' => _x('about a minute', 'time ago', 'aui'),
2855
+				'minutes' => _x('%d minutes', 'time ago', 'aui'),
2856
+				'hour' => _x('about an hour', 'time ago', 'aui'),
2857
+				'hours' => _x('about %d hours', 'time ago', 'aui'),
2858
+				'day' => _x('a day', 'time ago', 'aui'),
2859
+				'days' => _x('%d days', 'time ago', 'aui'),
2860
+				'month' => _x('about a month', 'time ago', 'aui'),
2861
+				'months' => _x('%d months', 'time ago', 'aui'),
2862
+				'year' => _x('about a year', 'time ago', 'aui'),
2863
+				'years' => _x('%d years', 'time ago', 'aui'),
2864 2864
 			);
2865 2865
 
2866
-			$params = apply_filters( 'ayecode_ui_timeago_params', $params );
2866
+			$params = apply_filters('ayecode_ui_timeago_params', $params);
2867 2867
 
2868
-			foreach ( (array) $params as $key => $value ) {
2869
-				if ( ! is_scalar( $value ) ) {
2868
+			foreach ((array) $params as $key => $value) {
2869
+				if (!is_scalar($value)) {
2870 2870
 					continue;
2871 2871
 				}
2872 2872
 
2873
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2873
+				$params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
2874 2874
 			}
2875 2875
 
2876
-			$locale = json_encode( $params );
2876
+			$locale = json_encode($params);
2877 2877
 
2878
-			return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2878
+			return apply_filters('ayecode_ui_timeago_locale', trim($locale));
2879 2879
 		}
2880 2880
 
2881 2881
 		/**
@@ -2886,7 +2886,7 @@  discard block
 block discarded – undo
2886 2886
 		 * @return mixed
2887 2887
 		 */
2888 2888
 		public static function minify_js($input) {
2889
-			if(trim($input) === "") return $input;
2889
+			if (trim($input) === "") return $input;
2890 2890
 			return preg_replace(
2891 2891
 				array(
2892 2892
 					// Remove comment(s)
@@ -2918,7 +2918,7 @@  discard block
 block discarded – undo
2918 2918
 		 * @return mixed
2919 2919
 		 */
2920 2920
 		public static function minify_css($input) {
2921
-			if(trim($input) === "") return $input;
2921
+			if (trim($input) === "") return $input;
2922 2922
 			return preg_replace(
2923 2923
 				array(
2924 2924
 					// Remove comment(s)
@@ -3466,12 +3466,12 @@  discard block
 block discarded – undo
3466 3466
                         });
3467 3467
                     }
3468 3468
                 }
3469
-				<?php do_action( 'aui_conditional_fields_js', $this ); ?>
3469
+				<?php do_action('aui_conditional_fields_js', $this); ?>
3470 3470
             </script>
3471 3471
 			<?php
3472 3472
 			$output = ob_get_clean();
3473 3473
 
3474
-			return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
3474
+			return str_replace(array('<script>', '</script>'), '', self::minify_js($output));
3475 3475
 		}
3476 3476
 	}
3477 3477
 
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/wp-super-duper.php 3 patches
Braces   +48 added lines, -50 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
             if(!empty($this->options['nested-block'])){
61 61
                 if(empty($this->options['output_types'])){
62 62
                     $this->options['output_types'] = array('shortcode','block');
63
-                }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
63
+                } elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64 64
                     unset($this->options['output_types'][$key]);
65 65
                 }
66 66
             }
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 				<?php
700 700
 				if(! empty( $insert_shortcode_function )){
701 701
 					echo $insert_shortcode_function;
702
-				}else{
702
+				} else{
703 703
 
704 704
 				/**
705 705
 				 * Function for super duper insert shortcode.
@@ -2132,7 +2132,7 @@  discard block
 block discarded – undo
2132 2132
                     var InnerBlocks = blockEditor.InnerBlocks;
2133 2133
 
2134 2134
 					var term_query_type = '';
2135
-					var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";}else{echo "[]";} ?>;
2135
+					var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";} else{echo "[]";} ?>;
2136 2136
 					const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2137 2137
 					const sort_by_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2138 2138
                     const MediaUpload = wp.blockEditor.MediaUpload;
@@ -2251,8 +2251,7 @@  discard block
 block discarded – undo
2251 2251
 
2252 2252
 								if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2253 2253
 									continue;
2254
-								}
2255
-								elseif ( $args['type'] == 'checkbox' ) {
2254
+								} elseif ( $args['type'] == 'checkbox' ) {
2256 2255
 									$type    = 'boolean';
2257 2256
 									$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2258 2257
 								} elseif ( $args['type'] == 'number' ) {
@@ -2380,7 +2379,7 @@  discard block
 block discarded – undo
2380 2379
                             <?php
2381 2380
                             if(!empty($this->options['block-edit-raw'])) {
2382 2381
                                 echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2383
-                            }else{
2382
+                            } else{
2384 2383
                             ?>
2385 2384
 
2386 2385
 function hasSelectedInnerBlock(props) {
@@ -2421,7 +2420,7 @@  discard block
 block discarded – undo
2421 2420
 
2422 2421
 								// taxonomies
2423 2422
 								if( $value && 'post_type' in prev_attributes[props.clientId] && 'category' in prev_attributes[props.clientId] && run ){
2424
-									wp.apiFetch({path: "<?php if(isset($this->arguments['post_type']['onchange_rest']['path'])){echo $this->arguments['post_type']['onchange_rest']['path'];}else{'/wp/v2/"+$value+"/categories/?per_page=100';} ?>"}).then(terms => {
2423
+									wp.apiFetch({path: "<?php if(isset($this->arguments['post_type']['onchange_rest']['path'])){echo $this->arguments['post_type']['onchange_rest']['path'];} else{'/wp/v2/"+$value+"/categories/?per_page=100';} ?>"}).then(terms => {
2425 2424
 										while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) {
2426 2425
 										taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop();
2427 2426
 									}
@@ -2470,7 +2469,7 @@  discard block
 block discarded – undo
2470 2469
 $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2471 2470
 if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2472 2471
 	echo 'const { deviceType } = "";';
2473
-}else{
2472
+} else{
2474 2473
 ?>
2475 2474
 /** Get device type const. */
2476 2475
 const { deviceType } = wp.data.useSelect != 'undefined' ?  wp.data.useSelect(select => {
@@ -2504,7 +2503,7 @@  discard block
 block discarded – undo
2504 2503
 										'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '',
2505 2504
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
2506 2505
 										echo $post->ID;
2507
-									}else{echo '0';}?>,
2506
+									} else{echo '0';}?>,
2508 2507
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
2509 2508
 									};
2510 2509
 
@@ -2524,7 +2523,7 @@  discard block
 block discarded – undo
2524 2523
 										is_fetching = false;
2525 2524
 										prev_attributes[props.clientId] = props.attributes;
2526 2525
                                              <?php
2527
-                                        }else{
2526
+                                        } else{
2528 2527
                                         ?>
2529 2528
                                        props.setAttributes({content: env});
2530 2529
 										is_fetching = false;
@@ -2703,7 +2702,7 @@  discard block
 block discarded – undo
2703 2702
 //
2704 2703
 
2705 2704
 									}
2706
-									}else {
2705
+									} else {
2707 2706
 									?>
2708 2707
 									el(wp.components.PanelBody, {
2709 2708
 											title: '<?php esc_attr_e( "Settings" ); ?>',
@@ -2729,9 +2728,9 @@  discard block
 block discarded – undo
2729 2728
 								// If the user sets block-output array then build it
2730 2729
 								if ( ! empty( $this->options['block-output'] ) ) {
2731 2730
 								$this->block_element( $this->options['block-output'] );
2732
-							}elseif(!empty($this->options['block-edit-return'])){
2731
+							} elseif(!empty($this->options['block-edit-return'])){
2733 2732
                                    echo $this->options['block-edit-return'];
2734
-							}else{
2733
+							} else{
2735 2734
 								// if no block-output is set then we try and get the shortcode html output via ajax.
2736 2735
 								?>
2737 2736
 								el('div', wp.blockEditor.useBlockProps({
@@ -2835,9 +2834,9 @@  discard block
 block discarded – undo
2835 2834
                                );
2836 2835
                                 <?php
2837 2836
 
2838
-							}elseif(!empty($this->options['block-save-return'])){
2837
+							} elseif(!empty($this->options['block-save-return'])){
2839 2838
                                    echo 'return ' . $this->options['block-save-return'];
2840
-							}elseif(!empty($this->options['nested-block'])){
2839
+							} elseif(!empty($this->options['nested-block'])){
2841 2840
                                 ?>
2842 2841
                               return el(
2843 2842
                                    '',
@@ -2847,13 +2846,13 @@  discard block
 block discarded – undo
2847 2846
                                    el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
2848 2847
                                );
2849 2848
                                 <?php
2850
-							}elseif(!empty( $this->options['block-save-return'] ) ){
2849
+							} elseif(!empty( $this->options['block-save-return'] ) ){
2851 2850
                                 echo "return ". $this->options['block-edit-return'].";";
2852
-							}elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
2851
+							} elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
2853 2852
 							?>
2854 2853
 							return content;
2855 2854
 							<?php
2856
-							}else{
2855
+							} else{
2857 2856
 							?>
2858 2857
 							var block_wrap = 'div';
2859 2858
 							if (attr.hasOwnProperty("block_wrap")) {
@@ -2904,9 +2903,9 @@  discard block
 block discarded – undo
2904 2903
                 $device_type_icon = '';
2905 2904
                 if($device_type=='Desktop'){
2906 2905
                     $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
2907
-                }elseif($device_type=='Tablet'){
2906
+                } elseif($device_type=='Tablet'){
2908 2907
                     $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
2909
-                }elseif($device_type=='Mobile'){
2908
+                } elseif($device_type=='Mobile'){
2910 2909
                     $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
2911 2910
                 }
2912 2911
 				echo $element_require;
@@ -2951,7 +2950,7 @@  discard block
 block discarded – undo
2951 2950
 
2952 2951
 					<?php
2953 2952
 					if(false){?></script><?php }
2954
-				}elseif(!empty($args['row']['close'])){
2953
+				} elseif(!empty($args['row']['close'])){
2955 2954
 					if(false){?><script><?php }?>
2956 2955
 						el(
2957 2956
 							'div',
@@ -2960,7 +2959,7 @@  discard block
 block discarded – undo
2960 2959
 							},
2961 2960
 					<?php
2962 2961
 					if(false){?></script><?php }
2963
-				}else{
2962
+				} else{
2964 2963
 					if(false){?><script><?php }?>
2965 2964
 						el(
2966 2965
 							'div',
@@ -3069,9 +3068,9 @@  discard block
 block discarded – undo
3069 3068
             $device_type_icon = '';
3070 3069
             if($device_type=='Desktop'){
3071 3070
                 $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3072
-            }elseif($device_type=='Tablet'){
3071
+            } elseif($device_type=='Tablet'){
3073 3072
                 $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3074
-            }elseif($device_type=='Mobile'){
3073
+            } elseif($device_type=='Mobile'){
3075 3074
                 $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3076 3075
             }
3077 3076
 
@@ -3105,12 +3104,12 @@  discard block
 block discarded – undo
3105 3104
 				if ( $args['type'] == 'number' ) {
3106 3105
 					$onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3107 3106
 				}
3108
-			}else if ( $args['type'] == 'styleid' ) {
3107
+			} else if ( $args['type'] == 'styleid' ) {
3109 3108
 				$type = 'TextControl';
3110 3109
 				$args['type'] == 'text';
3111 3110
 				// Save numbers as numbers and not strings
3112 3111
 				$value     = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'";
3113
-			}else if ( $args['type'] == 'notice' ) {
3112
+			} else if ( $args['type'] == 'notice' ) {
3114 3113
 
3115 3114
 				$notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3116 3115
 				$notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
@@ -3185,10 +3184,10 @@  discard block
 block discarded – undo
3185 3184
                             $key: value
3186 3185
                         });
3187 3186
                     },";
3188
-			}elseif ( $args['type'] == 'gradient' ) {
3187
+			} elseif ( $args['type'] == 'gradient' ) {
3189 3188
 				$type = 'GradientPicker';
3190 3189
 
3191
-			}elseif ( $args['type'] == 'image' ) {
3190
+			} elseif ( $args['type'] == 'image' ) {
3192 3191
 //                print_r($args);
3193 3192
 
3194 3193
                 $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
@@ -3250,7 +3249,7 @@  discard block
 block discarded – undo
3250 3249
                 $onchange = "";
3251 3250
 
3252 3251
                 //$inside_elements = ",el('div',{},'file upload')";
3253
-			}elseif ( $args['type'] == 'images' ) {
3252
+			} elseif ( $args['type'] == 'images' ) {
3254 3253
 				//                print_r($args);
3255 3254
 
3256 3255
                 $img_preview = "props.attributes.$key && (function() {
@@ -3335,8 +3334,7 @@  discard block
 block discarded – undo
3335 3334
                 $onchange = "";
3336 3335
 
3337 3336
                 //$inside_elements = ",el('div',{},'file upload')";
3338
-			}
3339
-			elseif ( $args['type'] == 'checkbox' ) {
3337
+			} elseif ( $args['type'] == 'checkbox' ) {
3340 3338
 				$type = 'CheckboxControl';
3341 3339
 				$extra .= "checked: props.attributes.$key,";
3342 3340
 				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
@@ -3348,9 +3346,9 @@  discard block
 block discarded – undo
3348 3346
 
3349 3347
 				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3350 3348
 					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3351
-				}elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3349
+				} elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3352 3350
 					$options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3353
-				}else {
3351
+				} else {
3354 3352
 
3355 3353
 					if ( ! empty( $args['options'] ) ) {
3356 3354
 						$options .= "options: [";
@@ -3414,7 +3412,7 @@  discard block
 block discarded – undo
3414 3412
 
3415 3413
 			} elseif ( $args['type'] == 'alignment' ) {
3416 3414
 				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
3417
-			}elseif ( $args['type'] == 'margins' ) {
3415
+			} elseif ( $args['type'] == 'margins' ) {
3418 3416
 
3419 3417
 			} else {
3420 3418
 				return;// if we have not implemented the control then don't break the JS.
@@ -3444,7 +3442,7 @@  discard block
 block discarded – undo
3444 3442
 			label: <?php
3445 3443
 			if(empty($args['title'])){
3446 3444
                 echo "''";
3447
-			}elseif(empty($args['row']) && !empty($args['device_type'])){
3445
+			} elseif(empty($args['row']) && !empty($args['device_type'])){
3448 3446
                 ?>el('label', {
3449 3447
 									className: 'components-base-control__label',
3450 3448
 									style: {width:"100%"}
@@ -3459,7 +3457,7 @@  discard block
 block discarded – undo
3459 3457
 
3460 3458
 							)<?php
3461 3459
 
3462
-			}else{
3460
+			} else{
3463 3461
                  ?>'<?php echo addslashes( $args['title'] ); ?>'<?php
3464 3462
 
3465 3463
 			}
@@ -3467,7 +3465,7 @@  discard block
 block discarded – undo
3467 3465
 			?>,
3468 3466
 			help: <?php if ( isset( $args['desc'] ) ) {
3469 3467
 				echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})";
3470
-			}else{ echo "''"; } ?>,
3468
+			} else{ echo "''"; } ?>,
3471 3469
 			value: <?php echo $value; ?>,
3472 3470
 			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
3473 3471
 				echo "type: '" . addslashes( $args['type'] ) . "',";
@@ -3507,7 +3505,7 @@  discard block
 block discarded – undo
3507 3505
 				foreach ( $custom_attributes as $key => $val ) {
3508 3506
 					if(is_array($val)){
3509 3507
 						$attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
3510
-					}else{
3508
+					} else{
3511 3509
 						$attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
3512 3510
 					}
3513 3511
 				}
@@ -3547,7 +3545,7 @@  discard block
 block discarded – undo
3547 3545
 
3548 3546
                             if($new_args['element']=='InnerBlocks'){
3549 3547
                                 echo "\n el( InnerBlocks, {";
3550
-                            }elseif($new_args['element']=='innerBlocksProps'){
3548
+                            } elseif($new_args['element']=='innerBlocksProps'){
3551 3549
                                 $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
3552 3550
                               //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
3553 3551
 //                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
@@ -3560,11 +3558,11 @@  discard block
 block discarded – undo
3560 3558
                             //    echo '###';
3561 3559
 
3562 3560
                               //  echo '###';
3563
-                            }elseif($new_args['element']=='BlocksProps'){
3561
+                            } elseif($new_args['element']=='BlocksProps'){
3564 3562
 
3565 3563
 								if ( isset($new_args['if_inner_element']) ) {
3566 3564
 									$element = $new_args['if_inner_element'];
3567
-								}else {
3565
+								} else {
3568 3566
 									$element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
3569 3567
 								}
3570 3568
 
@@ -3575,7 +3573,7 @@  discard block
 block discarded – undo
3575 3573
 
3576 3574
                                // echo "} ),";
3577 3575
 
3578
-                            }else{
3576
+                            } else{
3579 3577
                                 echo "\n el( '" . $new_args['element'] . "', {";
3580 3578
                             }
3581 3579
 
@@ -3600,7 +3598,7 @@  discard block
 block discarded – undo
3600 3598
 
3601 3599
 									if ( $new_key === 'content' ) {
3602 3600
 										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
3603
-									}else if ( $new_key === 'if_content' ) {
3601
+									} else if ( $new_key === 'if_content' ) {
3604 3602
 										echo  $this->block_props_replace(  $new_value  );
3605 3603
 									}
3606 3604
 
@@ -3630,7 +3628,7 @@  discard block
 block discarded – undo
3630 3628
 
3631 3629
                             if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
3632 3630
                                 echo "))";// end content
3633
-                            }else{
3631
+                            } else{
3634 3632
                                 echo ")";// end content
3635 3633
                             }
3636 3634
 
@@ -3916,7 +3914,7 @@  discard block
 block discarded – undo
3916 3914
 
3917 3915
 				if(empty($instance['widget_title_tag'])){
3918 3916
 					$output = $args['before_title'] . $title . $args['after_title'];
3919
-				}else{
3917
+				} else{
3920 3918
 					$title_tag = esc_attr( $instance['widget_title_tag'] );
3921 3919
 
3922 3920
 					// classes
@@ -4021,9 +4019,9 @@  discard block
 block discarded – undo
4021 4019
 					<div class='row <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>'>
4022 4020
 					<div class='col pr-2'>
4023 4021
 					<?php
4024
-				}elseif(!empty($args['row']['close'])){
4022
+				} elseif(!empty($args['row']['close'])){
4025 4023
 					echo "<div class='col pl-0'>";
4026
-				}else{
4024
+				} else{
4027 4025
 					echo "<div class='col pl-0 pr-2'>";
4028 4026
 				}
4029 4027
 			}
@@ -4241,11 +4239,11 @@  discard block
 block discarded – undo
4241 4239
 		public function get_widget_icon($icon = 'box-top', $title = ''){
4242 4240
 			if($icon=='box-top'){
4243 4241
 				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4244
-			}elseif($icon=='box-right'){
4242
+			} elseif($icon=='box-right'){
4245 4243
 				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4246
-			}elseif($icon=='box-bottom'){
4244
+			} elseif($icon=='box-bottom'){
4247 4245
 				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4248
-			}elseif($icon=='box-left'){
4246
+			} elseif($icon=='box-left'){
4249 4247
 				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4250 4248
 			}
4251 4249
 		}
Please login to merge, or discard this patch.
Indentation   +1995 added lines, -1995 removed lines patch added patch discarded remove patch
@@ -1,60 +1,60 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 if ( ! class_exists( 'WP_Super_Duper' ) ) {
7 7
 
8
-	define( 'SUPER_DUPER_VER', '1.1.10' );
9
-
10
-	/**
11
-	 * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
12
-	 *
13
-	 * Should not be called direct but extended instead.
14
-	 *
15
-	 * Class WP_Super_Duper
16
-	 * @since 1.0.16 change log moved to file change-log.txt - CHANGED
17
-	 * @ver 1.1.1
18
-	 */
19
-	class WP_Super_Duper extends WP_Widget {
20
-
21
-		public $version = SUPER_DUPER_VER;
22
-		public $font_awesome_icon_version = "5.11.2";
23
-		public $block_code;
24
-		public $options;
25
-		public $base_id;
26
-		public $settings_hash;
27
-		public $arguments = array();
28
-		public $instance = array();
29
-		private $class_name;
30
-
31
-		/**
32
-		 * The relative url to the current folder.
33
-		 *
34
-		 * @var string
35
-		 */
36
-		public $url = '';
37
-
38
-		/**
39
-		 * Take the array options and use them to build.
40
-		 */
41
-		public function __construct( $options ) {
42
-			global $sd_widgets;
43
-
44
-			$sd_widgets[ $options['base_id'] ] = array(
45
-				'name'       => $options['name'],
46
-				'class_name' => $options['class_name'],
47
-				'output_types' => !empty($options['output_types']) ? $options['output_types'] : array()
48
-			);
49
-			$this->base_id                     = $options['base_id'];
50
-			// lets filter the options before we do anything
51
-			$options       = apply_filters( "wp_super_duper_options", $options );
52
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
-			$options       = $this->add_name_from_key( $options );
54
-			$this->options = $options;
55
-
56
-			$this->base_id   = $options['base_id'];
57
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
8
+    define( 'SUPER_DUPER_VER', '1.1.10' );
9
+
10
+    /**
11
+     * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
12
+     *
13
+     * Should not be called direct but extended instead.
14
+     *
15
+     * Class WP_Super_Duper
16
+     * @since 1.0.16 change log moved to file change-log.txt - CHANGED
17
+     * @ver 1.1.1
18
+     */
19
+    class WP_Super_Duper extends WP_Widget {
20
+
21
+        public $version = SUPER_DUPER_VER;
22
+        public $font_awesome_icon_version = "5.11.2";
23
+        public $block_code;
24
+        public $options;
25
+        public $base_id;
26
+        public $settings_hash;
27
+        public $arguments = array();
28
+        public $instance = array();
29
+        private $class_name;
30
+
31
+        /**
32
+         * The relative url to the current folder.
33
+         *
34
+         * @var string
35
+         */
36
+        public $url = '';
37
+
38
+        /**
39
+         * Take the array options and use them to build.
40
+         */
41
+        public function __construct( $options ) {
42
+            global $sd_widgets;
43
+
44
+            $sd_widgets[ $options['base_id'] ] = array(
45
+                'name'       => $options['name'],
46
+                'class_name' => $options['class_name'],
47
+                'output_types' => !empty($options['output_types']) ? $options['output_types'] : array()
48
+            );
49
+            $this->base_id                     = $options['base_id'];
50
+            // lets filter the options before we do anything
51
+            $options       = apply_filters( "wp_super_duper_options", $options );
52
+            $options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
+            $options       = $this->add_name_from_key( $options );
54
+            $this->options = $options;
55
+
56
+            $this->base_id   = $options['base_id'];
57
+            $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
58 58
 
59 59
             // nested blocks can't work as a widget
60 60
             if(!empty($this->options['nested-block'])){
@@ -65,234 +65,234 @@  discard block
 block discarded – undo
65 65
                 }
66 66
             }
67 67
 
68
-			// init parent
69
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
68
+            // init parent
69
+            if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
70 70
                 parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
71
-			}
71
+            }
72 72
 
73 73
 
74
-			if ( isset( $options['class_name'] ) ) {
75
-				// register widget
76
-				$this->class_name = $options['class_name'];
74
+            if ( isset( $options['class_name'] ) ) {
75
+                // register widget
76
+                $this->class_name = $options['class_name'];
77 77
 
78
-				// register shortcode, this needs to be done even for blocks and widgets
78
+                // register shortcode, this needs to be done even for blocks and widgets
79 79
                 $this->register_shortcode();
80 80
 
81 81
 
82
-				// Fusion Builder (avada) support
83
-				if ( function_exists( 'fusion_builder_map' ) ) {
84
-					add_action( 'init', array( $this, 'register_fusion_element' ) );
85
-				}
82
+                // Fusion Builder (avada) support
83
+                if ( function_exists( 'fusion_builder_map' ) ) {
84
+                    add_action( 'init', array( $this, 'register_fusion_element' ) );
85
+                }
86 86
 
87
-				// register block
88
-				if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){
89
-				    add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
87
+                // register block
88
+                if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){
89
+                    add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
90 90
                 }
91
-			}
91
+            }
92 92
 
93
-			// add the CSS and JS we need ONCE
94
-			global $sd_widget_scripts;
93
+            // add the CSS and JS we need ONCE
94
+            global $sd_widget_scripts;
95 95
 
96
-			if ( ! $sd_widget_scripts ) {
97
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
98
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
99
-				wp_add_inline_style( 'widgets', $this->widget_css() );
96
+            if ( ! $sd_widget_scripts ) {
97
+                wp_add_inline_script( 'admin-widgets', $this->widget_js() );
98
+                wp_add_inline_script( 'customize-controls', $this->widget_js() );
99
+                wp_add_inline_style( 'widgets', $this->widget_css() );
100 100
 
101
-				// maybe add elementor editor styles
102
-				add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
101
+                // maybe add elementor editor styles
102
+                add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
103 103
 
104
-				$sd_widget_scripts = true;
104
+                $sd_widget_scripts = true;
105 105
 
106
-				// add shortcode insert button once
107
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
108
-				// generatepress theme sections compatibility
109
-				if ( function_exists( 'generate_sections_sections_metabox' ) ) {
110
-					add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
111
-				}
112
-				/* Load script on Divi theme builder page */
113
-				if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) {
114
-					add_thickbox();
115
-					add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) );
116
-				}
106
+                // add shortcode insert button once
107
+                add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
108
+                // generatepress theme sections compatibility
109
+                if ( function_exists( 'generate_sections_sections_metabox' ) ) {
110
+                    add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
111
+                }
112
+                /* Load script on Divi theme builder page */
113
+                if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) {
114
+                    add_thickbox();
115
+                    add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) );
116
+                }
117 117
 
118
-				if ( $this->is_preview() ) {
119
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
120
-					// this makes the insert button work for elementor
121
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
122
-						$this,
123
-						'shortcode_insert_button_script'
124
-					) ); // for elementor
125
-				}
126
-				// this makes the insert button work for cornerstone
127
-				add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
118
+                if ( $this->is_preview() ) {
119
+                    add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
120
+                    // this makes the insert button work for elementor
121
+                    add_action( 'elementor/editor/after_enqueue_scripts', array(
122
+                        $this,
123
+                        'shortcode_insert_button_script'
124
+                    ) ); // for elementor
125
+                }
126
+                // this makes the insert button work for cornerstone
127
+                add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
128 128
 
129
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
130
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
129
+                add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
130
+                add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
131 131
 
132
-				// add generator text to admin head
133
-				add_action( 'admin_head', array( $this, 'generator' ) );
134
-			}
132
+                // add generator text to admin head
133
+                add_action( 'admin_head', array( $this, 'generator' ) );
134
+            }
135 135
 
136
-			do_action( 'wp_super_duper_widget_init', $options, $this );
137
-		}
136
+            do_action( 'wp_super_duper_widget_init', $options, $this );
137
+        }
138 138
 
139 139
         /**
140 140
          * The register widget function
141 141
          * @return void
142 142
          */
143
-		public function _register() {
143
+        public function _register() {
144 144
             if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
145 145
                 parent::_register();
146
-			}
147
-		}
146
+            }
147
+        }
148 148
 
149
-		/**
150
-		 * Add our widget CSS to elementor editor.
151
-		 */
152
-		public function elementor_editor_styles() {
153
-			wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
154
-		}
149
+        /**
150
+         * Add our widget CSS to elementor editor.
151
+         */
152
+        public function elementor_editor_styles() {
153
+            wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
154
+        }
155 155
 
156
-		public function register_fusion_element() {
156
+        public function register_fusion_element() {
157 157
 
158
-			$options = $this->options;
158
+            $options = $this->options;
159 159
 
160
-			if ( $this->base_id ) {
160
+            if ( $this->base_id ) {
161 161
 
162
-				$params = $this->get_fusion_params();
162
+                $params = $this->get_fusion_params();
163 163
 
164
-				$args = array(
165
-					'name'            => $options['name'],
166
-					'shortcode'       => $this->base_id,
167
-					'icon'            => $options['block-icon'] ? $options['block-icon'] : 'far fa-square',
168
-					'allow_generator' => true,
169
-				);
164
+                $args = array(
165
+                    'name'            => $options['name'],
166
+                    'shortcode'       => $this->base_id,
167
+                    'icon'            => $options['block-icon'] ? $options['block-icon'] : 'far fa-square',
168
+                    'allow_generator' => true,
169
+                );
170 170
 
171
-				if ( ! empty( $params ) ) {
172
-					$args['params'] = $params;
173
-				}
171
+                if ( ! empty( $params ) ) {
172
+                    $args['params'] = $params;
173
+                }
174 174
 
175
-				fusion_builder_map( $args );
176
-			}
175
+                fusion_builder_map( $args );
176
+            }
177 177
 
178
-		}
178
+        }
179 179
 
180
-		public function get_fusion_params() {
181
-			$params    = array();
182
-			$arguments = $this->get_arguments();
183
-
184
-			if ( ! empty( $arguments ) ) {
185
-				foreach ( $arguments as $key => $val ) {
186
-					$param = array();
187
-					// type
188
-					$param['type'] = str_replace(
189
-						array(
190
-							"text",
191
-							"number",
192
-							"email",
193
-							"color",
194
-							"checkbox"
195
-						),
196
-						array(
197
-							"textfield",
198
-							"textfield",
199
-							"textfield",
200
-							"colorpicker",
201
-							"select",
202
-
203
-						),
204
-						$val['type'] );
205
-
206
-					// multiselect
207
-					if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
208
-						$param['type']     = 'multiple_select';
209
-						$param['multiple'] = true;
210
-					}
180
+        public function get_fusion_params() {
181
+            $params    = array();
182
+            $arguments = $this->get_arguments();
183
+
184
+            if ( ! empty( $arguments ) ) {
185
+                foreach ( $arguments as $key => $val ) {
186
+                    $param = array();
187
+                    // type
188
+                    $param['type'] = str_replace(
189
+                        array(
190
+                            "text",
191
+                            "number",
192
+                            "email",
193
+                            "color",
194
+                            "checkbox"
195
+                        ),
196
+                        array(
197
+                            "textfield",
198
+                            "textfield",
199
+                            "textfield",
200
+                            "colorpicker",
201
+                            "select",
211 202
 
212
-					// heading
213
-					$param['heading'] = $val['title'];
203
+                        ),
204
+                        $val['type'] );
214 205
 
215
-					// description
216
-					$param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
206
+                    // multiselect
207
+                    if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
208
+                        $param['type']     = 'multiple_select';
209
+                        $param['multiple'] = true;
210
+                    }
217 211
 
218
-					// param_name
219
-					$param['param_name'] = $key;
212
+                    // heading
213
+                    $param['heading'] = $val['title'];
220 214
 
221
-					// Default
222
-					$param['default'] = isset( $val['default'] ) ? $val['default'] : '';
215
+                    // description
216
+                    $param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
223 217
 
224
-					// Group
225
-					if ( isset( $val['group'] ) ) {
226
-						$param['group'] = $val['group'];
227
-					}
218
+                    // param_name
219
+                    $param['param_name'] = $key;
228 220
 
229
-					// value
230
-					if ( $val['type'] == 'checkbox' ) {
231
-						if ( isset( $val['default'] ) && $val['default'] == '0' ) {
232
-							unset( $param['default'] );
233
-						}
234
-						$param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) );
235
-					} elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
236
-						$param['value'] = isset( $val['options'] ) ? $val['options'] : array();
237
-					} else {
238
-						$param['value'] = isset( $val['default'] ) ? $val['default'] : '';
239
-					}
221
+                    // Default
222
+                    $param['default'] = isset( $val['default'] ) ? $val['default'] : '';
240 223
 
241
-					// setup the param
242
-					$params[] = $param;
224
+                    // Group
225
+                    if ( isset( $val['group'] ) ) {
226
+                        $param['group'] = $val['group'];
227
+                    }
243 228
 
244
-				}
245
-			}
229
+                    // value
230
+                    if ( $val['type'] == 'checkbox' ) {
231
+                        if ( isset( $val['default'] ) && $val['default'] == '0' ) {
232
+                            unset( $param['default'] );
233
+                        }
234
+                        $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) );
235
+                    } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
236
+                        $param['value'] = isset( $val['options'] ) ? $val['options'] : array();
237
+                    } else {
238
+                        $param['value'] = isset( $val['default'] ) ? $val['default'] : '';
239
+                    }
246 240
 
241
+                    // setup the param
242
+                    $params[] = $param;
247 243
 
248
-			return $params;
249
-		}
244
+                }
245
+            }
250 246
 
251
-		/**
252
-		 * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
253
-		 */
254
-		public static function maybe_cornerstone_builder() {
255
-			if ( did_action( 'cornerstone_before_boot_app' ) ) {
256
-				self::shortcode_insert_button_script();
257
-			}
258
-		}
259 247
 
260
-		/**
261
-		 * A function to ge the shortcode builder picker html.
262
-		 *
263
-		 * @param string $editor_id
264
-		 *
265
-		 * @return string
266
-		 */
267
-		public static function get_picker( $editor_id = '' ) {
268
-
269
-			ob_start();
270
-			if ( isset( $_POST['editor_id'] ) ) {
271
-				$editor_id = esc_attr( $_POST['editor_id'] );
272
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
273
-				$editor_id = 'main_content_content_vb_tiny_mce';
274
-			}
248
+            return $params;
249
+        }
250
+
251
+        /**
252
+         * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
253
+         */
254
+        public static function maybe_cornerstone_builder() {
255
+            if ( did_action( 'cornerstone_before_boot_app' ) ) {
256
+                self::shortcode_insert_button_script();
257
+            }
258
+        }
259
+
260
+        /**
261
+         * A function to ge the shortcode builder picker html.
262
+         *
263
+         * @param string $editor_id
264
+         *
265
+         * @return string
266
+         */
267
+        public static function get_picker( $editor_id = '' ) {
268
+
269
+            ob_start();
270
+            if ( isset( $_POST['editor_id'] ) ) {
271
+                $editor_id = esc_attr( $_POST['editor_id'] );
272
+            } elseif ( isset( $_REQUEST['et_fb'] ) ) {
273
+                $editor_id = 'main_content_content_vb_tiny_mce';
274
+            }
275 275
 
276
-			global $sd_widgets;
276
+            global $sd_widgets;
277 277
 
278 278
 //			print_r($sd_widgets);exit;
279
-			?>
279
+            ?>
280 280
 
281 281
 			<div class="sd-shortcode-left-wrap">
282 282
 				<?php
283
-				ksort( $sd_widgets );
284
-				//				print_r($sd_widgets);exit;
285
-				if ( ! empty( $sd_widgets ) ) {
286
-					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
287
-					echo "<option>" . __( 'Select shortcode' ) . "</option>";
288
-					foreach ( $sd_widgets as $shortcode => $class ) {
289
-						if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; }
290
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
291
-					}
292
-					echo "</select>";
283
+                ksort( $sd_widgets );
284
+                //				print_r($sd_widgets);exit;
285
+                if ( ! empty( $sd_widgets ) ) {
286
+                    echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
287
+                    echo "<option>" . __( 'Select shortcode' ) . "</option>";
288
+                    foreach ( $sd_widgets as $shortcode => $class ) {
289
+                        if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; }
290
+                        echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
291
+                    }
292
+                    echo "</select>";
293 293
 
294
-				}
295
-				?>
294
+                }
295
+                ?>
296 296
 				<div class="sd-shortcode-settings"></div>
297 297
 
298 298
 			</div>
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 					<?php if ( $editor_id != '' ) { ?>
304 304
 						<button class="button sd-insert-shortcode-button"
305 305
 						        onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
306
-							        echo "'" . $editor_id . "'";
307
-						        } ?>)"><?php _e( 'Insert shortcode' ); ?></button>
306
+                                    echo "'" . $editor_id . "'";
307
+                                } ?>)"><?php _e( 'Insert shortcode' ); ?></button>
308 308
 					<?php } ?>
309 309
 					<button class="button"
310 310
 					        onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
@@ -312,135 +312,135 @@  discard block
 block discarded – undo
312 312
 			</div>
313 313
 			<?php
314 314
 
315
-			$html = ob_get_clean();
315
+            $html = ob_get_clean();
316 316
 
317
-			if ( wp_doing_ajax() ) {
318
-				echo $html;
319
-				$should_die = true;
317
+            if ( wp_doing_ajax() ) {
318
+                echo $html;
319
+                $should_die = true;
320 320
 
321
-				// some builder get the editor via ajax so we should not die on those occasions
322
-				$dont_die = array(
323
-					'parent_tag',// WP Bakery
324
-					'avia_request' // enfold
325
-				);
321
+                // some builder get the editor via ajax so we should not die on those occasions
322
+                $dont_die = array(
323
+                    'parent_tag',// WP Bakery
324
+                    'avia_request' // enfold
325
+                );
326 326
 
327
-				foreach ( $dont_die as $request ) {
328
-					if ( isset( $_REQUEST[ $request ] ) ) {
329
-						$should_die = false;
330
-					}
331
-				}
327
+                foreach ( $dont_die as $request ) {
328
+                    if ( isset( $_REQUEST[ $request ] ) ) {
329
+                        $should_die = false;
330
+                    }
331
+                }
332 332
 
333
-				if ( $should_die ) {
334
-					wp_die();
335
-				}
333
+                if ( $should_die ) {
334
+                    wp_die();
335
+                }
336 336
 
337
-			} else {
338
-				return $html;
339
-			}
337
+            } else {
338
+                return $html;
339
+            }
340 340
 
341
-			return '';
341
+            return '';
342 342
 
343
-		}
343
+        }
344 344
 
345
-		/**
346
-		 * Output the version in the admin header.
347
-		 */
348
-		public function generator() {
349
-			echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />';
350
-		}
345
+        /**
346
+         * Output the version in the admin header.
347
+         */
348
+        public function generator() {
349
+            echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />';
350
+        }
351 351
 
352
-		/**
353
-		 * Get widget settings.
354
-		 *
355
-		 * @since 1.0.0
356
-		 */
357
-		public static function get_widget_settings() {
358
-			global $sd_widgets;
359
-
360
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
361
-			if ( ! $shortcode ) {
362
-				wp_die();
363
-			}
364
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
365
-			if ( ! $widget_args ) {
366
-				wp_die();
367
-			}
368
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
369
-			if ( ! $class_name ) {
370
-				wp_die();
371
-			}
352
+        /**
353
+         * Get widget settings.
354
+         *
355
+         * @since 1.0.0
356
+         */
357
+        public static function get_widget_settings() {
358
+            global $sd_widgets;
359
+
360
+            $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
361
+            if ( ! $shortcode ) {
362
+                wp_die();
363
+            }
364
+            $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
365
+            if ( ! $widget_args ) {
366
+                wp_die();
367
+            }
368
+            $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
369
+            if ( ! $class_name ) {
370
+                wp_die();
371
+            }
372 372
 
373
-			// invoke an instance method
374
-			$widget = new $class_name;
373
+            // invoke an instance method
374
+            $widget = new $class_name;
375 375
 
376
-			ob_start();
377
-			$widget->form( array() );
378
-			$form = ob_get_clean();
379
-			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
380
-			echo "<style>" . $widget->widget_css() . "</style>";
381
-			echo "<script>" . $widget->widget_js() . "</script>";
382
-			?>
376
+            ob_start();
377
+            $widget->form( array() );
378
+            $form = ob_get_clean();
379
+            echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
380
+            echo "<style>" . $widget->widget_css() . "</style>";
381
+            echo "<script>" . $widget->widget_js() . "</script>";
382
+            ?>
383 383
 			<?php
384
-			wp_die();
385
-		}
384
+            wp_die();
385
+        }
386 386
 
387
-		/**
388
-		 * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
389
-		 *
390
-		 * @param string $editor_id Optional. Shortcode editor id. Default null.
391
-		 * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null.
392
-		 *
393
-		 *@since 1.0.0
394
-		 *
395
-		 */
396
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
397
-			global $sd_widgets, $shortcode_insert_button_once;
398
-			if ( $shortcode_insert_button_once ) {
399
-				return;
400
-			}
401
-			add_thickbox();
387
+        /**
388
+         * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
389
+         *
390
+         * @param string $editor_id Optional. Shortcode editor id. Default null.
391
+         * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null.
392
+         *
393
+         *@since 1.0.0
394
+         *
395
+         */
396
+        public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
397
+            global $sd_widgets, $shortcode_insert_button_once;
398
+            if ( $shortcode_insert_button_once ) {
399
+                return;
400
+            }
401
+            add_thickbox();
402 402
 
403 403
 
404
-			/**
405
-			 * Cornerstone makes us play dirty tricks :/
406
-			 * 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.
407
-			 */
408
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
409
-				echo '<span id="insert-media-button">';
410
-			}
404
+            /**
405
+             * Cornerstone makes us play dirty tricks :/
406
+             * 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.
407
+             */
408
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
409
+                echo '<span id="insert-media-button">';
410
+            }
411 411
 
412
-			echo self::shortcode_button( 'this', 'true' );
412
+            echo self::shortcode_button( 'this', 'true' );
413 413
 
414
-			// see opening note
415
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
416
-				echo '</span>'; // end #insert-media-button
417
-			}
414
+            // see opening note
415
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
416
+                echo '</span>'; // end #insert-media-button
417
+            }
418 418
 
419
-			// Add separate script for generatepress theme sections
420
-			if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
421
-			} else {
422
-				self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
423
-			}
419
+            // Add separate script for generatepress theme sections
420
+            if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
421
+            } else {
422
+                self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
423
+            }
424 424
 
425
-			$shortcode_insert_button_once = true;
426
-		}
425
+            $shortcode_insert_button_once = true;
426
+        }
427 427
 
428
-		/**
429
-		 * Gets the shortcode insert button html.
430
-		 *
431
-		 * @param string $id
432
-		 * @param string $search_for_id
433
-		 *
434
-		 * @return mixed
435
-		 */
436
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
437
-			ob_start();
438
-			?>
428
+        /**
429
+         * Gets the shortcode insert button html.
430
+         *
431
+         * @param string $id
432
+         * @param string $search_for_id
433
+         *
434
+         * @return mixed
435
+         */
436
+        public static function shortcode_button( $id = '', $search_for_id = '' ) {
437
+            ob_start();
438
+            ?>
439 439
 			<span class="sd-lable-shortcode-inserter">
440 440
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
441
-				if ( $search_for_id ) {
442
-					echo "," . $search_for_id;
443
-				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
441
+                if ( $search_for_id ) {
442
+                    echo "," . $search_for_id;
443
+                } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
444 444
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
445 445
 					<span style="vertical-align: middle;line-height: 18px;font-size: 20px;"
446 446
 					      class="dashicons dashicons-screenoptions"></span>
@@ -451,21 +451,21 @@  discard block
 block discarded – undo
451 451
 			</span>
452 452
 
453 453
 			<?php
454
-			$html = ob_get_clean();
454
+            $html = ob_get_clean();
455 455
 
456
-			// remove line breaks so we can use it in js
457
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
458
-		}
456
+            // remove line breaks so we can use it in js
457
+            return preg_replace( "/\r|\n/", "", trim( $html ) );
458
+        }
459 459
 
460
-		/**
461
-		 * Makes SD work with the siteOrigin page builder.
462
-		 *
463
-		 * @return mixed
464
-		 *@since 1.0.6
465
-		 */
466
-		public static function siteorigin_js() {
467
-			ob_start();
468
-			?>
460
+        /**
461
+         * Makes SD work with the siteOrigin page builder.
462
+         *
463
+         * @return mixed
464
+         *@since 1.0.6
465
+         */
466
+        public static function siteorigin_js() {
467
+            ob_start();
468
+            ?>
469 469
 			<script>
470 470
 				/**
471 471
 				 * Check a form to see what items should be shown or hidden.
@@ -541,29 +541,29 @@  discard block
 block discarded – undo
541 541
 				});
542 542
 			</script>
543 543
 			<?php
544
-			$output = ob_get_clean();
544
+            $output = ob_get_clean();
545 545
 
546
-			/*
546
+            /*
547 547
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
548 548
 			 */
549 549
 
550
-			return str_replace( array(
551
-				'<script>',
552
-				'</script>'
553
-			), '', $output );
554
-		}
550
+            return str_replace( array(
551
+                '<script>',
552
+                '</script>'
553
+            ), '', $output );
554
+        }
555 555
 
556
-		/**
557
-		 * Output the JS and CSS for the shortcode insert button.
558
-		 *
559
-		 * @param string $editor_id
560
-		 * @param string $insert_shortcode_function
561
-		 *
562
-		 *@since 1.0.6
563
-		 *
564
-		 */
565
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
566
-			?>
556
+        /**
557
+         * Output the JS and CSS for the shortcode insert button.
558
+         *
559
+         * @param string $editor_id
560
+         * @param string $insert_shortcode_function
561
+         *
562
+         *@since 1.0.6
563
+         *
564
+         */
565
+        public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
566
+            ?>
567 567
 			<style>
568 568
 				.sd-shortcode-left-wrap {
569 569
 					float: left;
@@ -691,35 +691,35 @@  discard block
 block discarded – undo
691 691
 				<?php } ?>
692 692
 			</style>
693 693
 			<?php
694
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
695
-				echo "<script>" . self::siteorigin_js() . "</script>";
696
-			}
697
-			?>
694
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
695
+                echo "<script>" . self::siteorigin_js() . "</script>";
696
+            }
697
+            ?>
698 698
 			<script>
699 699
 				<?php
700
-				if(! empty( $insert_shortcode_function )){
701
-					echo $insert_shortcode_function;
702
-				}else{
703
-
704
-				/**
705
-				 * Function for super duper insert shortcode.
706
-				 *
707
-				 * @since 1.0.0
708
-				 */
709
-				?>
700
+                if(! empty( $insert_shortcode_function )){
701
+                    echo $insert_shortcode_function;
702
+                }else{
703
+
704
+                /**
705
+                 * Function for super duper insert shortcode.
706
+                 *
707
+                 * @since 1.0.0
708
+                 */
709
+                ?>
710 710
 				function sd_insert_shortcode($editor_id) {
711 711
 					$shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val();
712 712
 					if ($shortcode) {
713 713
 						if (!$editor_id) {
714 714
 							<?php
715
-							if ( isset( $_REQUEST['et_fb'] ) ) {
716
-								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
717
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
718
-								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
719
-							} else {
720
-								echo '$editor_id = "#wp-content-editor-container textarea";';
721
-							}
722
-							?>
715
+                            if ( isset( $_REQUEST['et_fb'] ) ) {
716
+                                echo '$editor_id = "#main_content_content_vb_tiny_mce";';
717
+                            } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
718
+                                echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
719
+                            } else {
720
+                                echo '$editor_id = "#wp-content-editor-container textarea";';
721
+                            }
722
+                            ?>
723 723
 						} else {
724 724
 							$editor_id = '#' + $editor_id;
725 725
 						}
@@ -1046,18 +1046,18 @@  discard block
 block discarded – undo
1046 1046
 
1047 1047
 			</script>
1048 1048
 			<?php
1049
-		}
1049
+        }
1050 1050
 
1051
-		/**
1052
-		 * Gets some CSS for the widgets screen.
1053
-		 *
1054
-		 * @param bool $advanced If we should include advanced CSS.
1055
-		 *
1056
-		 * @return mixed
1057
-		 */
1058
-		public function widget_css( $advanced = true ) {
1059
-			ob_start();
1060
-			?>
1051
+        /**
1052
+         * Gets some CSS for the widgets screen.
1053
+         *
1054
+         * @param bool $advanced If we should include advanced CSS.
1055
+         *
1056
+         * @return mixed
1057
+         */
1058
+        public function widget_css( $advanced = true ) {
1059
+            ob_start();
1060
+            ?>
1061 1061
 			<style>
1062 1062
 				<?php if( $advanced ){ ?>
1063 1063
 				.sd-advanced-setting {
@@ -1095,26 +1095,26 @@  discard block
 block discarded – undo
1095 1095
 				}
1096 1096
 			</style>
1097 1097
 			<?php
1098
-			$output = ob_get_clean();
1098
+            $output = ob_get_clean();
1099 1099
 
1100
-			/*
1100
+            /*
1101 1101
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1102 1102
 			 */
1103 1103
 
1104
-			return str_replace( array(
1105
-				'<style>',
1106
-				'</style>'
1107
-			), '', $output );
1108
-		}
1104
+            return str_replace( array(
1105
+                '<style>',
1106
+                '</style>'
1107
+            ), '', $output );
1108
+        }
1109 1109
 
1110
-		/**
1111
-		 * Gets some JS for the widgets screen.
1112
-		 *
1113
-		 * @return mixed
1114
-		 */
1115
-		public function widget_js() {
1116
-			ob_start();
1117
-			?>
1110
+        /**
1111
+         * Gets some JS for the widgets screen.
1112
+         *
1113
+         * @return mixed
1114
+         */
1115
+        public function widget_js() {
1116
+            ob_start();
1117
+            ?>
1118 1118
 			<script>
1119 1119
 
1120 1120
 				/**
@@ -1265,471 +1265,471 @@  discard block
 block discarded – undo
1265 1265
 				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1266 1266
 			</script>
1267 1267
 			<?php
1268
-			$output = ob_get_clean();
1268
+            $output = ob_get_clean();
1269 1269
 
1270
-			/*
1270
+            /*
1271 1271
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1272 1272
 			 */
1273 1273
 
1274
-			return str_replace( array(
1275
-				'<script>',
1276
-				'</script>'
1277
-			), '', $output );
1278
-		}
1274
+            return str_replace( array(
1275
+                '<script>',
1276
+                '</script>'
1277
+            ), '', $output );
1278
+        }
1279 1279
 
1280 1280
 
1281
-		/**
1282
-		 * Set the name from the argument key.
1283
-		 *
1284
-		 * @param $options
1285
-		 *
1286
-		 * @return mixed
1287
-		 */
1288
-		private function add_name_from_key( $options, $arguments = false ) {
1289
-			if ( ! empty( $options['arguments'] ) ) {
1290
-				foreach ( $options['arguments'] as $key => $val ) {
1291
-					$options['arguments'][ $key ]['name'] = $key;
1292
-				}
1293
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1294
-				foreach ( $options as $key => $val ) {
1295
-					$options[ $key ]['name'] = $key;
1296
-				}
1297
-			}
1281
+        /**
1282
+         * Set the name from the argument key.
1283
+         *
1284
+         * @param $options
1285
+         *
1286
+         * @return mixed
1287
+         */
1288
+        private function add_name_from_key( $options, $arguments = false ) {
1289
+            if ( ! empty( $options['arguments'] ) ) {
1290
+                foreach ( $options['arguments'] as $key => $val ) {
1291
+                    $options['arguments'][ $key ]['name'] = $key;
1292
+                }
1293
+            } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1294
+                foreach ( $options as $key => $val ) {
1295
+                    $options[ $key ]['name'] = $key;
1296
+                }
1297
+            }
1298 1298
 
1299
-			return $options;
1300
-		}
1299
+            return $options;
1300
+        }
1301 1301
 
1302
-		/**
1303
-		 * Register the parent shortcode.
1304
-		 *
1305
-		 * @since 1.0.0
1306
-		 */
1307
-		public function register_shortcode() {
1308
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1309
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) );
1310
-		}
1302
+        /**
1303
+         * Register the parent shortcode.
1304
+         *
1305
+         * @since 1.0.0
1306
+         */
1307
+        public function register_shortcode() {
1308
+            add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1309
+            add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) );
1310
+        }
1311 1311
 
1312
-		/**
1313
-		 * Render the shortcode via ajax so we can return it to Gutenberg.
1314
-		 *
1315
-		 * @since 1.0.0
1316
-		 */
1317
-		public function render_shortcode() {
1318
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1319
-			if ( ! current_user_can( 'manage_options' ) ) {
1320
-				wp_die();
1321
-			}
1312
+        /**
1313
+         * Render the shortcode via ajax so we can return it to Gutenberg.
1314
+         *
1315
+         * @since 1.0.0
1316
+         */
1317
+        public function render_shortcode() {
1318
+            check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1319
+            if ( ! current_user_can( 'manage_options' ) ) {
1320
+                wp_die();
1321
+            }
1322 1322
 
1323
-			// we might need the $post value here so lets set it.
1324
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1325
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1326
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1327
-					global $post;
1328
-					$post = $post_obj;
1329
-				}
1330
-			}
1323
+            // we might need the $post value here so lets set it.
1324
+            if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1325
+                $post_obj = get_post( absint( $_POST['post_id'] ) );
1326
+                if ( ! empty( $post_obj ) && empty( $post ) ) {
1327
+                    global $post;
1328
+                    $post = $post_obj;
1329
+                }
1330
+            }
1331 1331
 
1332
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1333
-				$is_preview = $this->is_preview();
1334
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1335
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1336
-				$attributes       = '';
1337
-				if ( ! empty( $attributes_array ) ) {
1338
-					foreach ( $attributes_array as $key => $value ) {
1339
-						if ( is_array( $value ) ) {
1340
-							$value = implode( ",", $value );
1341
-						}
1332
+            if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1333
+                $is_preview = $this->is_preview();
1334
+                $shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1335
+                $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1336
+                $attributes       = '';
1337
+                if ( ! empty( $attributes_array ) ) {
1338
+                    foreach ( $attributes_array as $key => $value ) {
1339
+                        if ( is_array( $value ) ) {
1340
+                            $value = implode( ",", $value );
1341
+                        }
1342 1342
 
1343
-						if ( ! empty( $value ) ) {
1344
-							$value = wp_unslash( $value );
1343
+                        if ( ! empty( $value ) ) {
1344
+                            $value = wp_unslash( $value );
1345 1345
 
1346
-							// Encode [ and ].
1347
-							if ( $is_preview ) {
1348
-								$value = $this->encode_shortcodes( $value );
1349
-							}
1350
-						}
1351
-						$attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . esc_attr( $value ) . "' ";
1352
-					}
1353
-				}
1346
+                            // Encode [ and ].
1347
+                            if ( $is_preview ) {
1348
+                                $value = $this->encode_shortcodes( $value );
1349
+                            }
1350
+                        }
1351
+                        $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . esc_attr( $value ) . "' ";
1352
+                    }
1353
+                }
1354 1354
 
1355
-				$shortcode = "[" . $shortcode_name . " " . $attributes . "]";
1355
+                $shortcode = "[" . $shortcode_name . " " . $attributes . "]";
1356 1356
 
1357
-				$content = do_shortcode( $shortcode );
1357
+                $content = do_shortcode( $shortcode );
1358 1358
 
1359
-				// Decode [ and ].
1360
-				if ( ! empty( $content ) && $is_preview ) {
1361
-					$content = $this->decode_shortcodes( $content );
1362
-				}
1359
+                // Decode [ and ].
1360
+                if ( ! empty( $content ) && $is_preview ) {
1361
+                    $content = $this->decode_shortcodes( $content );
1362
+                }
1363 1363
 
1364
-				echo $content;
1365
-			}
1366
-			wp_die();
1367
-		}
1364
+                echo $content;
1365
+            }
1366
+            wp_die();
1367
+        }
1368 1368
 
1369
-		/**
1370
-		 * Output the shortcode.
1371
-		 *
1372
-		 * @param array $args
1373
-		 * @param string $content
1374
-		 *
1375
-		 * @return string
1376
-		 */
1377
-		public function shortcode_output( $args = array(), $content = '' ) {
1378
-			$_instance = $args;
1379
-
1380
-			$args = $this->argument_values( $args );
1381
-
1382
-			// add extra argument so we know its a output to gutenberg
1383
-			//$args
1384
-			$args = $this->string_to_bool( $args );
1385
-
1386
-			// if we have a enclosed shortcode we add it to the special `html` argument
1387
-			if ( ! empty( $content ) ) {
1388
-				$args['html'] = $content;
1389
-			}
1369
+        /**
1370
+         * Output the shortcode.
1371
+         *
1372
+         * @param array $args
1373
+         * @param string $content
1374
+         *
1375
+         * @return string
1376
+         */
1377
+        public function shortcode_output( $args = array(), $content = '' ) {
1378
+            $_instance = $args;
1390 1379
 
1391
-			if ( ! $this->is_preview() ) {
1392
-				/**
1393
-				 * Filters the settings for a particular widget args.
1394
-				 *
1395
-				 * @param array          $args      The current widget instance's settings.
1396
-				 * @param WP_Super_Duper $widget    The current widget settings.
1397
-				 * @param array          $_instance An array of default widget arguments.
1398
-				 *
1399
-				 *@since 1.0.28
1400
-				 *
1401
-				 */
1402
-				$args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );
1380
+            $args = $this->argument_values( $args );
1403 1381
 
1404
-				if ( ! is_array( $args ) ) {
1405
-					return $args;
1406
-				}
1407
-			}
1382
+            // add extra argument so we know its a output to gutenberg
1383
+            //$args
1384
+            $args = $this->string_to_bool( $args );
1408 1385
 
1409
-			$class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1410
-			$class .= " sdel-".$this->get_instance_hash();
1386
+            // if we have a enclosed shortcode we add it to the special `html` argument
1387
+            if ( ! empty( $content ) ) {
1388
+                $args['html'] = $content;
1389
+            }
1411 1390
 
1412
-			$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1413
-			$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1391
+            if ( ! $this->is_preview() ) {
1392
+                /**
1393
+                 * Filters the settings for a particular widget args.
1394
+                 *
1395
+                 * @param array          $args      The current widget instance's settings.
1396
+                 * @param WP_Super_Duper $widget    The current widget settings.
1397
+                 * @param array          $_instance An array of default widget arguments.
1398
+                 *
1399
+                 *@since 1.0.28
1400
+                 *
1401
+                 */
1402
+                $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );
1403
+
1404
+                if ( ! is_array( $args ) ) {
1405
+                    return $args;
1406
+                }
1407
+            }
1414 1408
 
1415
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1416
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1409
+            $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1410
+            $class .= " sdel-".$this->get_instance_hash();
1417 1411
 
1418
-			$shortcode_args = array();
1419
-			$output         = '';
1420
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1421
-			if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1422
-				$no_wrap = true;
1423
-			}
1424
-			$main_content = $this->output( $args, $shortcode_args, $content );
1425
-			if ( $main_content && ! $no_wrap ) {
1426
-				// wrap the shortcode in a div with the same class as the widget
1427
-				$output .= '<div class="' . $class . '" ' . $attrs . '>';
1428
-				if ( ! empty( $args['title'] ) ) {
1429
-					// if its a shortcode and there is a title try to grab the title wrappers
1430
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1431
-					if ( empty( $instance ) ) {
1432
-						global $wp_registered_sidebars;
1433
-						if ( ! empty( $wp_registered_sidebars ) ) {
1434
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1435
-								if ( ! empty( $sidebar['before_title'] ) ) {
1436
-									$shortcode_args['before_title'] = $sidebar['before_title'];
1437
-									$shortcode_args['after_title']  = $sidebar['after_title'];
1438
-									break;
1439
-								}
1440
-							}
1441
-						}
1442
-					}
1443
-					$output .= $this->output_title( $shortcode_args, $args );
1444
-				}
1445
-				$output .= $main_content;
1446
-				$output .= '</div>';
1447
-			} elseif ( $main_content && $no_wrap ) {
1448
-				$output .= $main_content;
1449
-			}
1412
+            $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1413
+            $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1450 1414
 
1451
-			// if preview show a placeholder if empty
1452
-			if ( $this->is_preview() && $output == '' ) {
1453
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1454
-			}
1415
+            $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1416
+            $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1455 1417
 
1456
-			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1457
-		}
1418
+            $shortcode_args = array();
1419
+            $output         = '';
1420
+            $no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1421
+            if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1422
+                $no_wrap = true;
1423
+            }
1424
+            $main_content = $this->output( $args, $shortcode_args, $content );
1425
+            if ( $main_content && ! $no_wrap ) {
1426
+                // wrap the shortcode in a div with the same class as the widget
1427
+                $output .= '<div class="' . $class . '" ' . $attrs . '>';
1428
+                if ( ! empty( $args['title'] ) ) {
1429
+                    // if its a shortcode and there is a title try to grab the title wrappers
1430
+                    $shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1431
+                    if ( empty( $instance ) ) {
1432
+                        global $wp_registered_sidebars;
1433
+                        if ( ! empty( $wp_registered_sidebars ) ) {
1434
+                            foreach ( $wp_registered_sidebars as $sidebar ) {
1435
+                                if ( ! empty( $sidebar['before_title'] ) ) {
1436
+                                    $shortcode_args['before_title'] = $sidebar['before_title'];
1437
+                                    $shortcode_args['after_title']  = $sidebar['after_title'];
1438
+                                    break;
1439
+                                }
1440
+                            }
1441
+                        }
1442
+                    }
1443
+                    $output .= $this->output_title( $shortcode_args, $args );
1444
+                }
1445
+                $output .= $main_content;
1446
+                $output .= '</div>';
1447
+            } elseif ( $main_content && $no_wrap ) {
1448
+                $output .= $main_content;
1449
+            }
1458 1450
 
1459
-		/**
1460
-		 * Placeholder text to show if output is empty and we are on a preview/builder page.
1461
-		 *
1462
-		 * @param string $name
1463
-		 *
1464
-		 * @return string
1465
-		 */
1466
-		public function preview_placeholder_text( $name = '' ) {
1467
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>";
1468
-		}
1451
+            // if preview show a placeholder if empty
1452
+            if ( $this->is_preview() && $output == '' ) {
1453
+                $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1454
+            }
1469 1455
 
1470
-		/**
1471
-		 * Sometimes booleans values can be turned to strings, so we fix that.
1472
-		 *
1473
-		 * @param $options
1474
-		 *
1475
-		 * @return mixed
1476
-		 */
1477
-		public function string_to_bool( $options ) {
1478
-			// convert bool strings to booleans
1479
-			foreach ( $options as $key => $val ) {
1480
-				if ( $val == 'false' ) {
1481
-					$options[ $key ] = false;
1482
-				} elseif ( $val == 'true' ) {
1483
-					$options[ $key ] = true;
1484
-				}
1485
-			}
1456
+            return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1457
+        }
1486 1458
 
1487
-			return $options;
1488
-		}
1459
+        /**
1460
+         * Placeholder text to show if output is empty and we are on a preview/builder page.
1461
+         *
1462
+         * @param string $name
1463
+         *
1464
+         * @return string
1465
+         */
1466
+        public function preview_placeholder_text( $name = '' ) {
1467
+            return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>";
1468
+        }
1489 1469
 
1490
-		/**
1491
-		 * Get the argument values that are also filterable.
1492
-		 *
1493
-		 * @param $instance
1494
-		 *
1495
-		 * @return array
1496
-		 *@since 1.0.12 Don't set checkbox default value if the value is empty.
1497
-		 *
1498
-		 */
1499
-		public function argument_values( $instance ) {
1500
-			$argument_values = array();
1501
-
1502
-			// set widget instance
1503
-			$this->instance = $instance;
1504
-
1505
-			if ( empty( $this->arguments ) ) {
1506
-				$this->arguments = $this->get_arguments();
1507
-			}
1470
+        /**
1471
+         * Sometimes booleans values can be turned to strings, so we fix that.
1472
+         *
1473
+         * @param $options
1474
+         *
1475
+         * @return mixed
1476
+         */
1477
+        public function string_to_bool( $options ) {
1478
+            // convert bool strings to booleans
1479
+            foreach ( $options as $key => $val ) {
1480
+                if ( $val == 'false' ) {
1481
+                    $options[ $key ] = false;
1482
+                } elseif ( $val == 'true' ) {
1483
+                    $options[ $key ] = true;
1484
+                }
1485
+            }
1508 1486
 
1509
-			if ( ! empty( $this->arguments ) ) {
1510
-				foreach ( $this->arguments as $key => $args ) {
1511
-					// set the input name from the key
1512
-					$args['name'] = $key;
1513
-					//
1514
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1515
-					if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1516
-						// don't set default for an empty checkbox
1517
-					} elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1518
-						$argument_values[ $key ] = $args['default'];
1519
-					}
1520
-				}
1521
-			}
1487
+            return $options;
1488
+        }
1522 1489
 
1523
-			return $argument_values;
1524
-		}
1490
+        /**
1491
+         * Get the argument values that are also filterable.
1492
+         *
1493
+         * @param $instance
1494
+         *
1495
+         * @return array
1496
+         *@since 1.0.12 Don't set checkbox default value if the value is empty.
1497
+         *
1498
+         */
1499
+        public function argument_values( $instance ) {
1500
+            $argument_values = array();
1525 1501
 
1526
-		/**
1527
-		 * Set arguments in super duper.
1528
-		 *
1529
-		 * @return array Set arguments.
1530
-		 *@since 1.0.0
1531
-		 *
1532
-		 */
1533
-		public function set_arguments() {
1534
-			return $this->arguments;
1535
-		}
1502
+            // set widget instance
1503
+            $this->instance = $instance;
1536 1504
 
1537
-		/**
1538
-		 * Get arguments in super duper.
1539
-		 *
1540
-		 * @return array Get arguments.
1541
-		 *@since 1.0.0
1542
-		 *
1543
-		 */
1544
-		public function get_arguments() {
1545
-			if ( empty( $this->arguments ) ) {
1546
-				$this->arguments = $this->set_arguments();
1547
-			}
1505
+            if ( empty( $this->arguments ) ) {
1506
+                $this->arguments = $this->get_arguments();
1507
+            }
1548 1508
 
1549
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1550
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1509
+            if ( ! empty( $this->arguments ) ) {
1510
+                foreach ( $this->arguments as $key => $args ) {
1511
+                    // set the input name from the key
1512
+                    $args['name'] = $key;
1513
+                    //
1514
+                    $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1515
+                    if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1516
+                        // don't set default for an empty checkbox
1517
+                    } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1518
+                        $argument_values[ $key ] = $args['default'];
1519
+                    }
1520
+                }
1521
+            }
1551 1522
 
1552
-			return $this->arguments;
1553
-		}
1523
+            return $argument_values;
1524
+        }
1554 1525
 
1555
-		/**
1556
-		 * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1557
-		 *
1558
-		 * @param array $args
1559
-		 * @param array $widget_args
1560
-		 * @param string $content
1561
-		 */
1562
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1526
+        /**
1527
+         * Set arguments in super duper.
1528
+         *
1529
+         * @return array Set arguments.
1530
+         *@since 1.0.0
1531
+         *
1532
+         */
1533
+        public function set_arguments() {
1534
+            return $this->arguments;
1535
+        }
1563 1536
 
1564
-		}
1537
+        /**
1538
+         * Get arguments in super duper.
1539
+         *
1540
+         * @return array Get arguments.
1541
+         *@since 1.0.0
1542
+         *
1543
+         */
1544
+        public function get_arguments() {
1545
+            if ( empty( $this->arguments ) ) {
1546
+                $this->arguments = $this->set_arguments();
1547
+            }
1565 1548
 
1566
-		/**
1567
-		 * Add the dynamic block code inline when the wp-block in enqueued.
1568
-		 */
1569
-		public function register_block() {
1570
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1571
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1572
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1573
-			}
1574
-		}
1549
+            $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1550
+            $this->arguments = $this->add_name_from_key( $this->arguments, true );
1575 1551
 
1576
-		/**
1577
-		 * Check if we need to show advanced options.
1578
-		 *
1579
-		 * @return bool
1580
-		 */
1581
-		public function block_show_advanced() {
1582
-
1583
-			$show      = false;
1584
-			$arguments = $this->get_arguments();
1585
-
1586
-			if ( ! empty( $arguments ) ) {
1587
-				foreach ( $arguments as $argument ) {
1588
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1589
-						$show = true;
1590
-						break; // no need to continue if we know we have it
1591
-					}
1592
-				}
1593
-			}
1552
+            return $this->arguments;
1553
+        }
1594 1554
 
1595
-			return $show;
1596
-		}
1555
+        /**
1556
+         * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1557
+         *
1558
+         * @param array $args
1559
+         * @param array $widget_args
1560
+         * @param string $content
1561
+         */
1562
+        public function output( $args = array(), $widget_args = array(), $content = '' ) {
1597 1563
 
1598
-		/**
1599
-		 * Get the url path to the current folder.
1600
-		 *
1601
-		 * @return string
1602
-		 */
1603
-		public function get_url() {
1604
-			$url = $this->url;
1605
-
1606
-			if ( ! $url ) {
1607
-				$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1608
-				$content_url = untrailingslashit( WP_CONTENT_URL );
1609
-
1610
-				// Replace http:// to https://.
1611
-				if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1612
-					$content_url = str_replace( 'http://', 'https://', $content_url );
1613
-				}
1564
+        }
1614 1565
 
1615
-				// Check if we are inside a plugin
1616
-				$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1617
-				$url = str_replace( $content_dir, $content_url, $file_dir );
1618
-				$url = trailingslashit( $url );
1619
-				$this->url = $url;
1620
-			}
1566
+        /**
1567
+         * Add the dynamic block code inline when the wp-block in enqueued.
1568
+         */
1569
+        public function register_block() {
1570
+            wp_add_inline_script( 'wp-blocks', $this->block() );
1571
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
1572
+                wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1573
+            }
1574
+        }
1621 1575
 
1622
-			return $url;
1623
-		}
1576
+        /**
1577
+         * Check if we need to show advanced options.
1578
+         *
1579
+         * @return bool
1580
+         */
1581
+        public function block_show_advanced() {
1624 1582
 
1625
-		/**
1626
-		 * Get the url path to the current folder.
1627
-		 *
1628
-		 * @return string
1629
-		 */
1630
-		public function get_url_old() {
1583
+            $show      = false;
1584
+            $arguments = $this->get_arguments();
1631 1585
 
1632
-			$url = $this->url;
1586
+            if ( ! empty( $arguments ) ) {
1587
+                foreach ( $arguments as $argument ) {
1588
+                    if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1589
+                        $show = true;
1590
+                        break; // no need to continue if we know we have it
1591
+                    }
1592
+                }
1593
+            }
1633 1594
 
1634
-			if ( ! $url ) {
1635
-				// check if we are inside a plugin
1636
-				$file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1595
+            return $show;
1596
+        }
1637 1597
 
1638
-				$dir_parts = explode( "/wp-content/", $file_dir );
1639
-				$url_parts = explode( "/wp-content/", plugins_url() );
1598
+        /**
1599
+         * Get the url path to the current folder.
1600
+         *
1601
+         * @return string
1602
+         */
1603
+        public function get_url() {
1604
+            $url = $this->url;
1640 1605
 
1641
-				if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1642
-					$url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1643
-					$this->url = $url;
1644
-				}
1645
-			}
1606
+            if ( ! $url ) {
1607
+                $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1608
+                $content_url = untrailingslashit( WP_CONTENT_URL );
1646 1609
 
1610
+                // Replace http:// to https://.
1611
+                if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1612
+                    $content_url = str_replace( 'http://', 'https://', $content_url );
1613
+                }
1647 1614
 
1648
-			return $url;
1649
-		}
1615
+                // Check if we are inside a plugin
1616
+                $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1617
+                $url = str_replace( $content_dir, $content_url, $file_dir );
1618
+                $url = trailingslashit( $url );
1619
+                $this->url = $url;
1620
+            }
1650 1621
 
1651
-		/**
1652
-		 * Generate the block icon.
1653
-		 *
1654
-		 * Enables the use of Font Awesome icons.
1655
-		 *
1656
-		 * @note xlink:href is actually deprecated but href is not supported by all so we use both.
1657
-		 *
1658
-		 * @param $icon
1659
-		 *
1660
-		 * @return string
1661
-		 *@since 1.1.0
1662
-		 */
1663
-		public function get_block_icon( $icon ) {
1664
-
1665
-			// check if we have a Font Awesome icon
1666
-			$fa_type = '';
1667
-			if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1668
-				$fa_type = 'solid';
1669
-			} elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1670
-				$fa_type = 'regular';
1671
-			} elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1672
-				$fa_type = 'brands';
1673
-			} else {
1674
-				$icon = "'" . $icon . "'";
1675
-			}
1622
+            return $url;
1623
+        }
1676 1624
 
1677
-			// set the icon if we found one
1678
-			if ( $fa_type ) {
1679
-				$fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1680
-				$icon    = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1681
-			}
1625
+        /**
1626
+         * Get the url path to the current folder.
1627
+         *
1628
+         * @return string
1629
+         */
1630
+        public function get_url_old() {
1682 1631
 
1683
-			return $icon;
1684
-		}
1632
+            $url = $this->url;
1633
+
1634
+            if ( ! $url ) {
1635
+                // check if we are inside a plugin
1636
+                $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1637
+
1638
+                $dir_parts = explode( "/wp-content/", $file_dir );
1639
+                $url_parts = explode( "/wp-content/", plugins_url() );
1640
+
1641
+                if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1642
+                    $url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1643
+                    $this->url = $url;
1644
+                }
1645
+            }
1646
+
1647
+
1648
+            return $url;
1649
+        }
1650
+
1651
+        /**
1652
+         * Generate the block icon.
1653
+         *
1654
+         * Enables the use of Font Awesome icons.
1655
+         *
1656
+         * @note xlink:href is actually deprecated but href is not supported by all so we use both.
1657
+         *
1658
+         * @param $icon
1659
+         *
1660
+         * @return string
1661
+         *@since 1.1.0
1662
+         */
1663
+        public function get_block_icon( $icon ) {
1664
+
1665
+            // check if we have a Font Awesome icon
1666
+            $fa_type = '';
1667
+            if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1668
+                $fa_type = 'solid';
1669
+            } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1670
+                $fa_type = 'regular';
1671
+            } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1672
+                $fa_type = 'brands';
1673
+            } else {
1674
+                $icon = "'" . $icon . "'";
1675
+            }
1685 1676
 
1686
-		public function group_arguments( $arguments ) {
1677
+            // set the icon if we found one
1678
+            if ( $fa_type ) {
1679
+                $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1680
+                $icon    = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1681
+            }
1682
+
1683
+            return $icon;
1684
+        }
1685
+
1686
+        public function group_arguments( $arguments ) {
1687 1687
 //			echo '###';print_r($arguments);
1688
-			if ( ! empty( $arguments ) ) {
1689
-				$temp_arguments = array();
1690
-				$general        = __( "General" );
1691
-				$add_sections   = false;
1692
-				foreach ( $arguments as $key => $args ) {
1693
-					if ( isset( $args['group'] ) ) {
1694
-						$temp_arguments[ $args['group'] ][ $key ] = $args;
1695
-						$add_sections                             = true;
1696
-					} else {
1697
-						$temp_arguments[ $general ][ $key ] = $args;
1698
-					}
1699
-				}
1688
+            if ( ! empty( $arguments ) ) {
1689
+                $temp_arguments = array();
1690
+                $general        = __( "General" );
1691
+                $add_sections   = false;
1692
+                foreach ( $arguments as $key => $args ) {
1693
+                    if ( isset( $args['group'] ) ) {
1694
+                        $temp_arguments[ $args['group'] ][ $key ] = $args;
1695
+                        $add_sections                             = true;
1696
+                    } else {
1697
+                        $temp_arguments[ $general ][ $key ] = $args;
1698
+                    }
1699
+                }
1700 1700
 
1701
-				// only add sections if more than one
1702
-				if ( $add_sections ) {
1703
-					$arguments = $temp_arguments;
1704
-				}
1705
-			}
1701
+                // only add sections if more than one
1702
+                if ( $add_sections ) {
1703
+                    $arguments = $temp_arguments;
1704
+                }
1705
+            }
1706 1706
 
1707 1707
 //			echo '###';print_r($arguments);
1708
-			return $arguments;
1709
-		}
1708
+            return $arguments;
1709
+        }
1710 1710
 
1711 1711
 
1712
-		/**
1713
-		 * Output the JS for building the dynamic Guntenberg block.
1714
-		 *
1715
-		 * @return mixed
1716
-		 *@since 1.0.9 Save numbers as numbers and not strings.
1717
-		 * @since 1.1.0 Font Awesome classes can be used for icons.
1718
-		 * @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.
1719
-		 */
1720
-		public function block() {
1712
+        /**
1713
+         * Output the JS for building the dynamic Guntenberg block.
1714
+         *
1715
+         * @return mixed
1716
+         *@since 1.0.9 Save numbers as numbers and not strings.
1717
+         * @since 1.1.0 Font Awesome classes can be used for icons.
1718
+         * @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.
1719
+         */
1720
+        public function block() {
1721 1721
             global $sd_is_js_functions_loaded;
1722 1722
 
1723
-			ob_start();
1723
+            ob_start();
1724 1724
 
1725
-			$show_advanced = $this->block_show_advanced();
1725
+            $show_advanced = $this->block_show_advanced();
1726 1726
 
1727 1727
 
1728
-			?>
1728
+            ?>
1729 1729
 			<script>
1730 1730
 
1731 1731
 			<?php
1732
-			if(!$sd_is_js_functions_loaded){
1732
+            if(!$sd_is_js_functions_loaded){
1733 1733
                 $sd_is_js_functions_loaded = true;
1734 1734
             ?>
1735 1735
 
@@ -2103,10 +2103,10 @@  discard block
 block discarded – undo
2103 2103
 
2104 2104
             }
2105 2105
 
2106
-			if(method_exists($this,'block_global_js')){
2107
-					echo $this->block_global_js();
2108
-			}
2109
-			?>
2106
+            if(method_exists($this,'block_global_js')){
2107
+                    echo $this->block_global_js();
2108
+            }
2109
+            ?>
2110 2110
 
2111 2111
 jQuery(function() {
2112 2112
 
@@ -2156,14 +2156,14 @@  discard block
 block discarded – undo
2156 2156
 						icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
2157 2157
 						supports: {
2158 2158
 							<?php
2159
-							if ( isset( $this->options['block-supports'] ) ) {
2160
-								echo $this->array_to_attributes( $this->options['block-supports'] );
2161
-							}
2162
-							?>
2159
+                            if ( isset( $this->options['block-supports'] ) ) {
2160
+                                echo $this->array_to_attributes( $this->options['block-supports'] );
2161
+                            }
2162
+                            ?>
2163 2163
 						},
2164 2164
 						<?php
2165
-						if ( isset( $this->options['block-label'] ) ) {
2166
-						?>
2165
+                        if ( isset( $this->options['block-label'] ) ) {
2166
+                        ?>
2167 2167
 						__experimentalLabel( attributes, { context } ) {
2168 2168
                             return <?php echo $this->options['block-label']; ?>;
2169 2169
                         },
@@ -2172,7 +2172,7 @@  discard block
 block discarded – undo
2172 2172
                         ?>
2173 2173
 						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.
2174 2174
 						<?php if ( isset( $this->options['block-keywords'] ) ) {
2175
-						echo "keywords : " . $this->options['block-keywords'] . ",";
2175
+                        echo "keywords : " . $this->options['block-keywords'] . ",";
2176 2176
 
2177 2177
 //						// block hover preview.
2178 2178
 //						$example_args = array();
@@ -2197,86 +2197,86 @@  discard block
 block discarded – undo
2197 2197
 
2198 2198
                         }
2199 2199
 
2200
-						// maybe set no_wrap
2201
-						$no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2202
-						if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2203
-							$no_wrap = true;
2204
-						}
2205
-						if ( $no_wrap ) {
2206
-							$this->options['block-wrap'] = '';
2207
-						}
2200
+                        // maybe set no_wrap
2201
+                        $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2202
+                        if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2203
+                            $no_wrap = true;
2204
+                        }
2205
+                        if ( $no_wrap ) {
2206
+                            $this->options['block-wrap'] = '';
2207
+                        }
2208 2208
 
2209
-						// maybe load the drag/drop functions.
2210
-						$img_drag_drop = false;
2209
+                        // maybe load the drag/drop functions.
2210
+                        $img_drag_drop = false;
2211 2211
 
2212
-						$show_alignment = false;
2213
-						// align feature
2214
-						/*echo "supports: {";
2212
+                        $show_alignment = false;
2213
+                        // align feature
2214
+                        /*echo "supports: {";
2215 2215
 						echo "	align: true,";
2216 2216
 						echo "  html: false";
2217 2217
 						echo "},";*/
2218 2218
 
2219
-						if ( ! empty( $this->arguments ) ) {
2220
-							echo "attributes : {";
2219
+                        if ( ! empty( $this->arguments ) ) {
2220
+                            echo "attributes : {";
2221 2221
 
2222
-							if ( $show_advanced ) {
2223
-								echo "show_advanced: {";
2224
-								echo "	type: 'boolean',";
2225
-								echo "  default: false,";
2226
-								echo "},";
2227
-							}
2222
+                            if ( $show_advanced ) {
2223
+                                echo "show_advanced: {";
2224
+                                echo "	type: 'boolean',";
2225
+                                echo "  default: false,";
2226
+                                echo "},";
2227
+                            }
2228 2228
 
2229
-							// block wrap element
2230
-							if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2231
-								echo "block_wrap: {";
2232
-								echo "	type: 'string',";
2233
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2234
-								echo "},";
2235
-							}
2229
+                            // block wrap element
2230
+                            if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2231
+                                echo "block_wrap: {";
2232
+                                echo "	type: 'string',";
2233
+                                echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2234
+                                echo "},";
2235
+                            }
2236 2236
 
2237 2237
 
2238 2238
 
2239
-							foreach ( $this->arguments as $key => $args ) {
2239
+                            foreach ( $this->arguments as $key => $args ) {
2240 2240
 
2241
-								if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2242
-									$img_drag_drop = true;
2243
-								}
2241
+                                if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2242
+                                    $img_drag_drop = true;
2243
+                                }
2244 2244
 
2245
-								// set if we should show alignment
2246
-								if ( $key == 'alignment' ) {
2247
-									$show_alignment = true;
2248
-								}
2245
+                                // set if we should show alignment
2246
+                                if ( $key == 'alignment' ) {
2247
+                                    $show_alignment = true;
2248
+                                }
2249 2249
 
2250
-								$extra = '';
2250
+                                $extra = '';
2251 2251
 
2252
-								if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2253
-									continue;
2254
-								}
2255
-								elseif ( $args['type'] == 'checkbox' ) {
2256
-									$type    = 'boolean';
2257
-									$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2258
-								} elseif ( $args['type'] == 'number' ) {
2259
-									$type    = 'number';
2260
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2261
-								} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2262
-									$type = 'array';
2263
-									if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2264
-										$default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2265
-									} else {
2266
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2267
-									}
2268
-								} elseif ( $args['type'] == 'tagselect' ) {
2269
-									$type    = 'array';
2270
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2271
-								} elseif ( $args['type'] == 'multiselect' ) {
2272
-									$type    = 'array';
2273
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2274
-								} elseif ( $args['type'] == 'image_xy' ) {
2275
-									$type    = 'object';
2276
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2277
-								} elseif ( $args['type'] == 'image' ) {
2278
-									$type    = 'string';
2279
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2252
+                                if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2253
+                                    continue;
2254
+                                }
2255
+                                elseif ( $args['type'] == 'checkbox' ) {
2256
+                                    $type    = 'boolean';
2257
+                                    $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2258
+                                } elseif ( $args['type'] == 'number' ) {
2259
+                                    $type    = 'number';
2260
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2261
+                                } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2262
+                                    $type = 'array';
2263
+                                    if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2264
+                                        $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2265
+                                    } else {
2266
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2267
+                                    }
2268
+                                } elseif ( $args['type'] == 'tagselect' ) {
2269
+                                    $type    = 'array';
2270
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2271
+                                } elseif ( $args['type'] == 'multiselect' ) {
2272
+                                    $type    = 'array';
2273
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2274
+                                } elseif ( $args['type'] == 'image_xy' ) {
2275
+                                    $type    = 'object';
2276
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2277
+                                } elseif ( $args['type'] == 'image' ) {
2278
+                                    $type    = 'string';
2279
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2280 2280
 
2281 2281
                                     // add a field for ID
2282 2282
 //                                    echo $key . "_id : {";
@@ -2286,25 +2286,25 @@  discard block
 block discarded – undo
2286 2286
 //                                    echo "type : 'object',";
2287 2287
 //                                    echo "},";
2288 2288
 
2289
-								} else {
2290
-									$type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2291
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2289
+                                } else {
2290
+                                    $type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2291
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2292 2292
 
2293
-								}
2294
-								echo $key . " : {";
2295
-								echo "type : '$type',";
2296
-								echo "default : $default,";
2297
-								echo "},";
2298
-							}
2293
+                                }
2294
+                                echo $key . " : {";
2295
+                                echo "type : '$type',";
2296
+                                echo "default : $default,";
2297
+                                echo "},";
2298
+                            }
2299 2299
 
2300
-							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2301
-							echo "className: { type: 'string', default: '' },";
2300
+                            echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2301
+                            echo "className: { type: 'string', default: '' },";
2302 2302
 
2303
-							echo "},";
2303
+                            echo "},";
2304 2304
 
2305
-						}
2305
+                        }
2306 2306
 
2307
-						?>
2307
+                        ?>
2308 2308
 
2309 2309
 						// The "edit" property must be a valid function.
2310 2310
 						edit: function (props) {
@@ -2404,9 +2404,9 @@  discard block
 block discarded – undo
2404 2404
 
2405 2405
 							var $value = '';
2406 2406
 							<?php
2407
-							// if we have a post_type and a category then link them
2408
-							if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2409
-							?>
2407
+                            // if we have a post_type and a category then link them
2408
+                            if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2409
+                            ?>
2410 2410
 							if(typeof(prev_attributes[props.clientId]) != 'undefined' ){
2411 2411
 								$pt = props.attributes.post_type;
2412 2412
 								if(post_type_rest_slugs.length){
@@ -2469,7 +2469,7 @@  discard block
 block discarded – undo
2469 2469
 <?php
2470 2470
 $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2471 2471
 if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2472
-	echo 'const { deviceType } = "";';
2472
+    echo 'const { deviceType } = "";';
2473 2473
 }else{
2474 2474
 ?>
2475 2475
 /** Get device type const. */
@@ -2503,8 +2503,8 @@  discard block
 block discarded – undo
2503 2503
 										'attributes': props.attributes,
2504 2504
 										'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '',
2505 2505
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
2506
-										echo $post->ID;
2507
-									}else{echo '0';}?>,
2506
+                                        echo $post->ID;
2507
+                                    }else{echo '0';}?>,
2508 2508
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
2509 2509
 									};
2510 2510
 
@@ -2581,10 +2581,10 @@  discard block
 block discarded – undo
2581 2581
 
2582 2582
 									<?php
2583 2583
 
2584
-									if(! empty( $this->arguments )){
2584
+                                    if(! empty( $this->arguments )){
2585 2585
 
2586
-									if ( $show_advanced ) {
2587
-									?>
2586
+                                    if ( $show_advanced ) {
2587
+                                    ?>
2588 2588
 									el('div', {
2589 2589
 											style: {'padding-left': '16px','padding-right': '16px'}
2590 2590
 										},
@@ -2602,146 +2602,146 @@  discard block
 block discarded – undo
2602 2602
 									,
2603 2603
 									<?php
2604 2604
 
2605
-									}
2605
+                                    }
2606 2606
 
2607
-								//	print_r( $this->arguments);
2607
+                                //	print_r( $this->arguments);
2608 2608
 
2609
-									//echo '####';
2609
+                                    //echo '####';
2610 2610
 
2611
-									$arguments = $this->group_arguments( $this->arguments );
2611
+                                    $arguments = $this->group_arguments( $this->arguments );
2612 2612
 //print_r($arguments ); exit;
2613
-									// Do we have sections?
2614
-									$has_sections = $arguments == $this->arguments ? false : true;
2613
+                                    // Do we have sections?
2614
+                                    $has_sections = $arguments == $this->arguments ? false : true;
2615 2615
 
2616 2616
 
2617
-									if($has_sections){
2618
-									$panel_count = 0;
2619
-									$open_tab = '';
2617
+                                    if($has_sections){
2618
+                                    $panel_count = 0;
2619
+                                    $open_tab = '';
2620 2620
 
2621
-									$open_tab_groups = array();
2622
-									$used_tabs = array();
2623
-									foreach($arguments as $key => $args){
2621
+                                    $open_tab_groups = array();
2622
+                                    $used_tabs = array();
2623
+                                    foreach($arguments as $key => $args){
2624 2624
 
2625
-										$close_tab = false;
2626
-										$close_tabs = false;
2625
+                                        $close_tab = false;
2626
+                                        $close_tabs = false;
2627 2627
 
2628
-										 if(!empty($this->options['block_group_tabs'])) {
2629
-											foreach($this->options['block_group_tabs'] as $tab_name => $tab_args){
2630
-												if(in_array($key,$tab_args['groups'])){
2628
+                                            if(!empty($this->options['block_group_tabs'])) {
2629
+                                            foreach($this->options['block_group_tabs'] as $tab_name => $tab_args){
2630
+                                                if(in_array($key,$tab_args['groups'])){
2631 2631
 
2632
-													$open_tab_groups[] = $key;
2632
+                                                    $open_tab_groups[] = $key;
2633 2633
 
2634
-													if($open_tab != $tab_name){
2635
-														$tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
2636
-														$tab_args['tab']['open'] = true;
2634
+                                                    if($open_tab != $tab_name){
2635
+                                                        $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
2636
+                                                        $tab_args['tab']['open'] = true;
2637 2637
 
2638
-														$this->block_tab_start( '', $tab_args );
2638
+                                                        $this->block_tab_start( '', $tab_args );
2639 2639
 //														echo '###open'.$tab_name;print_r($tab_args);
2640
-														$open_tab = $tab_name;
2641
-														$used_tabs[] = $tab_name;
2642
-													}
2640
+                                                        $open_tab = $tab_name;
2641
+                                                        $used_tabs[] = $tab_name;
2642
+                                                    }
2643 2643
 
2644
-													if($open_tab_groups == $tab_args['groups']){
2645
-														//$open_tab = '';
2646
-														$close_tab = true;
2647
-														$open_tab_groups = array();
2644
+                                                    if($open_tab_groups == $tab_args['groups']){
2645
+                                                        //$open_tab = '';
2646
+                                                        $close_tab = true;
2647
+                                                        $open_tab_groups = array();
2648 2648
 
2649 2649
 //													print_r(array_keys($this->options['block_group_tabs']));echo '####';print_r($used_tabs);
2650
-													if($used_tabs == array_keys($this->options['block_group_tabs'])){
2650
+                                                    if($used_tabs == array_keys($this->options['block_group_tabs'])){
2651 2651
 //														echo '@@@';
2652
-															$close_tabs = true;
2653
-														}
2654
-													}
2652
+                                                            $close_tabs = true;
2653
+                                                        }
2654
+                                                    }
2655 2655
 
2656
-												}
2657
-											}
2658
-										}
2656
+                                                }
2657
+                                            }
2658
+                                        }
2659 2659
 
2660 2660
 //
2661 2661
 
2662
-									//	print_r($arguments);exit;
2662
+                                    //	print_r($arguments);exit;
2663 2663
 
2664
-										?>
2664
+                                        ?>
2665 2665
 										el(wp.components.PanelBody, {
2666 2666
 												title: '<?php esc_attr_e( $key ); ?>',
2667 2667
 												initialOpen: <?php if ( $panel_count ) {
2668
-												echo "false";
2669
-											} else {
2670
-												echo "true";
2671
-											}?>
2668
+                                                echo "false";
2669
+                                            } else {
2670
+                                                echo "true";
2671
+                                            }?>
2672 2672
 											},
2673 2673
 											<?php
2674 2674
 
2675 2675
 
2676 2676
 
2677
-											foreach ( $args as $k => $a ) {
2677
+                                            foreach ( $args as $k => $a ) {
2678 2678
 
2679
-												$this->block_tab_start( $k, $a );
2680
-												$this->block_row_start( $k, $a );
2681
-												$this->build_block_arguments( $k, $a );
2682
-												$this->block_row_end( $k, $a );
2683
-												$this->block_tab_end( $k, $a );
2684
-											}
2685
-											?>
2679
+                                                $this->block_tab_start( $k, $a );
2680
+                                                $this->block_row_start( $k, $a );
2681
+                                                $this->build_block_arguments( $k, $a );
2682
+                                                $this->block_row_end( $k, $a );
2683
+                                                $this->block_tab_end( $k, $a );
2684
+                                            }
2685
+                                            ?>
2686 2686
 										),
2687 2687
 										<?php
2688
-										$panel_count ++;
2688
+                                        $panel_count ++;
2689 2689
 
2690 2690
 
2691
-										if($close_tab || $close_tabs){
2692
-											$tab_args = array(
2693
-												'tab'	=> array(
2694
-													'tabs_close' => $close_tabs,
2695
-												'close' => true,
2696
-												)
2691
+                                        if($close_tab || $close_tabs){
2692
+                                            $tab_args = array(
2693
+                                                'tab'	=> array(
2694
+                                                    'tabs_close' => $close_tabs,
2695
+                                                'close' => true,
2696
+                                                )
2697 2697
 
2698
-											);
2699
-											$this->block_tab_end( '', $tab_args );
2698
+                                            );
2699
+                                            $this->block_tab_end( '', $tab_args );
2700 2700
 //											echo '###close'; print_r($tab_args);
2701
-											$panel_count = 0;
2702
-										}
2701
+                                            $panel_count = 0;
2702
+                                        }
2703 2703
 //
2704 2704
 
2705
-									}
2706
-									}else {
2707
-									?>
2705
+                                    }
2706
+                                    }else {
2707
+                                    ?>
2708 2708
 									el(wp.components.PanelBody, {
2709 2709
 											title: '<?php esc_attr_e( "Settings" ); ?>',
2710 2710
 											initialOpen: true
2711 2711
 										},
2712 2712
 										<?php
2713
-										foreach ( $this->arguments as $key => $args ) {
2714
-											$this->block_row_start( $key, $args );
2715
-											$this->build_block_arguments( $key, $args );
2716
-											$this->block_row_end( $key, $args );
2717
-										}
2718
-										?>
2713
+                                        foreach ( $this->arguments as $key => $args ) {
2714
+                                            $this->block_row_start( $key, $args );
2715
+                                            $this->build_block_arguments( $key, $args );
2716
+                                            $this->block_row_end( $key, $args );
2717
+                                        }
2718
+                                        ?>
2719 2719
 									),
2720 2720
 									<?php
2721
-									}
2721
+                                    }
2722 2722
 
2723
-									}
2724
-									?>
2723
+                                    }
2724
+                                    ?>
2725 2725
 
2726 2726
 								),
2727 2727
 
2728 2728
 								<?php
2729
-								// If the user sets block-output array then build it
2730
-								if ( ! empty( $this->options['block-output'] ) ) {
2731
-								$this->block_element( $this->options['block-output'] );
2732
-							}elseif(!empty($this->options['block-edit-return'])){
2733
-                                   echo $this->options['block-edit-return'];
2734
-							}else{
2735
-								// if no block-output is set then we try and get the shortcode html output via ajax.
2736
-								?>
2729
+                                // If the user sets block-output array then build it
2730
+                                if ( ! empty( $this->options['block-output'] ) ) {
2731
+                                $this->block_element( $this->options['block-output'] );
2732
+                            }elseif(!empty($this->options['block-edit-return'])){
2733
+                                    echo $this->options['block-edit-return'];
2734
+                            }else{
2735
+                                // if no block-output is set then we try and get the shortcode html output via ajax.
2736
+                                ?>
2737 2737
 								el('div', wp.blockEditor.useBlockProps({
2738 2738
 									dangerouslySetInnerHTML: {__html: onChangeContent()},
2739 2739
 									className: props.className,
2740 2740
 									style: {'minHeight': '30px'}
2741 2741
 								}))
2742 2742
 								<?php
2743
-								}
2744
-								?>
2743
+                                }
2744
+                                ?>
2745 2745
 							]; // end return
2746 2746
 
2747 2747
 							<?php
@@ -2760,11 +2760,11 @@  discard block
 block discarded – undo
2760 2760
 							$html = '';
2761 2761
 							<?php
2762 2762
 
2763
-							if(! empty( $this->arguments )){
2763
+                            if(! empty( $this->arguments )){
2764 2764
 
2765
-							foreach($this->arguments as $key => $args){
2766
-                               // if($args['type']=='tabs'){continue;}
2767
-							?>
2765
+                            foreach($this->arguments as $key => $args){
2766
+                                // if($args['type']=='tabs'){continue;}
2767
+                            ?>
2768 2768
 							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
2769 2769
 								if ('<?php echo esc_attr( $key );?>' == 'html') {
2770 2770
 									$html = attr.<?php echo esc_attr( $key );?>;
@@ -2775,10 +2775,10 @@  discard block
 block discarded – undo
2775 2775
 								}
2776 2776
 							}
2777 2777
 							<?php
2778
-							}
2779
-							}
2778
+                            }
2779
+                            }
2780 2780
 
2781
-							?>
2781
+                            ?>
2782 2782
 							content += "]";
2783 2783
 
2784 2784
                             <?php
@@ -2825,7 +2825,7 @@  discard block
 block discarded – undo
2825 2825
 //                               $this->block_element( $this->options['block-output'], true );
2826 2826
 //                               echo ";";
2827 2827
 
2828
-                               ?>
2828
+                                ?>
2829 2829
                               return el(
2830 2830
                                    '',
2831 2831
                                    {},
@@ -2835,9 +2835,9 @@  discard block
 block discarded – undo
2835 2835
                                );
2836 2836
                                 <?php
2837 2837
 
2838
-							}elseif(!empty($this->options['block-save-return'])){
2839
-                                   echo 'return ' . $this->options['block-save-return'];
2840
-							}elseif(!empty($this->options['nested-block'])){
2838
+                            }elseif(!empty($this->options['block-save-return'])){
2839
+                                    echo 'return ' . $this->options['block-save-return'];
2840
+                            }elseif(!empty($this->options['nested-block'])){
2841 2841
                                 ?>
2842 2842
                               return el(
2843 2843
                                    '',
@@ -2847,22 +2847,22 @@  discard block
 block discarded – undo
2847 2847
                                    el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
2848 2848
                                );
2849 2849
                                 <?php
2850
-							}elseif(!empty( $this->options['block-save-return'] ) ){
2850
+                            }elseif(!empty( $this->options['block-save-return'] ) ){
2851 2851
                                 echo "return ". $this->options['block-edit-return'].";";
2852
-							}elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
2853
-							?>
2852
+                            }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
2853
+                            ?>
2854 2854
 							return content;
2855 2855
 							<?php
2856
-							}else{
2857
-							?>
2856
+                            }else{
2857
+                            ?>
2858 2858
 							var block_wrap = 'div';
2859 2859
 							if (attr.hasOwnProperty("block_wrap")) {
2860 2860
 								block_wrap = attr.block_wrap;
2861 2861
 							}
2862 2862
 							return el(block_wrap, wp.blockEditor.useBlockProps.save( {dangerouslySetInnerHTML: {__html: content}, className: align} ));
2863 2863
 							<?php
2864
-							}
2865
-							?>
2864
+                            }
2865
+                            ?>
2866 2866
 
2867 2867
 
2868 2868
 						}
@@ -2876,29 +2876,29 @@  discard block
 block discarded – undo
2876 2876
                 });
2877 2877
 			</script>
2878 2878
 			<?php
2879
-			$output = ob_get_clean();
2879
+            $output = ob_get_clean();
2880 2880
 
2881
-			/*
2881
+            /*
2882 2882
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
2883 2883
 			 */
2884 2884
 
2885
-			return str_replace( array(
2886
-				'<script>',
2887
-				'</script>'
2888
-			), '', $output );
2889
-		}
2885
+            return str_replace( array(
2886
+                '<script>',
2887
+                '</script>'
2888
+            ), '', $output );
2889
+        }
2890 2890
 
2891 2891
 
2892 2892
 
2893
-		public function block_row_start($key, $args){
2893
+        public function block_row_start($key, $args){
2894 2894
 
2895
-			// check for row
2896
-			if(!empty($args['row'])){
2895
+            // check for row
2896
+            if(!empty($args['row'])){
2897 2897
 
2898
-				if(!empty($args['row']['open'])){
2898
+                if(!empty($args['row']['open'])){
2899 2899
 
2900
-				// element require
2901
-				$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
2900
+                // element require
2901
+                $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
2902 2902
                 $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
2903 2903
                 $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
2904 2904
                 $device_type_icon = '';
@@ -2909,10 +2909,10 @@  discard block
 block discarded – undo
2909 2909
                 }elseif($device_type=='Mobile'){
2910 2910
                     $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
2911 2911
                 }
2912
-				echo $element_require;
2912
+                echo $element_require;
2913 2913
                 echo $device_type_require;
2914 2914
 
2915
-					if(false){?><script><?php }?>
2915
+                    if(false){?><script><?php }?>
2916 2916
 						el('div', {
2917 2917
 								className: 'bsui components-base-control',
2918 2918
 							},
@@ -2950,51 +2950,51 @@  discard block
 block discarded – undo
2950 2950
 									},
2951 2951
 
2952 2952
 					<?php
2953
-					if(false){?></script><?php }
2954
-				}elseif(!empty($args['row']['close'])){
2955
-					if(false){?><script><?php }?>
2953
+                    if(false){?></script><?php }
2954
+                }elseif(!empty($args['row']['close'])){
2955
+                    if(false){?><script><?php }?>
2956 2956
 						el(
2957 2957
 							'div',
2958 2958
 							{
2959 2959
 								className: 'col pl-0',
2960 2960
 							},
2961 2961
 					<?php
2962
-					if(false){?></script><?php }
2963
-				}else{
2964
-					if(false){?><script><?php }?>
2962
+                    if(false){?></script><?php }
2963
+                }else{
2964
+                    if(false){?><script><?php }?>
2965 2965
 						el(
2966 2966
 							'div',
2967 2967
 							{
2968 2968
 								className: 'col pl-0 pr-2',
2969 2969
 							},
2970 2970
 					<?php
2971
-					if(false){?></script><?php }
2972
-				}
2971
+                    if(false){?></script><?php }
2972
+                }
2973 2973
 
2974
-			}
2974
+            }
2975 2975
 
2976
-		}
2976
+        }
2977 2977
 
2978
-		public function block_row_end($key, $args){
2978
+        public function block_row_end($key, $args){
2979 2979
 
2980
-			if(!empty($args['row'])){
2981
-				// maybe close
2982
-				if(!empty($args['row']['close'])){
2983
-					echo "))";
2984
-				}
2980
+            if(!empty($args['row'])){
2981
+                // maybe close
2982
+                if(!empty($args['row']['close'])){
2983
+                    echo "))";
2984
+                }
2985 2985
 
2986
-				echo "),";
2987
-			}
2988
-		}
2986
+                echo "),";
2987
+            }
2988
+        }
2989 2989
 
2990
-		public function block_tab_start($key, $args){
2990
+        public function block_tab_start($key, $args){
2991 2991
 
2992
-			// check for row
2993
-			if(!empty($args['tab'])){
2992
+            // check for row
2993
+            if(!empty($args['tab'])){
2994 2994
 
2995
-				if(!empty($args['tab']['tabs_open'])){
2995
+                if(!empty($args['tab']['tabs_open'])){
2996 2996
 
2997
-					if(false){?><script><?php }?>
2997
+                    if(false){?><script><?php }?>
2998 2998
 
2999 2999
 el('div',{className: 'bsui'},
3000 3000
 
@@ -3007,12 +3007,12 @@  discard block
 block discarded – undo
3007 3007
 										tabs: [
3008 3008
 
3009 3009
 					<?php
3010
-					if(false){?></script><?php }
3011
-				}
3010
+                    if(false){?></script><?php }
3011
+                }
3012 3012
 
3013
-				if(!empty($args['tab']['open'])){
3013
+                if(!empty($args['tab']['open'])){
3014 3014
 
3015
-					if(false){?><script><?php }?>
3015
+                    if(false){?><script><?php }?>
3016 3016
 							{
3017 3017
 												name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3018 3018
 												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}),
@@ -3021,23 +3021,23 @@  discard block
 block discarded – undo
3021 3021
 									className: 'components-base-control__help mb-0',
3022 3022
 									dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'}
3023 3023
 								}),<?php }
3024
-					if(false){?></script><?php }
3025
-				}
3024
+                    if(false){?></script><?php }
3025
+                }
3026 3026
 
3027
-			}
3027
+            }
3028 3028
 
3029
-		}
3029
+        }
3030 3030
 
3031
-		public function block_tab_end($key, $args){
3031
+        public function block_tab_end($key, $args){
3032 3032
 
3033
-			if(!empty($args['tab'])){
3034
-				// maybe close
3035
-				if(!empty($args['tab']['close'])){
3036
-					echo ")}, /* tab close */";
3037
-				}
3033
+            if(!empty($args['tab'])){
3034
+                // maybe close
3035
+                if(!empty($args['tab']['close'])){
3036
+                    echo ")}, /* tab close */";
3037
+                }
3038 3038
 
3039
-				if(!empty($args['tab']['tabs_close'])){
3040
-					if(false){?><script><?php }?>
3039
+                if(!empty($args['tab']['tabs_close'])){
3040
+                    if(false){?><script><?php }?>
3041 3041
 							],
3042 3042
 									},
3043 3043
 									( tab ) => {
@@ -3047,22 +3047,22 @@  discard block
 block discarded – undo
3047 3047
 								}
3048 3048
 								)), /* tabs close */
3049 3049
 					<?php if(false){ ?></script><?php }
3050
-				}
3051
-			}
3052
-		}
3050
+                }
3051
+            }
3052
+        }
3053 3053
 
3054
-		public function build_block_arguments( $key, $args ) {
3055
-			$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3056
-			$options           = '';
3057
-			$extra             = '';
3058
-			$require           = '';
3054
+        public function build_block_arguments( $key, $args ) {
3055
+            $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3056
+            $options           = '';
3057
+            $extra             = '';
3058
+            $require           = '';
3059 3059
             $inside_elements   = '';
3060
-			$after_elements	   = '';
3060
+            $after_elements	   = '';
3061 3061
 
3062
-			// `content` is a protected and special argument
3063
-			if ( $key == 'content' ) {
3064
-				return;
3065
-			}
3062
+            // `content` is a protected and special argument
3063
+            if ( $key == 'content' ) {
3064
+                return;
3065
+            }
3066 3066
 
3067 3067
             $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3068 3068
             $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
@@ -3075,51 +3075,51 @@  discard block
 block discarded – undo
3075 3075
                 $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3076 3076
             }
3077 3077
 
3078
-			// icon
3079
-			$icon = '';
3080
-			if( !empty( $args['icon'] ) ){
3081
-				$icon .= "el('div', {";
3082
-									$icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3083
-									$icon .= "className: 'text-center',";
3084
-									$icon .= "title: '".addslashes( $args['title'] )."',";
3085
-								$icon .= "}),";
3086
-
3087
-				// blank title as its added to the icon.
3088
-				$args['title'] = '';
3089
-			}
3078
+            // icon
3079
+            $icon = '';
3080
+            if( !empty( $args['icon'] ) ){
3081
+                $icon .= "el('div', {";
3082
+                                    $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3083
+                                    $icon .= "className: 'text-center',";
3084
+                                    $icon .= "title: '".addslashes( $args['title'] )."',";
3085
+                                $icon .= "}),";
3086
+
3087
+                // blank title as its added to the icon.
3088
+                $args['title'] = '';
3089
+            }
3090 3090
 
3091
-			// require advanced
3092
-			$require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3091
+            // require advanced
3092
+            $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3093 3093
 
3094
-			// element require
3095
-			$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3094
+            // element require
3095
+            $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3096 3096
 
3097 3097
 
3098
-			$onchange  = "props.setAttributes({ $key: $key } )";
3099
-			$onchangecomplete  = "";
3100
-			$value     = "props.attributes.$key";
3101
-			$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3102
-			if ( in_array( $args['type'], $text_type ) ) {
3103
-				$type = 'TextControl';
3104
-				// Save numbers as numbers and not strings
3105
-				if ( $args['type'] == 'number' ) {
3106
-					$onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3107
-				}
3108
-			}else if ( $args['type'] == 'styleid' ) {
3109
-				$type = 'TextControl';
3110
-				$args['type'] == 'text';
3111
-				// Save numbers as numbers and not strings
3112
-				$value     = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'";
3113
-			}else if ( $args['type'] == 'notice' ) {
3114
-
3115
-				$notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3116
-				$notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
3117
-
3118
-				$notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),";
3119
-				echo $notice_message ? $element_require . $notice : '';
3120
-				return;
3121
-			}
3122
-			/*
3098
+            $onchange  = "props.setAttributes({ $key: $key } )";
3099
+            $onchangecomplete  = "";
3100
+            $value     = "props.attributes.$key";
3101
+            $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3102
+            if ( in_array( $args['type'], $text_type ) ) {
3103
+                $type = 'TextControl';
3104
+                // Save numbers as numbers and not strings
3105
+                if ( $args['type'] == 'number' ) {
3106
+                    $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3107
+                }
3108
+            }else if ( $args['type'] == 'styleid' ) {
3109
+                $type = 'TextControl';
3110
+                $args['type'] == 'text';
3111
+                // Save numbers as numbers and not strings
3112
+                $value     = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'";
3113
+            }else if ( $args['type'] == 'notice' ) {
3114
+
3115
+                $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3116
+                $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
3117
+
3118
+                $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),";
3119
+                echo $notice_message ? $element_require . $notice : '';
3120
+                return;
3121
+            }
3122
+            /*
3123 3123
 			 * https://www.wptricks.com/question/set-current-tab-on-a-gutenberg-tabpanel-component-from-outside-that-component/ es5 layout
3124 3124
 						elseif($args['type']=='tabs'){
3125 3125
 							?>
@@ -3172,23 +3172,23 @@  discard block
 block discarded – undo
3172 3172
 							return;
3173 3173
 						}
3174 3174
 */
3175
-			elseif ( $args['type'] == 'color' ) {
3176
-				$type = 'ColorPicker';
3177
-				$onchange = "";
3178
-				$extra = "color: $value,";
3179
-				if(!empty($args['disable_alpha'])){
3180
-					$extra .= "disableAlpha: true,";
3181
-				}
3182
-				$onchangecomplete = "onChangeComplete: function($key) {
3175
+            elseif ( $args['type'] == 'color' ) {
3176
+                $type = 'ColorPicker';
3177
+                $onchange = "";
3178
+                $extra = "color: $value,";
3179
+                if(!empty($args['disable_alpha'])){
3180
+                    $extra .= "disableAlpha: true,";
3181
+                }
3182
+                $onchangecomplete = "onChangeComplete: function($key) {
3183 3183
 				value =  $key.rgb.a && $key.rgb.a < 1 ? \"rgba(\"+$key.rgb.r+\",\"+$key.rgb.g+\",\"+$key.rgb.b+\",\"+$key.rgb.a+\")\" : $key.hex;
3184 3184
                         props.setAttributes({
3185 3185
                             $key: value
3186 3186
                         });
3187 3187
                     },";
3188
-			}elseif ( $args['type'] == 'gradient' ) {
3189
-				$type = 'GradientPicker';
3188
+            }elseif ( $args['type'] == 'gradient' ) {
3189
+                $type = 'GradientPicker';
3190 3190
 
3191
-			}elseif ( $args['type'] == 'image' ) {
3191
+            }elseif ( $args['type'] == 'image' ) {
3192 3192
 //                print_r($args);
3193 3193
 
3194 3194
                 $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
@@ -3213,15 +3213,15 @@  discard block
 block discarded – undo
3213 3213
 
3214 3214
 
3215 3215
                 $value = '""';
3216
-				$type = 'MediaUpload';
3216
+                $type = 'MediaUpload';
3217 3217
                 $extra .= "onSelect: function(media){
3218 3218
                       return props.setAttributes({
3219 3219
                           $key: media.url,
3220 3220
                           {$key}_id: media.id
3221 3221
                         });
3222 3222
                       },";
3223
-                   $extra .= "type: 'image',";
3224
-                   $extra .= "render: function (obj) {
3223
+                    $extra .= "type: 'image',";
3224
+                    $extra .= "render: function (obj) {
3225 3225
                         return el( 'div',{},
3226 3226
                         ( !props.attributes.$key && !props.attributes.{$key}_use_featured ) && el( wp.components.Button, {
3227 3227
                           className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
@@ -3250,8 +3250,8 @@  discard block
 block discarded – undo
3250 3250
                 $onchange = "";
3251 3251
 
3252 3252
                 //$inside_elements = ",el('div',{},'file upload')";
3253
-			}elseif ( $args['type'] == 'images' ) {
3254
-				//                print_r($args);
3253
+            }elseif ( $args['type'] == 'images' ) {
3254
+                //                print_r($args);
3255 3255
 
3256 3256
                 $img_preview = "props.attributes.$key && (function() {
3257 3257
 
@@ -3280,7 +3280,7 @@  discard block
 block discarded – undo
3280 3280
 
3281 3281
 
3282 3282
                 $value = '""';
3283
-				$type = 'MediaUpload';
3283
+                $type = 'MediaUpload';
3284 3284
                 $extra .= "onSelect: function(media){
3285 3285
 
3286 3286
                 let slim_images = props.attributes.$key ? JSON.parse('['+props.attributes.$key+']') : [];
@@ -3294,9 +3294,9 @@  discard block
 block discarded – undo
3294 3294
                           $key: JSON.stringify(slim_images).replace('[','').replace(']',''),
3295 3295
                         });
3296 3296
                       },";
3297
-                   $extra .= "type: 'image',";
3298
-                   $extra .= "multiple: true,";
3299
-                   $extra .= "render: function (obj) {
3297
+                    $extra .= "type: 'image',";
3298
+                    $extra .= "multiple: true,";
3299
+                    $extra .= "render: function (obj) {
3300 3300
 
3301 3301
                    // init the sort
3302 3302
 				enableDragSort('sd-sortable');
@@ -3335,37 +3335,37 @@  discard block
 block discarded – undo
3335 3335
                 $onchange = "";
3336 3336
 
3337 3337
                 //$inside_elements = ",el('div',{},'file upload')";
3338
-			}
3339
-			elseif ( $args['type'] == 'checkbox' ) {
3340
-				$type = 'CheckboxControl';
3341
-				$extra .= "checked: props.attributes.$key,";
3342
-				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3343
-			} elseif ( $args['type'] == 'textarea' ) {
3344
-				$type = 'TextareaControl';
3345
-
3346
-			} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3347
-				$type = 'SelectControl';
3348
-
3349
-				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3350
-					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3351
-				}elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3352
-					$options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3353
-				}else {
3354
-
3355
-					if ( ! empty( $args['options'] ) ) {
3356
-						$options .= "options: [";
3357
-						foreach ( $args['options'] as $option_val => $option_label ) {
3358
-							$options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },";
3359
-						}
3360
-						$options .= "],";
3361
-					}
3362
-				}
3363
-				if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3364
-					$extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3365
-				}
3338
+            }
3339
+            elseif ( $args['type'] == 'checkbox' ) {
3340
+                $type = 'CheckboxControl';
3341
+                $extra .= "checked: props.attributes.$key,";
3342
+                $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3343
+            } elseif ( $args['type'] == 'textarea' ) {
3344
+                $type = 'TextareaControl';
3345
+
3346
+            } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3347
+                $type = 'SelectControl';
3348
+
3349
+                if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3350
+                    $options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3351
+                }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3352
+                    $options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3353
+                }else {
3354
+
3355
+                    if ( ! empty( $args['options'] ) ) {
3356
+                        $options .= "options: [";
3357
+                        foreach ( $args['options'] as $option_val => $option_label ) {
3358
+                            $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },";
3359
+                        }
3360
+                        $options .= "],";
3361
+                    }
3362
+                }
3363
+                if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3364
+                    $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3365
+                }
3366 3366
 
3367
-				if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3368
-					$after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3367
+                if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3368
+                    $after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3369 3369
                                       className: 'components-button components-circular-option-picker__clear is-secondary is-small',
3370 3370
                                       style: {margin:'-8px 0 8px 0',display: 'block'},
3371 3371
                                       onClick: function(){
@@ -3376,8 +3376,8 @@  discard block
 block discarded – undo
3376 3376
                                     },
3377 3377
                                     'Clear'
3378 3378
                             ),";
3379
-				}
3380
-			} elseif ( $args['type'] == 'tagselect' ) {
3379
+                }
3380
+            } elseif ( $args['type'] == 'tagselect' ) {
3381 3381
 //				$type = 'FormTokenField';
3382 3382
 //
3383 3383
 //				if ( ! empty( $args['options'] ) ) {
@@ -3412,39 +3412,39 @@  discard block
 block discarded – undo
3412 3412
 //				$value     = "[]";
3413 3413
 //				$extra .= ' __experimentalExpandOnFocus: true,';
3414 3414
 
3415
-			} elseif ( $args['type'] == 'alignment' ) {
3416
-				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
3417
-			}elseif ( $args['type'] == 'margins' ) {
3415
+            } elseif ( $args['type'] == 'alignment' ) {
3416
+                $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
3417
+            }elseif ( $args['type'] == 'margins' ) {
3418 3418
 
3419
-			} else {
3420
-				return;// if we have not implemented the control then don't break the JS.
3421
-			}
3419
+            } else {
3420
+                return;// if we have not implemented the control then don't break the JS.
3421
+            }
3422 3422
 
3423 3423
 
3424 3424
 
3425
-			// color input does not show the labels so we add them
3426
-			if($args['type']=='color'){
3427
-				// add show only if advanced
3428
-				echo $require_advanced;
3429
-				// add setting require if defined
3430
-				echo $element_require;
3431
-				echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
3432
-			}
3425
+            // color input does not show the labels so we add them
3426
+            if($args['type']=='color'){
3427
+                // add show only if advanced
3428
+                echo $require_advanced;
3429
+                // add setting require if defined
3430
+                echo $element_require;
3431
+                echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
3432
+            }
3433 3433
 
3434
-			// add show only if advanced
3435
-			echo $require_advanced;
3436
-			// add setting require if defined
3437
-			echo $element_require;
3434
+            // add show only if advanced
3435
+            echo $require_advanced;
3436
+            // add setting require if defined
3437
+            echo $element_require;
3438 3438
             echo $device_type_require;
3439 3439
 
3440
-			// icon
3441
-			echo $icon;
3442
-			?>
3440
+            // icon
3441
+            echo $icon;
3442
+            ?>
3443 3443
 			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type  : "wp.components.".$type; ?>, {
3444 3444
 			label: <?php
3445
-			if(empty($args['title'])){
3445
+            if(empty($args['title'])){
3446 3446
                 echo "''";
3447
-			}elseif(empty($args['row']) && !empty($args['device_type'])){
3447
+            }elseif(empty($args['row']) && !empty($args['device_type'])){
3448 3448
                 ?>el('label', {
3449 3449
 									className: 'components-base-control__label',
3450 3450
 									style: {width:"100%"}
@@ -3459,22 +3459,22 @@  discard block
 block discarded – undo
3459 3459
 
3460 3460
 							)<?php
3461 3461
 
3462
-			}else{
3463
-                 ?>'<?php echo addslashes( $args['title'] ); ?>'<?php
3462
+            }else{
3463
+                    ?>'<?php echo addslashes( $args['title'] ); ?>'<?php
3464 3464
 
3465
-			}
3465
+            }
3466 3466
 
3467
-			?>,
3467
+            ?>,
3468 3468
 			help: <?php if ( isset( $args['desc'] ) ) {
3469
-				echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})";
3470
-			}else{ echo "''"; } ?>,
3469
+                echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})";
3470
+            }else{ echo "''"; } ?>,
3471 3471
 			value: <?php echo $value; ?>,
3472 3472
 			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
3473
-				echo "type: '" . addslashes( $args['type'] ) . "',";
3474
-			} ?>
3473
+                echo "type: '" . addslashes( $args['type'] ) . "',";
3474
+            } ?>
3475 3475
 			<?php if ( ! empty( $args['placeholder'] ) ) {
3476
-				echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',";
3477
-			} ?>
3476
+                echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',";
3477
+            } ?>
3478 3478
 			<?php echo $options; ?>
3479 3479
 			<?php echo $extra; ?>
3480 3480
 			<?php echo $custom_attributes; ?>
@@ -3487,69 +3487,69 @@  discard block
 block discarded – undo
3487 3487
 			<?php }?>
3488 3488
 			} <?php echo $inside_elements; ?> ),
3489 3489
 			<?php
3490
-			echo $after_elements;
3490
+            echo $after_elements;
3491 3491
 
3492
-		}
3492
+        }
3493 3493
 
3494
-		/**
3495
-		 * Convert an array of attributes to block string.
3496
-		 *
3497
-		 * @param $custom_attributes
3498
-		 *
3499
-		 * @return string
3500
-		 *@todo there is prob a faster way to do this, also we could add some validation here.
3501
-		 *
3502
-		 */
3503
-		public function array_to_attributes( $custom_attributes, $html = false ) {
3504
-			$attributes = '';
3505
-			if ( ! empty( $custom_attributes ) ) {
3506
-
3507
-				foreach ( $custom_attributes as $key => $val ) {
3508
-					if(is_array($val)){
3509
-						$attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
3510
-					}else{
3511
-						$attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
3512
-					}
3513
-				}
3494
+        /**
3495
+         * Convert an array of attributes to block string.
3496
+         *
3497
+         * @param $custom_attributes
3498
+         *
3499
+         * @return string
3500
+         *@todo there is prob a faster way to do this, also we could add some validation here.
3501
+         *
3502
+         */
3503
+        public function array_to_attributes( $custom_attributes, $html = false ) {
3504
+            $attributes = '';
3505
+            if ( ! empty( $custom_attributes ) ) {
3514 3506
 
3515
-			}
3507
+                foreach ( $custom_attributes as $key => $val ) {
3508
+                    if(is_array($val)){
3509
+                        $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
3510
+                    }else{
3511
+                        $attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
3512
+                    }
3513
+                }
3516 3514
 
3517
-			return $attributes;
3518
-		}
3515
+            }
3516
+
3517
+            return $attributes;
3518
+        }
3519 3519
 
3520 3520
 
3521 3521
 
3522
-		/**
3523
-		 * A self looping function to create the output for JS block elements.
3524
-		 *
3525
-		 * This is what is output in the WP Editor visual view.
3526
-		 *
3527
-		 * @param $args
3528
-		 */
3529
-		public function block_element( $args, $save = false ) {
3522
+        /**
3523
+         * A self looping function to create the output for JS block elements.
3524
+         *
3525
+         * This is what is output in the WP Editor visual view.
3526
+         *
3527
+         * @param $args
3528
+         */
3529
+        public function block_element( $args, $save = false ) {
3530 3530
 
3531 3531
 
3532
-			if ( ! empty( $args ) ) {
3533
-				foreach ( $args as $element => $new_args ) {
3532
+            if ( ! empty( $args ) ) {
3533
+                foreach ( $args as $element => $new_args ) {
3534 3534
 
3535
-					if ( is_array( $new_args ) ) { // its an element
3535
+                    if ( is_array( $new_args ) ) { // its an element
3536 3536
 
3537 3537
 
3538
-						if ( isset( $new_args['element'] ) ) {
3538
+                        if ( isset( $new_args['element'] ) ) {
3539 3539
 
3540
-							if ( isset( $new_args['element_require'] ) ) {
3541
-								echo str_replace( array(
3542
-										"'+",
3543
-										"+'"
3544
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
3545
-								unset( $new_args['element_require'] );
3546
-							}
3540
+                            if ( isset( $new_args['element_require'] ) ) {
3541
+                                echo str_replace( array(
3542
+                                        "'+",
3543
+                                        "+'"
3544
+                                    ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
3545
+                                unset( $new_args['element_require'] );
3546
+                            }
3547 3547
 
3548 3548
                             if($new_args['element']=='InnerBlocks'){
3549 3549
                                 echo "\n el( InnerBlocks, {";
3550 3550
                             }elseif($new_args['element']=='innerBlocksProps'){
3551 3551
                                 $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
3552
-                              //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
3552
+                                //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
3553 3553
 //                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
3554 3554
                                 echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
3555 3555
                                 echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
@@ -3559,74 +3559,74 @@  discard block
 block discarded – undo
3559 3559
                                 echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
3560 3560
                             //    echo '###';
3561 3561
 
3562
-                              //  echo '###';
3562
+                                //  echo '###';
3563 3563
                             }elseif($new_args['element']=='BlocksProps'){
3564 3564
 
3565
-								if ( isset($new_args['if_inner_element']) ) {
3566
-									$element = $new_args['if_inner_element'];
3567
-								}else {
3568
-									$element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
3569
-								}
3565
+                                if ( isset($new_args['if_inner_element']) ) {
3566
+                                    $element = $new_args['if_inner_element'];
3567
+                                }else {
3568
+                                    $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
3569
+                                }
3570 3570
 
3571
-								unset($new_args['inner_element']);
3571
+                                unset($new_args['inner_element']);
3572 3572
                                 echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
3573 3573
                                 echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
3574 3574
 
3575 3575
 
3576
-                               // echo "} ),";
3576
+                                // echo "} ),";
3577 3577
 
3578 3578
                             }else{
3579 3579
                                 echo "\n el( '" . $new_args['element'] . "', {";
3580 3580
                             }
3581 3581
 
3582 3582
 
3583
-							// get the attributes
3584
-							foreach ( $new_args as $new_key => $new_value ) {
3583
+                            // get the attributes
3584
+                            foreach ( $new_args as $new_key => $new_value ) {
3585 3585
 
3586 3586
 
3587
-								if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
3588
-									// do nothing
3589
-								} else {
3590
-									echo $this->block_element( array( $new_key => $new_value ),$save );
3591
-								}
3592
-							}
3587
+                                if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
3588
+                                    // do nothing
3589
+                                } else {
3590
+                                    echo $this->block_element( array( $new_key => $new_value ),$save );
3591
+                                }
3592
+                            }
3593 3593
 
3594
-							echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
3594
+                            echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
3595 3595
 
3596
-							// get the content
3597
-							$first_item = 0;
3598
-							foreach ( $new_args as $new_key => $new_value ) {
3599
-								if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
3596
+                            // get the content
3597
+                            $first_item = 0;
3598
+                            foreach ( $new_args as $new_key => $new_value ) {
3599
+                                if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
3600 3600
 
3601
-									if ( $new_key === 'content' ) {
3602
-										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
3603
-									}else if ( $new_key === 'if_content' ) {
3604
-										echo  $this->block_props_replace(  $new_value  );
3605
-									}
3601
+                                    if ( $new_key === 'content' ) {
3602
+                                        echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
3603
+                                    }else if ( $new_key === 'if_content' ) {
3604
+                                        echo  $this->block_props_replace(  $new_value  );
3605
+                                    }
3606 3606
 
3607
-									if ( is_array( $new_value ) ) {
3607
+                                    if ( is_array( $new_value ) ) {
3608 3608
 
3609
-										if ( isset( $new_value['element_require'] ) ) {
3610
-											echo str_replace( array(
3611
-													"'+",
3612
-													"+'"
3613
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
3614
-											unset( $new_value['element_require'] );
3615
-										}
3609
+                                        if ( isset( $new_value['element_require'] ) ) {
3610
+                                            echo str_replace( array(
3611
+                                                    "'+",
3612
+                                                    "+'"
3613
+                                                ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
3614
+                                            unset( $new_value['element_require'] );
3615
+                                        }
3616 3616
 
3617
-										if ( isset( $new_value['element_repeat'] ) ) {
3618
-											$x = 1;
3619
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
3620
-												$this->block_element( array( '' => $new_value ),$save );
3621
-												$x ++;
3622
-											}
3623
-										} else {
3624
-											$this->block_element( array( '' => $new_value ),$save );
3625
-										}
3626
-									}
3627
-									$first_item ++;
3628
-								}
3629
-							}
3617
+                                        if ( isset( $new_value['element_repeat'] ) ) {
3618
+                                            $x = 1;
3619
+                                            while ( $x <= absint( $new_value['element_repeat'] ) ) {
3620
+                                                $this->block_element( array( '' => $new_value ),$save );
3621
+                                                $x ++;
3622
+                                            }
3623
+                                        } else {
3624
+                                            $this->block_element( array( '' => $new_value ),$save );
3625
+                                        }
3626
+                                    }
3627
+                                    $first_item ++;
3628
+                                }
3629
+                            }
3630 3630
 
3631 3631
                             if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
3632 3632
                                 echo "))";// end content
@@ -3635,517 +3635,517 @@  discard block
 block discarded – undo
3635 3635
                             }
3636 3636
 
3637 3637
 
3638
-							echo ", \n";
3638
+                            echo ", \n";
3639 3639
 
3640
-						}
3641
-					} else {
3640
+                        }
3641
+                    } else {
3642 3642
 
3643
-						if ( substr( $element, 0, 3 ) === "if_" ) {
3644
-							$extra = '';
3645
-							if( strpos($new_args, '[%WrapClass%]') !== false ){
3646
-								$new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
3647
-								$new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
3648
-							}
3649
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
3650
-						} elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
3643
+                        if ( substr( $element, 0, 3 ) === "if_" ) {
3644
+                            $extra = '';
3645
+                            if( strpos($new_args, '[%WrapClass%]') !== false ){
3646
+                                $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
3647
+                                $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
3648
+                            }
3649
+                            echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
3650
+                        } elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
3651 3651
                             $new_args = str_replace('[%WrapStyle%]','',$new_args);
3652 3652
                             echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
3653 3653
 //                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
3654
-						} elseif ( $element == 'style' ) {
3655
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
3656
-						} elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
3654
+                        } elseif ( $element == 'style' ) {
3655
+                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
3656
+                        } elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
3657 3657
                             $new_args = str_replace('[%WrapClass%]','',$new_args);
3658 3658
                             echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
3659
-						} elseif ( $element == 'template' && $new_args ) {
3660
-							echo $element . ": $new_args,";
3661
-						} else {
3662
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
3663
-						}
3659
+                        } elseif ( $element == 'template' && $new_args ) {
3660
+                            echo $element . ": $new_args,";
3661
+                        } else {
3662
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
3663
+                        }
3664 3664
 
3665
-					}
3666
-				}
3667
-			}
3668
-		}
3665
+                    }
3666
+                }
3667
+            }
3668
+        }
3669 3669
 
3670
-		/**
3671
-		 * Replace block attributes placeholders with the proper naming.
3672
-		 *
3673
-		 * @param $string
3674
-		 *
3675
-		 * @return mixed
3676
-		 */
3677
-		public function block_props_replace( $string, $no_wrap = false ) {
3678
-
3679
-			if ( $no_wrap ) {
3680
-				$string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
3681
-			} else {
3682
-				$string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
3683
-			}
3670
+        /**
3671
+         * Replace block attributes placeholders with the proper naming.
3672
+         *
3673
+         * @param $string
3674
+         *
3675
+         * @return mixed
3676
+         */
3677
+        public function block_props_replace( $string, $no_wrap = false ) {
3684 3678
 
3685
-			return $string;
3686
-		}
3679
+            if ( $no_wrap ) {
3680
+                $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
3681
+            } else {
3682
+                $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
3683
+            }
3687 3684
 
3688
-		/**
3689
-		 * Outputs the content of the widget
3690
-		 *
3691
-		 * @param array $args
3692
-		 * @param array $instance
3693
-		 */
3694
-		public function widget( $args, $instance ) {
3695
-
3696
-			// get the filtered values
3697
-			$argument_values = $this->argument_values( $instance );
3698
-			$argument_values = $this->string_to_bool( $argument_values );
3699
-			$output          = $this->output( $argument_values, $args );
3700
-
3701
-			$no_wrap = false;
3702
-			if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
3703
-				$no_wrap = true;
3704
-			}
3685
+            return $string;
3686
+        }
3705 3687
 
3706
-			ob_start();
3707
-			if ( $output && ! $no_wrap ) {
3688
+        /**
3689
+         * Outputs the content of the widget
3690
+         *
3691
+         * @param array $args
3692
+         * @param array $instance
3693
+         */
3694
+        public function widget( $args, $instance ) {
3708 3695
 
3709
-				$class_original = $this->options['widget_ops']['classname'];
3710
-				$class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
3696
+            // get the filtered values
3697
+            $argument_values = $this->argument_values( $instance );
3698
+            $argument_values = $this->string_to_bool( $argument_values );
3699
+            $output          = $this->output( $argument_values, $args );
3711 3700
 
3712
-				// Before widget
3713
-				$before_widget = $args['before_widget'];
3714
-				$before_widget = str_replace($class_original,$class,$before_widget);
3715
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
3716
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
3701
+            $no_wrap = false;
3702
+            if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
3703
+                $no_wrap = true;
3704
+            }
3717 3705
 
3718
-				// After widget
3719
-				$after_widget = $args['after_widget'];
3720
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
3721
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
3706
+            ob_start();
3707
+            if ( $output && ! $no_wrap ) {
3722 3708
 
3723
-				echo $before_widget;
3724
-				// elementor strips the widget wrapping div so we check for and add it back if needed
3725
-				if ( $this->is_elementor_widget_output() ) {
3726
-					// Filter class & attrs for elementor widget output.
3727
-					$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
3728
-					$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
3709
+                $class_original = $this->options['widget_ops']['classname'];
3710
+                $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
3729 3711
 
3730
-					$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
3731
-					$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
3712
+                // Before widget
3713
+                $before_widget = $args['before_widget'];
3714
+                $before_widget = str_replace($class_original,$class,$before_widget);
3715
+                $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
3716
+                $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
3732 3717
 
3733
-					echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
3734
-				}
3735
-				echo $this->output_title( $args, $instance );
3736
-				echo $output;
3737
-				if ( $this->is_elementor_widget_output() ) {
3738
-					echo "</span>";
3739
-				}
3740
-				echo $after_widget;
3741
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
3742
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
3743
-				echo $output;
3744
-			} elseif ( $output && $no_wrap ) {
3745
-				echo $output;
3746
-			}
3747
-			$output = ob_get_clean();
3718
+                // After widget
3719
+                $after_widget = $args['after_widget'];
3720
+                $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
3721
+                $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
3748 3722
 
3749
-			$output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
3723
+                echo $before_widget;
3724
+                // elementor strips the widget wrapping div so we check for and add it back if needed
3725
+                if ( $this->is_elementor_widget_output() ) {
3726
+                    // Filter class & attrs for elementor widget output.
3727
+                    $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
3728
+                    $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
3750 3729
 
3751
-			echo $output;
3752
-		}
3730
+                    $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
3731
+                    $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
3753 3732
 
3754
-		/**
3755
-		 * Tests if the current output is inside a elementor container.
3756
-		 *
3757
-		 * @return bool
3758
-		 *@since 1.0.4
3759
-		 */
3760
-		public function is_elementor_widget_output() {
3761
-			$result = false;
3762
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
3763
-				$result = true;
3764
-			}
3733
+                    echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
3734
+                }
3735
+                echo $this->output_title( $args, $instance );
3736
+                echo $output;
3737
+                if ( $this->is_elementor_widget_output() ) {
3738
+                    echo "</span>";
3739
+                }
3740
+                echo $after_widget;
3741
+            } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
3742
+                $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
3743
+                echo $output;
3744
+            } elseif ( $output && $no_wrap ) {
3745
+                echo $output;
3746
+            }
3747
+            $output = ob_get_clean();
3765 3748
 
3766
-			return $result;
3767
-		}
3749
+            $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
3768 3750
 
3769
-		/**
3770
-		 * Tests if the current output is inside a elementor preview.
3771
-		 *
3772
-		 * @return bool
3773
-		 *@since 1.0.4
3774
-		 */
3775
-		public function is_elementor_preview() {
3776
-			$result = false;
3777
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
3778
-				$result = true;
3779
-			}
3751
+            echo $output;
3752
+        }
3780 3753
 
3781
-			return $result;
3782
-		}
3754
+        /**
3755
+         * Tests if the current output is inside a elementor container.
3756
+         *
3757
+         * @return bool
3758
+         *@since 1.0.4
3759
+         */
3760
+        public function is_elementor_widget_output() {
3761
+            $result = false;
3762
+            if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
3763
+                $result = true;
3764
+            }
3783 3765
 
3784
-		/**
3785
-		 * Tests if the current output is inside a Divi preview.
3786
-		 *
3787
-		 * @return bool
3788
-		 *@since 1.0.6
3789
-		 */
3790
-		public function is_divi_preview() {
3791
-			$result = false;
3792
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
3793
-				$result = true;
3794
-			}
3766
+            return $result;
3767
+        }
3795 3768
 
3796
-			return $result;
3797
-		}
3769
+        /**
3770
+         * Tests if the current output is inside a elementor preview.
3771
+         *
3772
+         * @return bool
3773
+         *@since 1.0.4
3774
+         */
3775
+        public function is_elementor_preview() {
3776
+            $result = false;
3777
+            if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
3778
+                $result = true;
3779
+            }
3798 3780
 
3799
-		/**
3800
-		 * Tests if the current output is inside a Beaver builder preview.
3801
-		 *
3802
-		 * @return bool
3803
-		 *@since 1.0.6
3804
-		 */
3805
-		public function is_beaver_preview() {
3806
-			$result = false;
3807
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
3808
-				$result = true;
3809
-			}
3781
+            return $result;
3782
+        }
3810 3783
 
3811
-			return $result;
3812
-		}
3784
+        /**
3785
+         * Tests if the current output is inside a Divi preview.
3786
+         *
3787
+         * @return bool
3788
+         *@since 1.0.6
3789
+         */
3790
+        public function is_divi_preview() {
3791
+            $result = false;
3792
+            if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
3793
+                $result = true;
3794
+            }
3813 3795
 
3814
-		/**
3815
-		 * Tests if the current output is inside a siteorigin builder preview.
3816
-		 *
3817
-		 * @return bool
3818
-		 *@since 1.0.6
3819
-		 */
3820
-		public function is_siteorigin_preview() {
3821
-			$result = false;
3822
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
3823
-				$result = true;
3824
-			}
3796
+            return $result;
3797
+        }
3825 3798
 
3826
-			return $result;
3827
-		}
3799
+        /**
3800
+         * Tests if the current output is inside a Beaver builder preview.
3801
+         *
3802
+         * @return bool
3803
+         *@since 1.0.6
3804
+         */
3805
+        public function is_beaver_preview() {
3806
+            $result = false;
3807
+            if ( isset( $_REQUEST['fl_builder'] ) ) {
3808
+                $result = true;
3809
+            }
3828 3810
 
3829
-		/**
3830
-		 * Tests if the current output is inside a cornerstone builder preview.
3831
-		 *
3832
-		 * @return bool
3833
-		 *@since 1.0.8
3834
-		 */
3835
-		public function is_cornerstone_preview() {
3836
-			$result = false;
3837
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
3838
-				$result = true;
3839
-			}
3811
+            return $result;
3812
+        }
3840 3813
 
3841
-			return $result;
3842
-		}
3814
+        /**
3815
+         * Tests if the current output is inside a siteorigin builder preview.
3816
+         *
3817
+         * @return bool
3818
+         *@since 1.0.6
3819
+         */
3820
+        public function is_siteorigin_preview() {
3821
+            $result = false;
3822
+            if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
3823
+                $result = true;
3824
+            }
3843 3825
 
3844
-		/**
3845
-		 * Tests if the current output is inside a fusion builder preview.
3846
-		 *
3847
-		 * @return bool
3848
-		 *@since 1.1.0
3849
-		 */
3850
-		public function is_fusion_preview() {
3851
-			$result = false;
3852
-			if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
3853
-				$result = true;
3854
-			}
3826
+            return $result;
3827
+        }
3855 3828
 
3856
-			return $result;
3857
-		}
3829
+        /**
3830
+         * Tests if the current output is inside a cornerstone builder preview.
3831
+         *
3832
+         * @return bool
3833
+         *@since 1.0.8
3834
+         */
3835
+        public function is_cornerstone_preview() {
3836
+            $result = false;
3837
+            if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
3838
+                $result = true;
3839
+            }
3858 3840
 
3859
-		/**
3860
-		 * Tests if the current output is inside a Oxygen builder preview.
3861
-		 *
3862
-		 * @return bool
3863
-		 *@since 1.0.18
3864
-		 */
3865
-		public function is_oxygen_preview() {
3866
-			$result = false;
3867
-			if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
3868
-				$result = true;
3869
-			}
3841
+            return $result;
3842
+        }
3870 3843
 
3871
-			return $result;
3872
-		}
3844
+        /**
3845
+         * Tests if the current output is inside a fusion builder preview.
3846
+         *
3847
+         * @return bool
3848
+         *@since 1.1.0
3849
+         */
3850
+        public function is_fusion_preview() {
3851
+            $result = false;
3852
+            if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
3853
+                $result = true;
3854
+            }
3873 3855
 
3874
-		/**
3875
-		 * General function to check if we are in a preview situation.
3876
-		 *
3877
-		 * @return bool
3878
-		 *@since 1.0.6
3879
-		 */
3880
-		public function is_preview() {
3881
-			$preview = false;
3882
-			if ( $this->is_divi_preview() ) {
3883
-				$preview = true;
3884
-			} elseif ( $this->is_elementor_preview() ) {
3885
-				$preview = true;
3886
-			} elseif ( $this->is_beaver_preview() ) {
3887
-				$preview = true;
3888
-			} elseif ( $this->is_siteorigin_preview() ) {
3889
-				$preview = true;
3890
-			} elseif ( $this->is_cornerstone_preview() ) {
3891
-				$preview = true;
3892
-			} elseif ( $this->is_fusion_preview() ) {
3893
-				$preview = true;
3894
-			} elseif ( $this->is_oxygen_preview() ) {
3895
-				$preview = true;
3896
-			} elseif( $this->is_block_content_call() ) {
3897
-				$preview = true;
3898
-			}
3856
+            return $result;
3857
+        }
3899 3858
 
3900
-			return $preview;
3901
-		}
3859
+        /**
3860
+         * Tests if the current output is inside a Oxygen builder preview.
3861
+         *
3862
+         * @return bool
3863
+         *@since 1.0.18
3864
+         */
3865
+        public function is_oxygen_preview() {
3866
+            $result = false;
3867
+            if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
3868
+                $result = true;
3869
+            }
3902 3870
 
3903
-		/**
3904
-		 * Output the super title.
3905
-		 *
3906
-		 * @param $args
3907
-		 * @param array $instance
3908
-		 *
3909
-		 * @return string
3910
-		 */
3911
-		public function output_title( $args, $instance = array() ) {
3912
-			$output = '';
3913
-			if ( ! empty( $instance['title'] ) ) {
3914
-				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
3915
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
3916
-
3917
-				if(empty($instance['widget_title_tag'])){
3918
-					$output = $args['before_title'] . $title . $args['after_title'];
3919
-				}else{
3920
-					$title_tag = esc_attr( $instance['widget_title_tag'] );
3921
-
3922
-					// classes
3923
-					$title_classes = array();
3924
-					$title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
3925
-					$title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
3926
-					$title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
3927
-					$title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
3928
-					$title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
3929
-					$title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
3930
-					$title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
3931
-					$title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
3932
-					$title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
3933
-					$title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
3934
-					$title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
3935
-					$title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
3936
-					$title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
3937
-
3938
-					$class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
3939
-					$output = "<$title_tag class='$class' >$title</$title_tag>";
3940
-				}
3871
+            return $result;
3872
+        }
3941 3873
 
3942
-			}
3874
+        /**
3875
+         * General function to check if we are in a preview situation.
3876
+         *
3877
+         * @return bool
3878
+         *@since 1.0.6
3879
+         */
3880
+        public function is_preview() {
3881
+            $preview = false;
3882
+            if ( $this->is_divi_preview() ) {
3883
+                $preview = true;
3884
+            } elseif ( $this->is_elementor_preview() ) {
3885
+                $preview = true;
3886
+            } elseif ( $this->is_beaver_preview() ) {
3887
+                $preview = true;
3888
+            } elseif ( $this->is_siteorigin_preview() ) {
3889
+                $preview = true;
3890
+            } elseif ( $this->is_cornerstone_preview() ) {
3891
+                $preview = true;
3892
+            } elseif ( $this->is_fusion_preview() ) {
3893
+                $preview = true;
3894
+            } elseif ( $this->is_oxygen_preview() ) {
3895
+                $preview = true;
3896
+            } elseif( $this->is_block_content_call() ) {
3897
+                $preview = true;
3898
+            }
3943 3899
 
3944
-			return $output;
3945
-		}
3900
+            return $preview;
3901
+        }
3902
+
3903
+        /**
3904
+         * Output the super title.
3905
+         *
3906
+         * @param $args
3907
+         * @param array $instance
3908
+         *
3909
+         * @return string
3910
+         */
3911
+        public function output_title( $args, $instance = array() ) {
3912
+            $output = '';
3913
+            if ( ! empty( $instance['title'] ) ) {
3914
+                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
3915
+                $title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
3916
+
3917
+                if(empty($instance['widget_title_tag'])){
3918
+                    $output = $args['before_title'] . $title . $args['after_title'];
3919
+                }else{
3920
+                    $title_tag = esc_attr( $instance['widget_title_tag'] );
3921
+
3922
+                    // classes
3923
+                    $title_classes = array();
3924
+                    $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
3925
+                    $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
3926
+                    $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
3927
+                    $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
3928
+                    $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
3929
+                    $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
3930
+                    $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
3931
+                    $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
3932
+                    $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
3933
+                    $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
3934
+                    $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
3935
+                    $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
3936
+                    $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
3937
+
3938
+                    $class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
3939
+                    $output = "<$title_tag class='$class' >$title</$title_tag>";
3940
+                }
3941
+
3942
+            }
3946 3943
 
3947
-		/**
3948
-		 * Outputs the options form inputs for the widget.
3949
-		 *
3950
-		 * @param array $instance The widget options.
3951
-		 */
3952
-		public function form( $instance ) {
3944
+            return $output;
3945
+        }
3946
+
3947
+        /**
3948
+         * Outputs the options form inputs for the widget.
3949
+         *
3950
+         * @param array $instance The widget options.
3951
+         */
3952
+        public function form( $instance ) {
3953 3953
 
3954
-			// set widget instance
3955
-			$this->instance = $instance;
3954
+            // set widget instance
3955
+            $this->instance = $instance;
3956 3956
 
3957
-			// set it as a SD widget
3958
-			echo $this->widget_advanced_toggle();
3957
+            // set it as a SD widget
3958
+            echo $this->widget_advanced_toggle();
3959 3959
 
3960
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
3961
-			$arguments_raw = $this->get_arguments();
3960
+            echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
3961
+            $arguments_raw = $this->get_arguments();
3962 3962
 
3963
-			if ( is_array( $arguments_raw ) ) {
3963
+            if ( is_array( $arguments_raw ) ) {
3964 3964
 
3965
-				$arguments = $this->group_arguments( $arguments_raw );
3965
+                $arguments = $this->group_arguments( $arguments_raw );
3966 3966
 
3967
-				// Do we have sections?
3968
-				$has_sections = $arguments == $arguments_raw ? false : true;
3967
+                // Do we have sections?
3968
+                $has_sections = $arguments == $arguments_raw ? false : true;
3969 3969
 
3970 3970
 
3971
-				if ( $has_sections ) {
3972
-					$panel_count = 0;
3973
-					foreach ( $arguments as $key => $args ) {
3971
+                if ( $has_sections ) {
3972
+                    $panel_count = 0;
3973
+                    foreach ( $arguments as $key => $args ) {
3974 3974
 
3975
-						?>
3975
+                        ?>
3976 3976
 						<script>
3977 3977
 							//							jQuery(this).find("i").toggleClass("fas fa-chevron-up fas fa-chevron-down");jQuery(this).next().toggle();
3978 3978
 						</script>
3979 3979
 						<?php
3980 3980
 
3981
-						$hide       = $panel_count ? ' style="display:none;" ' : '';
3982
-						$icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
3983
-						echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
3984
-						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
3981
+                        $hide       = $panel_count ? ' style="display:none;" ' : '';
3982
+                        $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
3983
+                        echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
3984
+                        echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
3985 3985
 
3986
-						foreach ( $args as $k => $a ) {
3986
+                        foreach ( $args as $k => $a ) {
3987 3987
 
3988
-							$this->widget_inputs_row_start($k, $a);
3989
-							$this->widget_inputs( $a, $instance );
3990
-							$this->widget_inputs_row_end($k, $a);
3988
+                            $this->widget_inputs_row_start($k, $a);
3989
+                            $this->widget_inputs( $a, $instance );
3990
+                            $this->widget_inputs_row_end($k, $a);
3991 3991
 
3992
-						}
3992
+                        }
3993 3993
 
3994
-						echo "</div>";
3994
+                        echo "</div>";
3995 3995
 
3996
-						$panel_count ++;
3996
+                        $panel_count ++;
3997 3997
 
3998
-					}
3999
-				} else {
4000
-					foreach ( $arguments as $key => $args ) {
4001
-						$this->widget_inputs_row_start($key, $args);
4002
-						$this->widget_inputs( $args, $instance );
4003
-						$this->widget_inputs_row_end($key, $args);
4004
-					}
4005
-				}
3998
+                    }
3999
+                } else {
4000
+                    foreach ( $arguments as $key => $args ) {
4001
+                        $this->widget_inputs_row_start($key, $args);
4002
+                        $this->widget_inputs( $args, $instance );
4003
+                        $this->widget_inputs_row_end($key, $args);
4004
+                    }
4005
+                }
4006 4006
 
4007
-			}
4008
-		}
4007
+            }
4008
+        }
4009 4009
 
4010
-		public function widget_inputs_row_start($key, $args){
4011
-			if(!empty($args['row'])){
4012
-				// maybe open
4013
-				if(!empty($args['row']['open'])){
4014
-					?>
4010
+        public function widget_inputs_row_start($key, $args){
4011
+            if(!empty($args['row'])){
4012
+                // maybe open
4013
+                if(!empty($args['row']['open'])){
4014
+                    ?>
4015 4015
 					<div class='bsui sd-argument ' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php if ( !empty($args['row']['element_require'])) {
4016
-						echo $this->convert_element_require( $args['row']['element_require'] );
4017
-					} ?>'>
4016
+                        echo $this->convert_element_require( $args['row']['element_require'] );
4017
+                    } ?>'>
4018 4018
 					<?php if(!empty($args['row']['title'])){ ?>
4019 4019
 					<label class="mb-0 "><?php echo esc_attr( $args['row']['title'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label>
4020 4020
 					<?php }?>
4021 4021
 					<div class='row <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>'>
4022 4022
 					<div class='col pr-2'>
4023 4023
 					<?php
4024
-				}elseif(!empty($args['row']['close'])){
4025
-					echo "<div class='col pl-0'>";
4026
-				}else{
4027
-					echo "<div class='col pl-0 pr-2'>";
4028
-				}
4029
-			}
4030
-		}
4024
+                }elseif(!empty($args['row']['close'])){
4025
+                    echo "<div class='col pl-0'>";
4026
+                }else{
4027
+                    echo "<div class='col pl-0 pr-2'>";
4028
+                }
4029
+            }
4030
+        }
4031 4031
 
4032
-		public function widget_inputs_row_end($key, $args){
4032
+        public function widget_inputs_row_end($key, $args){
4033 4033
 
4034
-			if(!empty($args['row'])){
4035
-				// maybe close
4036
-				if(!empty($args['row']['close'])){
4037
-					echo "</div></div>";
4038
-				}
4034
+            if(!empty($args['row'])){
4035
+                // maybe close
4036
+                if(!empty($args['row']['close'])){
4037
+                    echo "</div></div>";
4038
+                }
4039 4039
 
4040
-				echo "</div>";
4041
-			}
4042
-		}
4040
+                echo "</div>";
4041
+            }
4042
+        }
4043 4043
 
4044
-		/**
4045
-		 * Get the hidden input that when added makes the advanced button show on widget settings.
4046
-		 *
4047
-		 * @return string
4048
-		 */
4049
-		public function widget_advanced_toggle() {
4050
-
4051
-			$output = '';
4052
-			if ( $this->block_show_advanced() ) {
4053
-				$val = 1;
4054
-			} else {
4055
-				$val = 0;
4056
-			}
4044
+        /**
4045
+         * Get the hidden input that when added makes the advanced button show on widget settings.
4046
+         *
4047
+         * @return string
4048
+         */
4049
+        public function widget_advanced_toggle() {
4057 4050
 
4058
-			$output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
4051
+            $output = '';
4052
+            if ( $this->block_show_advanced() ) {
4053
+                $val = 1;
4054
+            } else {
4055
+                $val = 0;
4056
+            }
4059 4057
 
4060
-			return $output;
4061
-		}
4058
+            $output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
4062 4059
 
4063
-		/**
4064
-		 * Convert require element.
4065
-		 *
4066
-		 * @param string $input Input element.
4067
-		 *
4068
-		 * @return string $output
4069
-		 *@since 1.0.0
4070
-		 *
4071
-		 */
4072
-		public function convert_element_require( $input ) {
4073
-
4074
-			$input = str_replace( "'", '"', $input );// we only want double quotes
4075
-
4076
-			$output = esc_attr( str_replace( array( "[%", "%]" ), array(
4077
-				"jQuery(form).find('[data-argument=\"",
4078
-				"\"]').find('input,select,textarea').val()"
4079
-			), $input ) );
4080
-
4081
-			return $output;
4082
-		}
4060
+            return $output;
4061
+        }
4083 4062
 
4084
-		/**
4085
-		 * Builds the inputs for the widget options.
4086
-		 *
4087
-		 * @param $args
4088
-		 * @param $instance
4089
-		 */
4090
-		public function widget_inputs( $args, $instance ) {
4091
-
4092
-			$class             = "";
4093
-			$element_require   = "";
4094
-			$custom_attributes = "";
4095
-
4096
-			// get value
4097
-			if ( isset( $instance[ $args['name'] ] ) ) {
4098
-				$value = $instance[ $args['name'] ];
4099
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4100
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4101
-			} else {
4102
-				$value = '';
4103
-			}
4063
+        /**
4064
+         * Convert require element.
4065
+         *
4066
+         * @param string $input Input element.
4067
+         *
4068
+         * @return string $output
4069
+         *@since 1.0.0
4070
+         *
4071
+         */
4072
+        public function convert_element_require( $input ) {
4104 4073
 
4105
-			// get placeholder
4106
-			if ( ! empty( $args['placeholder'] ) ) {
4107
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4108
-			} else {
4109
-				$placeholder = '';
4110
-			}
4074
+            $input = str_replace( "'", '"', $input );// we only want double quotes
4111 4075
 
4112
-			// get if advanced
4113
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4114
-				$class .= " sd-advanced-setting ";
4115
-			}
4076
+            $output = esc_attr( str_replace( array( "[%", "%]" ), array(
4077
+                "jQuery(form).find('[data-argument=\"",
4078
+                "\"]').find('input,select,textarea').val()"
4079
+            ), $input ) );
4116 4080
 
4117
-			// element_require
4118
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4119
-				$element_require = $args['element_require'];
4120
-			}
4081
+            return $output;
4082
+        }
4121 4083
 
4122
-			// custom_attributes
4123
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4124
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4125
-			}
4084
+        /**
4085
+         * Builds the inputs for the widget options.
4086
+         *
4087
+         * @param $args
4088
+         * @param $instance
4089
+         */
4090
+        public function widget_inputs( $args, $instance ) {
4091
+
4092
+            $class             = "";
4093
+            $element_require   = "";
4094
+            $custom_attributes = "";
4095
+
4096
+            // get value
4097
+            if ( isset( $instance[ $args['name'] ] ) ) {
4098
+                $value = $instance[ $args['name'] ];
4099
+            } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4100
+                $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4101
+            } else {
4102
+                $value = '';
4103
+            }
4104
+
4105
+            // get placeholder
4106
+            if ( ! empty( $args['placeholder'] ) ) {
4107
+                $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4108
+            } else {
4109
+                $placeholder = '';
4110
+            }
4126 4111
 
4112
+            // get if advanced
4113
+            if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4114
+                $class .= " sd-advanced-setting ";
4115
+            }
4127 4116
 
4128
-			// before wrapper
4129
-			?>
4117
+            // element_require
4118
+            if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4119
+                $element_require = $args['element_require'];
4120
+            }
4121
+
4122
+            // custom_attributes
4123
+            if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4124
+                $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4125
+            }
4126
+
4127
+
4128
+            // before wrapper
4129
+            ?>
4130 4130
 			<p class="sd-argument <?php echo esc_attr( $class ); ?>"
4131 4131
 			data-argument='<?php echo esc_attr( $args['name'] ); ?>'
4132 4132
 			data-element_require='<?php if ( $element_require ) {
4133
-				echo $this->convert_element_require( $element_require );
4134
-			} ?>'
4133
+                echo $this->convert_element_require( $element_require );
4134
+            } ?>'
4135 4135
 			>
4136 4136
 			<?php
4137 4137
 
4138 4138
 
4139
-			switch ( $args['type'] ) {
4140
-				//array('text','password','number','email','tel','url','color')
4141
-				case "text":
4142
-				case "password":
4143
-				case "number":
4144
-				case "email":
4145
-				case "tel":
4146
-				case "url":
4147
-				case "color":
4148
-					?>
4139
+            switch ( $args['type'] ) {
4140
+                //array('text','password','number','email','tel','url','color')
4141
+                case "text":
4142
+                case "password":
4143
+                case "number":
4144
+                case "email":
4145
+                case "tel":
4146
+                case "url":
4147
+                case "color":
4148
+                    ?>
4149 4149
 					<label
4150 4150
 						for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4151 4151
 					<input <?php echo $placeholder; ?> class="widefat"
@@ -4156,47 +4156,47 @@  discard block
 block discarded – undo
4156 4156
 						                               value="<?php echo esc_attr( $value ); ?>">
4157 4157
 					<?php
4158 4158
 
4159
-					break;
4160
-				case "select":
4161
-					$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4162
-					if ( $multiple ) {
4163
-						if ( empty( $value ) ) {
4164
-							$value = array();
4165
-						}
4166
-					}
4167
-					?>
4159
+                    break;
4160
+                case "select":
4161
+                    $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4162
+                    if ( $multiple ) {
4163
+                        if ( empty( $value ) ) {
4164
+                            $value = array();
4165
+                        }
4166
+                    }
4167
+                    ?>
4168 4168
 					<label
4169 4169
 						for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4170 4170
 					<select <?php echo $placeholder; ?> class="widefat"
4171 4171
 						<?php echo $custom_attributes; ?>
4172 4172
 						                                id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
4173 4173
 						                                name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) );
4174
-						                                if ( $multiple ) {
4175
-							                                echo "[]";
4176
-						                                } ?>"
4174
+                                                        if ( $multiple ) {
4175
+                                                            echo "[]";
4176
+                                                        } ?>"
4177 4177
 						<?php if ( $multiple ) {
4178
-							echo "multiple";
4179
-						} //@todo not implemented yet due to gutenberg not supporting it
4180
-						?>
4178
+                            echo "multiple";
4179
+                        } //@todo not implemented yet due to gutenberg not supporting it
4180
+                        ?>
4181 4181
 					>
4182 4182
 						<?php
4183 4183
 
4184
-						if ( ! empty( $args['options'] ) ) {
4185
-							foreach ( $args['options'] as $val => $label ) {
4186
-								if ( $multiple ) {
4187
-									$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4188
-								} else {
4189
-									$selected = selected( $value, $val, false );
4190
-								}
4191
-								echo "<option value='$val' " . $selected . ">$label</option>";
4192
-							}
4193
-						}
4194
-						?>
4184
+                        if ( ! empty( $args['options'] ) ) {
4185
+                            foreach ( $args['options'] as $val => $label ) {
4186
+                                if ( $multiple ) {
4187
+                                    $selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4188
+                                } else {
4189
+                                    $selected = selected( $value, $val, false );
4190
+                                }
4191
+                                echo "<option value='$val' " . $selected . ">$label</option>";
4192
+                            }
4193
+                        }
4194
+                        ?>
4195 4195
 					</select>
4196 4196
 					<?php
4197
-					break;
4198
-				case "checkbox":
4199
-					?>
4197
+                    break;
4198
+                case "checkbox":
4199
+                    ?>
4200 4200
 					<input <?php echo $placeholder; ?>
4201 4201
 						<?php checked( 1, $value, true ) ?>
4202 4202
 						<?php echo $custom_attributes; ?>
@@ -4206,9 +4206,9 @@  discard block
 block discarded – undo
4206 4206
 					<label
4207 4207
 						for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4208 4208
 					<?php
4209
-					break;
4210
-				case "textarea":
4211
-					?>
4209
+                    break;
4210
+                case "textarea":
4211
+                    ?>
4212 4212
 					<label
4213 4213
 						for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4214 4214
 					<textarea <?php echo $placeholder; ?> class="widefat"
@@ -4218,282 +4218,282 @@  discard block
 block discarded – undo
4218 4218
 					><?php echo esc_attr( $value ); ?></textarea>
4219 4219
 					<?php
4220 4220
 
4221
-					break;
4222
-				case "hidden":
4223
-					?>
4221
+                    break;
4222
+                case "hidden":
4223
+                    ?>
4224 4224
 					<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
4225 4225
 					       name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden"
4226 4226
 					       value="<?php echo esc_attr( $value ); ?>">
4227 4227
 					<?php
4228
-					break;
4229
-				default:
4230
-					echo "No input type found!"; // @todo we need to add more input types.
4231
-			}
4228
+                    break;
4229
+                default:
4230
+                    echo "No input type found!"; // @todo we need to add more input types.
4231
+            }
4232 4232
 
4233
-			// after wrapper
4234
-			?>
4233
+            // after wrapper
4234
+            ?>
4235 4235
 			</p>
4236 4236
 			<?php
4237 4237
 
4238 4238
 
4239
-		}
4239
+        }
4240 4240
 
4241
-		public function get_widget_icon($icon = 'box-top', $title = ''){
4242
-			if($icon=='box-top'){
4243
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4244
-			}elseif($icon=='box-right'){
4245
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4246
-			}elseif($icon=='box-bottom'){
4247
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4248
-			}elseif($icon=='box-left'){
4249
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4250
-			}
4251
-		}
4241
+        public function get_widget_icon($icon = 'box-top', $title = ''){
4242
+            if($icon=='box-top'){
4243
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4244
+            }elseif($icon=='box-right'){
4245
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4246
+            }elseif($icon=='box-bottom'){
4247
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4248
+            }elseif($icon=='box-left'){
4249
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4250
+            }
4251
+        }
4252 4252
 
4253
-		/**
4254
-		 * Get the widget input description html.
4255
-		 *
4256
-		 * @param $args
4257
-		 *
4258
-		 * @return string
4259
-		 * @todo, need to make its own tooltip script
4260
-		 */
4261
-		public function widget_field_desc( $args ) {
4262
-
4263
-			$description = '';
4264
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
4265
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4266
-					$description = $this->desc_tip( $args['desc'] );
4267
-				} else {
4268
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4269
-				}
4270
-			}
4253
+        /**
4254
+         * Get the widget input description html.
4255
+         *
4256
+         * @param $args
4257
+         *
4258
+         * @return string
4259
+         * @todo, need to make its own tooltip script
4260
+         */
4261
+        public function widget_field_desc( $args ) {
4262
+
4263
+            $description = '';
4264
+            if ( isset( $args['desc'] ) && $args['desc'] ) {
4265
+                if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4266
+                    $description = $this->desc_tip( $args['desc'] );
4267
+                } else {
4268
+                    $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4269
+                }
4270
+            }
4271 4271
 
4272
-			return $description;
4273
-		}
4272
+            return $description;
4273
+        }
4274 4274
 
4275
-		/**
4276
-		 * Get the widget input title html.
4277
-		 *
4278
-		 * @param $args
4279
-		 *
4280
-		 * @return string
4281
-		 */
4282
-		public function widget_field_title( $args ) {
4283
-
4284
-			$title = '';
4285
-			if ( isset( $args['title'] ) && $args['title'] ) {
4286
-				if ( isset( $args['icon'] ) && $args['icon'] ) {
4287
-					$title = self::get_widget_icon( $args['icon'], $args['title']  );
4288
-				} else {
4289
-					$title = esc_attr($args['title']);
4290
-				}
4291
-			}
4275
+        /**
4276
+         * Get the widget input title html.
4277
+         *
4278
+         * @param $args
4279
+         *
4280
+         * @return string
4281
+         */
4282
+        public function widget_field_title( $args ) {
4283
+
4284
+            $title = '';
4285
+            if ( isset( $args['title'] ) && $args['title'] ) {
4286
+                if ( isset( $args['icon'] ) && $args['icon'] ) {
4287
+                    $title = self::get_widget_icon( $args['icon'], $args['title']  );
4288
+                } else {
4289
+                    $title = esc_attr($args['title']);
4290
+                }
4291
+            }
4292 4292
 
4293
-			return $title;
4294
-		}
4293
+            return $title;
4294
+        }
4295 4295
 
4296
-		/**
4297
-		 * Get the tool tip html.
4298
-		 *
4299
-		 * @param $tip
4300
-		 * @param bool $allow_html
4301
-		 *
4302
-		 * @return string
4303
-		 */
4304
-		function desc_tip( $tip, $allow_html = false ) {
4305
-			if ( $allow_html ) {
4306
-				$tip = $this->sanitize_tooltip( $tip );
4307
-			} else {
4308
-				$tip = esc_attr( $tip );
4309
-			}
4296
+        /**
4297
+         * Get the tool tip html.
4298
+         *
4299
+         * @param $tip
4300
+         * @param bool $allow_html
4301
+         *
4302
+         * @return string
4303
+         */
4304
+        function desc_tip( $tip, $allow_html = false ) {
4305
+            if ( $allow_html ) {
4306
+                $tip = $this->sanitize_tooltip( $tip );
4307
+            } else {
4308
+                $tip = esc_attr( $tip );
4309
+            }
4310 4310
 
4311
-			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
4312
-		}
4311
+            return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
4312
+        }
4313 4313
 
4314
-		/**
4315
-		 * Sanitize a string destined to be a tooltip.
4316
-		 *
4317
-		 * @param string $var
4318
-		 *
4319
-		 * @return string
4320
-		 */
4321
-		public function sanitize_tooltip( $var ) {
4322
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4323
-				'br'     => array(),
4324
-				'em'     => array(),
4325
-				'strong' => array(),
4326
-				'small'  => array(),
4327
-				'span'   => array(),
4328
-				'ul'     => array(),
4329
-				'li'     => array(),
4330
-				'ol'     => array(),
4331
-				'p'      => array(),
4332
-			) ) );
4333
-		}
4314
+        /**
4315
+         * Sanitize a string destined to be a tooltip.
4316
+         *
4317
+         * @param string $var
4318
+         *
4319
+         * @return string
4320
+         */
4321
+        public function sanitize_tooltip( $var ) {
4322
+            return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4323
+                'br'     => array(),
4324
+                'em'     => array(),
4325
+                'strong' => array(),
4326
+                'small'  => array(),
4327
+                'span'   => array(),
4328
+                'ul'     => array(),
4329
+                'li'     => array(),
4330
+                'ol'     => array(),
4331
+                'p'      => array(),
4332
+            ) ) );
4333
+        }
4334 4334
 
4335
-		/**
4336
-		 * Processing widget options on save
4337
-		 *
4338
-		 * @param array $new_instance The new options
4339
-		 * @param array $old_instance The previous options
4340
-		 *
4341
-		 * @return array
4342
-		 * @todo we should add some sanitation here.
4343
-		 */
4344
-		public function update( $new_instance, $old_instance ) {
4345
-
4346
-			//save the widget
4347
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
4348
-
4349
-			// set widget instance
4350
-			$this->instance = $instance;
4351
-
4352
-			if ( empty( $this->arguments ) ) {
4353
-				$this->get_arguments();
4354
-			}
4335
+        /**
4336
+         * Processing widget options on save
4337
+         *
4338
+         * @param array $new_instance The new options
4339
+         * @param array $old_instance The previous options
4340
+         *
4341
+         * @return array
4342
+         * @todo we should add some sanitation here.
4343
+         */
4344
+        public function update( $new_instance, $old_instance ) {
4355 4345
 
4356
-			// check for checkboxes
4357
-			if ( ! empty( $this->arguments ) ) {
4358
-				foreach ( $this->arguments as $argument ) {
4359
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4360
-						$instance[ $argument['name'] ] = '0';
4361
-					}
4362
-				}
4363
-			}
4346
+            //save the widget
4347
+            $instance = array_merge( (array) $old_instance, (array) $new_instance );
4364 4348
 
4365
-			return $instance;
4366
-		}
4349
+            // set widget instance
4350
+            $this->instance = $instance;
4367 4351
 
4368
-		/**
4369
-		 * Checks if the current call is a ajax call to get the block content.
4370
-		 *
4371
-		 * This can be used in your widget to return different content as the block content.
4372
-		 *
4373
-		 * @return bool
4374
-		 *@since 1.0.3
4375
-		 */
4376
-		public function is_block_content_call() {
4377
-			$result = false;
4378
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4379
-				$result = true;
4380
-			}
4352
+            if ( empty( $this->arguments ) ) {
4353
+                $this->get_arguments();
4354
+            }
4381 4355
 
4382
-			return $result;
4383
-		}
4356
+            // check for checkboxes
4357
+            if ( ! empty( $this->arguments ) ) {
4358
+                foreach ( $this->arguments as $argument ) {
4359
+                    if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4360
+                        $instance[ $argument['name'] ] = '0';
4361
+                    }
4362
+                }
4363
+            }
4384 4364
 
4385
-		/**
4386
-		 * Get an instance hash that will be unique to the type and settings.
4387
-		 *
4388
-		 * @return string
4389
-		 *@since 1.0.20
4390
-		 */
4391
-		public function get_instance_hash(){
4392
-			$instance_string = $this->base_id.serialize($this->instance);
4393
-			return hash('crc32b',$instance_string);
4394
-		}
4365
+            return $instance;
4366
+        }
4395 4367
 
4396
-		/**
4397
-		 * Generate and return inline styles from CSS rules that will match the unique class of the instance.
4398
-		 *
4399
-		 * @param array $rules
4400
-		 *
4401
-		 * @return string
4402
-		 *@since 1.0.20
4403
-		 */
4404
-		public function get_instance_style($rules = array()){
4405
-			$css = '';
4406
-
4407
-			if(!empty($rules)){
4408
-				$rules = array_unique($rules);
4409
-				$instance_hash = $this->get_instance_hash();
4410
-				$css .= "<style>";
4411
-				foreach($rules as $rule){
4412
-					$css .= ".sdel-$instance_hash $rule";
4413
-				}
4414
-				$css .= "</style>";
4415
-			}
4368
+        /**
4369
+         * Checks if the current call is a ajax call to get the block content.
4370
+         *
4371
+         * This can be used in your widget to return different content as the block content.
4372
+         *
4373
+         * @return bool
4374
+         *@since 1.0.3
4375
+         */
4376
+        public function is_block_content_call() {
4377
+            $result = false;
4378
+            if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4379
+                $result = true;
4380
+            }
4416 4381
 
4417
-			return $css;
4418
-		}
4382
+            return $result;
4383
+        }
4384
+
4385
+        /**
4386
+         * Get an instance hash that will be unique to the type and settings.
4387
+         *
4388
+         * @return string
4389
+         *@since 1.0.20
4390
+         */
4391
+        public function get_instance_hash(){
4392
+            $instance_string = $this->base_id.serialize($this->instance);
4393
+            return hash('crc32b',$instance_string);
4394
+        }
4395
+
4396
+        /**
4397
+         * Generate and return inline styles from CSS rules that will match the unique class of the instance.
4398
+         *
4399
+         * @param array $rules
4400
+         *
4401
+         * @return string
4402
+         *@since 1.0.20
4403
+         */
4404
+        public function get_instance_style($rules = array()){
4405
+            $css = '';
4406
+
4407
+            if(!empty($rules)){
4408
+                $rules = array_unique($rules);
4409
+                $instance_hash = $this->get_instance_hash();
4410
+                $css .= "<style>";
4411
+                foreach($rules as $rule){
4412
+                    $css .= ".sdel-$instance_hash $rule";
4413
+                }
4414
+                $css .= "</style>";
4415
+            }
4416
+
4417
+            return $css;
4418
+        }
4419 4419
 
4420
-		/**
4421
-		 * Encode shortcodes tags.
4422
-		 *
4423
-		 * @param string $content Content to search for shortcode tags.
4424
-		 *
4420
+        /**
4421
+         * Encode shortcodes tags.
4422
+         *
4423
+         * @param string $content Content to search for shortcode tags.
4424
+         *
4425 4425
 *@return string Content with shortcode tags removed.
4426
-		 *@since 1.0.28
4427
-		 *
4428
-		 */
4429
-		public function encode_shortcodes( $content ) {
4430
-			// Avoids existing encoded tags.
4431
-			$trans   = array(
4432
-				'&#91;' => '&#091;',
4433
-				'&#93;' => '&#093;',
4434
-				'&amp;#91;' => '&#091;',
4435
-				'&amp;#93;' => '&#093;',
4436
-				'&lt;' => '&0lt;',
4437
-				'&gt;' => '&0gt;',
4438
-				'&amp;lt;' => '&0lt;',
4439
-				'&amp;gt;' => '&0gt;',
4440
-			);
4441
-
4442
-			$content = strtr( $content, $trans );
4443
-
4444
-			$trans   = array(
4445
-				'[' => '&#91;',
4446
-				']' => '&#93;',
4447
-				'<' => '&lt;',
4448
-				'>' => '&gt;',
4449
-				'"' => '&quot;',
4450
-				"'" => '&apos;',
4451
-			);
4452
-
4453
-			$content = strtr( $content, $trans );
4454
-
4455
-			return $content;
4456
-		}
4426
+         *@since 1.0.28
4427
+         *
4428
+         */
4429
+        public function encode_shortcodes( $content ) {
4430
+            // Avoids existing encoded tags.
4431
+            $trans   = array(
4432
+                '&#91;' => '&#091;',
4433
+                '&#93;' => '&#093;',
4434
+                '&amp;#91;' => '&#091;',
4435
+                '&amp;#93;' => '&#093;',
4436
+                '&lt;' => '&0lt;',
4437
+                '&gt;' => '&0gt;',
4438
+                '&amp;lt;' => '&0lt;',
4439
+                '&amp;gt;' => '&0gt;',
4440
+            );
4441
+
4442
+            $content = strtr( $content, $trans );
4443
+
4444
+            $trans   = array(
4445
+                '[' => '&#91;',
4446
+                ']' => '&#93;',
4447
+                '<' => '&lt;',
4448
+                '>' => '&gt;',
4449
+                '"' => '&quot;',
4450
+                "'" => '&apos;',
4451
+            );
4452
+
4453
+            $content = strtr( $content, $trans );
4454
+
4455
+            return $content;
4456
+        }
4457 4457
 
4458
-		/**
4459
-		 * Remove encoded shortcod tags.
4460
-		 *
4461
-		 * @param string $content Content to search for shortcode tags.
4462
-		 *
4458
+        /**
4459
+         * Remove encoded shortcod tags.
4460
+         *
4461
+         * @param string $content Content to search for shortcode tags.
4462
+         *
4463 4463
 *@return string Content with decoded shortcode tags.
4464
-		 *@since 1.0.28
4465
-		 *
4466
-		 */
4467
-		public function decode_shortcodes( $content ) {
4468
-			$trans   = array(
4469
-				'&#91;' => '[',
4470
-				'&#93;' => ']',
4471
-				'&amp;#91;' => '[',
4472
-				'&amp;#93;' => ']',
4473
-				'&lt;' => '<',
4474
-				'&gt;' => '>',
4475
-				'&amp;lt;' => '<',
4476
-				'&amp;gt;' => '>',
4477
-				'&quot;' => '"',
4478
-				'&apos;' => "'",
4479
-			);
4480
-
4481
-			$content = strtr( $content, $trans );
4482
-
4483
-			$trans   = array(
4484
-				'&#091;' => '&#91;',
4485
-				'&#093;' => '&#93;',
4486
-				'&amp;#091;' => '&#91;',
4487
-				'&amp;#093;' => '&#93;',
4488
-				'&0lt;' => '&lt;',
4489
-				'&0gt;' => '&gt;',
4490
-				'&amp;0lt;' => '&lt;',
4491
-				'&amp;0gt;' => '&gt;',
4492
-			);
4493
-
4494
-			$content = strtr( $content, $trans );
4495
-
4496
-			return $content;
4497
-		}
4498
-	}
4464
+         *@since 1.0.28
4465
+         *
4466
+         */
4467
+        public function decode_shortcodes( $content ) {
4468
+            $trans   = array(
4469
+                '&#91;' => '[',
4470
+                '&#93;' => ']',
4471
+                '&amp;#91;' => '[',
4472
+                '&amp;#93;' => ']',
4473
+                '&lt;' => '<',
4474
+                '&gt;' => '>',
4475
+                '&amp;lt;' => '<',
4476
+                '&amp;gt;' => '>',
4477
+                '&quot;' => '"',
4478
+                '&apos;' => "'",
4479
+            );
4480
+
4481
+            $content = strtr( $content, $trans );
4482
+
4483
+            $trans   = array(
4484
+                '&#091;' => '&#91;',
4485
+                '&#093;' => '&#93;',
4486
+                '&amp;#091;' => '&#91;',
4487
+                '&amp;#093;' => '&#93;',
4488
+                '&0lt;' => '&lt;',
4489
+                '&0gt;' => '&gt;',
4490
+                '&amp;0lt;' => '&lt;',
4491
+                '&amp;0gt;' => '&gt;',
4492
+            );
4493
+
4494
+            $content = strtr( $content, $trans );
4495
+
4496
+            return $content;
4497
+        }
4498
+    }
4499 4499
 }
Please login to merge, or discard this patch.
Spacing   +721 added lines, -721 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
6
-if ( ! class_exists( 'WP_Super_Duper' ) ) {
6
+if (!class_exists('WP_Super_Duper')) {
7 7
 
8
-	define( 'SUPER_DUPER_VER', '1.1.10' );
8
+	define('SUPER_DUPER_VER', '1.1.10');
9 9
 
10 10
 	/**
11 11
 	 * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
@@ -38,40 +38,40 @@  discard block
 block discarded – undo
38 38
 		/**
39 39
 		 * Take the array options and use them to build.
40 40
 		 */
41
-		public function __construct( $options ) {
41
+		public function __construct($options) {
42 42
 			global $sd_widgets;
43 43
 
44
-			$sd_widgets[ $options['base_id'] ] = array(
44
+			$sd_widgets[$options['base_id']] = array(
45 45
 				'name'       => $options['name'],
46 46
 				'class_name' => $options['class_name'],
47 47
 				'output_types' => !empty($options['output_types']) ? $options['output_types'] : array()
48 48
 			);
49
-			$this->base_id                     = $options['base_id'];
49
+			$this->base_id = $options['base_id'];
50 50
 			// lets filter the options before we do anything
51
-			$options       = apply_filters( "wp_super_duper_options", $options );
52
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
-			$options       = $this->add_name_from_key( $options );
51
+			$options       = apply_filters("wp_super_duper_options", $options);
52
+			$options       = apply_filters("wp_super_duper_options_{$this->base_id}", $options);
53
+			$options       = $this->add_name_from_key($options);
54 54
 			$this->options = $options;
55 55
 
56 56
 			$this->base_id   = $options['base_id'];
57
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
57
+			$this->arguments = isset($options['arguments']) ? $options['arguments'] : array();
58 58
 
59 59
             // nested blocks can't work as a widget
60
-            if(!empty($this->options['nested-block'])){
61
-                if(empty($this->options['output_types'])){
62
-                    $this->options['output_types'] = array('shortcode','block');
60
+            if (!empty($this->options['nested-block'])) {
61
+                if (empty($this->options['output_types'])) {
62
+                    $this->options['output_types'] = array('shortcode', 'block');
63 63
                 }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64 64
                     unset($this->options['output_types'][$key]);
65 65
                 }
66 66
             }
67 67
 
68 68
 			// init parent
69
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
70
-                parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
69
+			if (empty($this->options['output_types']) || in_array('widget', $this->options['output_types'])) {
70
+                parent::__construct($options['base_id'], $options['name'], $options['widget_ops']);
71 71
 			}
72 72
 
73 73
 
74
-			if ( isset( $options['class_name'] ) ) {
74
+			if (isset($options['class_name'])) {
75 75
 				// register widget
76 76
 				$this->class_name = $options['class_name'];
77 77
 
@@ -80,60 +80,60 @@  discard block
 block discarded – undo
80 80
 
81 81
 
82 82
 				// Fusion Builder (avada) support
83
-				if ( function_exists( 'fusion_builder_map' ) ) {
84
-					add_action( 'init', array( $this, 'register_fusion_element' ) );
83
+				if (function_exists('fusion_builder_map')) {
84
+					add_action('init', array($this, 'register_fusion_element'));
85 85
 				}
86 86
 
87 87
 				// register block
88
-				if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){
89
-				    add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
88
+				if (empty($this->options['output_types']) || in_array('block', $this->options['output_types'])) {
89
+				    add_action('admin_enqueue_scripts', array($this, 'register_block'));
90 90
                 }
91 91
 			}
92 92
 
93 93
 			// add the CSS and JS we need ONCE
94 94
 			global $sd_widget_scripts;
95 95
 
96
-			if ( ! $sd_widget_scripts ) {
97
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
98
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
99
-				wp_add_inline_style( 'widgets', $this->widget_css() );
96
+			if (!$sd_widget_scripts) {
97
+				wp_add_inline_script('admin-widgets', $this->widget_js());
98
+				wp_add_inline_script('customize-controls', $this->widget_js());
99
+				wp_add_inline_style('widgets', $this->widget_css());
100 100
 
101 101
 				// maybe add elementor editor styles
102
-				add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
102
+				add_action('elementor/editor/after_enqueue_styles', array($this, 'elementor_editor_styles'));
103 103
 
104 104
 				$sd_widget_scripts = true;
105 105
 
106 106
 				// add shortcode insert button once
107
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
107
+				add_action('media_buttons', array($this, 'shortcode_insert_button'));
108 108
 				// generatepress theme sections compatibility
109
-				if ( function_exists( 'generate_sections_sections_metabox' ) ) {
110
-					add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
109
+				if (function_exists('generate_sections_sections_metabox')) {
110
+					add_action('generate_sections_metabox', array($this, 'shortcode_insert_button_script'));
111 111
 				}
112 112
 				/* Load script on Divi theme builder page */
113
-				if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) {
113
+				if (function_exists('et_builder_is_tb_admin_screen') && et_builder_is_tb_admin_screen()) {
114 114
 					add_thickbox();
115
-					add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) );
115
+					add_action('admin_footer', array($this, 'shortcode_insert_button_script'));
116 116
 				}
117 117
 
118
-				if ( $this->is_preview() ) {
119
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
118
+				if ($this->is_preview()) {
119
+					add_action('wp_footer', array($this, 'shortcode_insert_button_script'));
120 120
 					// this makes the insert button work for elementor
121
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
121
+					add_action('elementor/editor/after_enqueue_scripts', array(
122 122
 						$this,
123 123
 						'shortcode_insert_button_script'
124
-					) ); // for elementor
124
+					)); // for elementor
125 125
 				}
126 126
 				// this makes the insert button work for cornerstone
127
-				add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
127
+				add_action('wp_print_footer_scripts', array(__CLASS__, 'maybe_cornerstone_builder'));
128 128
 
129
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
130
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
129
+				add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings'));
130
+				add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker'));
131 131
 
132 132
 				// add generator text to admin head
133
-				add_action( 'admin_head', array( $this, 'generator' ) );
133
+				add_action('admin_head', array($this, 'generator'));
134 134
 			}
135 135
 
136
-			do_action( 'wp_super_duper_widget_init', $options, $this );
136
+			do_action('wp_super_duper_widget_init', $options, $this);
137 137
 		}
138 138
 
139 139
         /**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
          * @return void
142 142
          */
143 143
 		public function _register() {
144
-            if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
144
+            if (empty($this->options['output_types']) || in_array('widget', $this->options['output_types'])) {
145 145
                 parent::_register();
146 146
 			}
147 147
 		}
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
 		 * Add our widget CSS to elementor editor.
151 151
 		 */
152 152
 		public function elementor_editor_styles() {
153
-			wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
153
+			wp_add_inline_style('elementor-editor', $this->widget_css(false));
154 154
 		}
155 155
 
156 156
 		public function register_fusion_element() {
157 157
 
158 158
 			$options = $this->options;
159 159
 
160
-			if ( $this->base_id ) {
160
+			if ($this->base_id) {
161 161
 
162 162
 				$params = $this->get_fusion_params();
163 163
 
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
 					'allow_generator' => true,
169 169
 				);
170 170
 
171
-				if ( ! empty( $params ) ) {
171
+				if (!empty($params)) {
172 172
 					$args['params'] = $params;
173 173
 				}
174 174
 
175
-				fusion_builder_map( $args );
175
+				fusion_builder_map($args);
176 176
 			}
177 177
 
178 178
 		}
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 			$params    = array();
182 182
 			$arguments = $this->get_arguments();
183 183
 
184
-			if ( ! empty( $arguments ) ) {
185
-				foreach ( $arguments as $key => $val ) {
184
+			if (!empty($arguments)) {
185
+				foreach ($arguments as $key => $val) {
186 186
 					$param = array();
187 187
 					// type
188 188
 					$param['type'] = str_replace(
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 						$val['type'] );
205 205
 
206 206
 					// multiselect
207
-					if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
207
+					if ($val['type'] == 'multiselect' || (($param['type'] == 'select' || $val['type'] == 'select') && !empty($val['multiple']))) {
208 208
 						$param['type']     = 'multiple_select';
209 209
 						$param['multiple'] = true;
210 210
 					}
@@ -213,29 +213,29 @@  discard block
 block discarded – undo
213 213
 					$param['heading'] = $val['title'];
214 214
 
215 215
 					// description
216
-					$param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
216
+					$param['description'] = isset($val['desc']) ? $val['desc'] : '';
217 217
 
218 218
 					// param_name
219 219
 					$param['param_name'] = $key;
220 220
 
221 221
 					// Default
222
-					$param['default'] = isset( $val['default'] ) ? $val['default'] : '';
222
+					$param['default'] = isset($val['default']) ? $val['default'] : '';
223 223
 
224 224
 					// Group
225
-					if ( isset( $val['group'] ) ) {
225
+					if (isset($val['group'])) {
226 226
 						$param['group'] = $val['group'];
227 227
 					}
228 228
 
229 229
 					// value
230
-					if ( $val['type'] == 'checkbox' ) {
231
-						if ( isset( $val['default'] ) && $val['default'] == '0' ) {
232
-							unset( $param['default'] );
230
+					if ($val['type'] == 'checkbox') {
231
+						if (isset($val['default']) && $val['default'] == '0') {
232
+							unset($param['default']);
233 233
 						}
234
-						$param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) );
235
-					} elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
236
-						$param['value'] = isset( $val['options'] ) ? $val['options'] : array();
234
+						$param['value'] = array('' => __("No"), '1' => __("Yes"));
235
+					} elseif ($param['type'] == 'select' || $param['type'] == 'multiple_select') {
236
+						$param['value'] = isset($val['options']) ? $val['options'] : array();
237 237
 					} else {
238
-						$param['value'] = isset( $val['default'] ) ? $val['default'] : '';
238
+						$param['value'] = isset($val['default']) ? $val['default'] : '';
239 239
 					}
240 240
 
241 241
 					// setup the param
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 		 * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
253 253
 		 */
254 254
 		public static function maybe_cornerstone_builder() {
255
-			if ( did_action( 'cornerstone_before_boot_app' ) ) {
255
+			if (did_action('cornerstone_before_boot_app')) {
256 256
 				self::shortcode_insert_button_script();
257 257
 			}
258 258
 		}
@@ -264,12 +264,12 @@  discard block
 block discarded – undo
264 264
 		 *
265 265
 		 * @return string
266 266
 		 */
267
-		public static function get_picker( $editor_id = '' ) {
267
+		public static function get_picker($editor_id = '') {
268 268
 
269 269
 			ob_start();
270
-			if ( isset( $_POST['editor_id'] ) ) {
271
-				$editor_id = esc_attr( $_POST['editor_id'] );
272
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
270
+			if (isset($_POST['editor_id'])) {
271
+				$editor_id = esc_attr($_POST['editor_id']);
272
+			} elseif (isset($_REQUEST['et_fb'])) {
273 273
 				$editor_id = 'main_content_content_vb_tiny_mce';
274 274
 			}
275 275
 
@@ -280,14 +280,14 @@  discard block
 block discarded – undo
280 280
 
281 281
 			<div class="sd-shortcode-left-wrap">
282 282
 				<?php
283
-				ksort( $sd_widgets );
283
+				ksort($sd_widgets);
284 284
 				//				print_r($sd_widgets);exit;
285
-				if ( ! empty( $sd_widgets ) ) {
285
+				if (!empty($sd_widgets)) {
286 286
 					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
287
-					echo "<option>" . __( 'Select shortcode' ) . "</option>";
288
-					foreach ( $sd_widgets as $shortcode => $class ) {
289
-						if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; }
290
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
287
+					echo "<option>" . __('Select shortcode') . "</option>";
288
+					foreach ($sd_widgets as $shortcode => $class) {
289
+						if (!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])) { continue; }
290
+						echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>";
291 291
 					}
292 292
 					echo "</select>";
293 293
 
@@ -300,37 +300,37 @@  discard block
 block discarded – undo
300 300
 			<div class="sd-shortcode-right-wrap">
301 301
 				<textarea id='sd-shortcode-output' disabled></textarea>
302 302
 				<div id='sd-shortcode-output-actions'>
303
-					<?php if ( $editor_id != '' ) { ?>
303
+					<?php if ($editor_id != '') { ?>
304 304
 						<button class="button sd-insert-shortcode-button"
305
-						        onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
305
+						        onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) {
306 306
 							        echo "'" . $editor_id . "'";
307
-						        } ?>)"><?php _e( 'Insert shortcode' ); ?></button>
307
+						        } ?>)"><?php _e('Insert shortcode'); ?></button>
308 308
 					<?php } ?>
309 309
 					<button class="button"
310
-					        onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
310
+					        onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button>
311 311
 				</div>
312 312
 			</div>
313 313
 			<?php
314 314
 
315 315
 			$html = ob_get_clean();
316 316
 
317
-			if ( wp_doing_ajax() ) {
317
+			if (wp_doing_ajax()) {
318 318
 				echo $html;
319 319
 				$should_die = true;
320 320
 
321 321
 				// some builder get the editor via ajax so we should not die on those occasions
322 322
 				$dont_die = array(
323
-					'parent_tag',// WP Bakery
323
+					'parent_tag', // WP Bakery
324 324
 					'avia_request' // enfold
325 325
 				);
326 326
 
327
-				foreach ( $dont_die as $request ) {
328
-					if ( isset( $_REQUEST[ $request ] ) ) {
327
+				foreach ($dont_die as $request) {
328
+					if (isset($_REQUEST[$request])) {
329 329
 						$should_die = false;
330 330
 					}
331 331
 				}
332 332
 
333
-				if ( $should_die ) {
333
+				if ($should_die) {
334 334
 					wp_die();
335 335
 				}
336 336
 
@@ -357,16 +357,16 @@  discard block
 block discarded – undo
357 357
 		public static function get_widget_settings() {
358 358
 			global $sd_widgets;
359 359
 
360
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
361
-			if ( ! $shortcode ) {
360
+			$shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : '';
361
+			if (!$shortcode) {
362 362
 				wp_die();
363 363
 			}
364
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
365
-			if ( ! $widget_args ) {
364
+			$widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : '';
365
+			if (!$widget_args) {
366 366
 				wp_die();
367 367
 			}
368
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
369
-			if ( ! $class_name ) {
368
+			$class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
369
+			if (!$class_name) {
370 370
 				wp_die();
371 371
 			}
372 372
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 			$widget = new $class_name;
375 375
 
376 376
 			ob_start();
377
-			$widget->form( array() );
377
+			$widget->form(array());
378 378
 			$form = ob_get_clean();
379 379
 			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
380 380
 			echo "<style>" . $widget->widget_css() . "</style>";
@@ -393,9 +393,9 @@  discard block
 block discarded – undo
393 393
 		 *@since 1.0.0
394 394
 		 *
395 395
 		 */
396
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
396
+		public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') {
397 397
 			global $sd_widgets, $shortcode_insert_button_once;
398
-			if ( $shortcode_insert_button_once ) {
398
+			if ($shortcode_insert_button_once) {
399 399
 				return;
400 400
 			}
401 401
 			add_thickbox();
@@ -405,21 +405,21 @@  discard block
 block discarded – undo
405 405
 			 * Cornerstone makes us play dirty tricks :/
406 406
 			 * 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.
407 407
 			 */
408
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
408
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
409 409
 				echo '<span id="insert-media-button">';
410 410
 			}
411 411
 
412
-			echo self::shortcode_button( 'this', 'true' );
412
+			echo self::shortcode_button('this', 'true');
413 413
 
414 414
 			// see opening note
415
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
415
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
416 416
 				echo '</span>'; // end #insert-media-button
417 417
 			}
418 418
 
419 419
 			// Add separate script for generatepress theme sections
420
-			if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
420
+			if (function_exists('generate_sections_sections_metabox') && did_action('generate_sections_metabox')) {
421 421
 			} else {
422
-				self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
422
+				self::shortcode_insert_button_script($editor_id, $insert_shortcode_function);
423 423
 			}
424 424
 
425 425
 			$shortcode_insert_button_once = true;
@@ -433,12 +433,12 @@  discard block
 block discarded – undo
433 433
 		 *
434 434
 		 * @return mixed
435 435
 		 */
436
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
436
+		public static function shortcode_button($id = '', $search_for_id = '') {
437 437
 			ob_start();
438 438
 			?>
439 439
 			<span class="sd-lable-shortcode-inserter">
440 440
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
441
-				if ( $search_for_id ) {
441
+				if ($search_for_id) {
442 442
 					echo "," . $search_for_id;
443 443
 				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
444 444
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 			$html = ob_get_clean();
455 455
 
456 456
 			// remove line breaks so we can use it in js
457
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
457
+			return preg_replace("/\r|\n/", "", trim($html));
458 458
 		}
459 459
 
460 460
 		/**
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 						jQuery($this).data('sd-widget-enabled', true);
513 513
 					}
514 514
 
515
-					var $button = '<button title="<?php _e( 'Advanced Settings' );?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>';
515
+					var $button = '<button title="<?php _e('Advanced Settings'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>';
516 516
 					var form = jQuery($this).parents('' + $selector + '');
517 517
 
518 518
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -547,10 +547,10 @@  discard block
 block discarded – undo
547 547
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
548 548
 			 */
549 549
 
550
-			return str_replace( array(
550
+			return str_replace(array(
551 551
 				'<script>',
552 552
 				'</script>'
553
-			), '', $output );
553
+			), '', $output);
554 554
 		}
555 555
 
556 556
 		/**
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 		 *@since 1.0.6
563 563
 		 *
564 564
 		 */
565
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
565
+		public static function shortcode_insert_button_script($editor_id = '', $insert_shortcode_function = '') {
566 566
 			?>
567 567
 			<style>
568 568
 				.sd-shortcode-left-wrap {
@@ -681,25 +681,25 @@  discard block
 block discarded – undo
681 681
 					width: 100%;
682 682
 				}
683 683
 
684
-				<?php if ( function_exists( 'generate_sections_sections_metabox' ) ) { ?>
684
+				<?php if (function_exists('generate_sections_sections_metabox')) { ?>
685 685
 				.generate-sections-modal #custom-media-buttons > .sd-lable-shortcode-inserter {
686 686
 					display: inline;
687 687
 				}
688 688
 				<?php } ?>
689
-				<?php if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { ?>
689
+				<?php if (function_exists('et_builder_is_tb_admin_screen') && et_builder_is_tb_admin_screen()) { ?>
690 690
 				body.divi_page_et_theme_builder div#TB_window.gd-tb-window{z-index:9999999}
691 691
 				<?php } ?>
692 692
 			</style>
693 693
 			<?php
694
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
694
+			if (class_exists('SiteOrigin_Panels')) {
695 695
 				echo "<script>" . self::siteorigin_js() . "</script>";
696 696
 			}
697 697
 			?>
698 698
 			<script>
699 699
 				<?php
700
-				if(! empty( $insert_shortcode_function )){
700
+				if (!empty($insert_shortcode_function)) {
701 701
 					echo $insert_shortcode_function;
702
-				}else{
702
+				} else {
703 703
 
704 704
 				/**
705 705
 				 * Function for super duper insert shortcode.
@@ -712,9 +712,9 @@  discard block
 block discarded – undo
712 712
 					if ($shortcode) {
713 713
 						if (!$editor_id) {
714 714
 							<?php
715
-							if ( isset( $_REQUEST['et_fb'] ) ) {
715
+							if (isset($_REQUEST['et_fb'])) {
716 716
 								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
717
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
717
+							} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') {
718 718
 								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
719 719
 							} else {
720 720
 								echo '$editor_id = "#wp-content-editor-container textarea";';
@@ -799,11 +799,11 @@  discard block
 block discarded – undo
799 799
 							'shortcode': $short_code,
800 800
 							'attributes': 123,
801 801
 							'post_id': 321,
802
-							'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
802
+							'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
803 803
 						};
804 804
 
805 805
 						if (typeof ajaxurl === 'undefined') {
806
-							var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>";
806
+							var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
807 807
 						}
808 808
 
809 809
 						jQuery.post(ajaxurl, data, function (response) {
@@ -1012,11 +1012,11 @@  discard block
 block discarded – undo
1012 1012
 					var data = {
1013 1013
 						'action': 'super_duper_get_picker',
1014 1014
 						'editor_id': $id,
1015
-						'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_picker' );?>'
1015
+						'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_picker'); ?>'
1016 1016
 					};
1017 1017
 
1018 1018
 					if (!ajaxurl) {
1019
-						var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
1019
+						var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
1020 1020
 					}
1021 1021
 
1022 1022
 					jQuery.post(ajaxurl, data, function (response) {
@@ -1038,9 +1038,9 @@  discard block
 block discarded – undo
1038 1038
 				 */
1039 1039
 				function sd_shortcode_button($id) {
1040 1040
 					if ($id) {
1041
-						return '<?php echo self::shortcode_button( "\\''+\$id+'\\'" );?>';
1041
+						return '<?php echo self::shortcode_button("\\''+\$id+'\\'"); ?>';
1042 1042
 					} else {
1043
-						return '<?php echo self::shortcode_button();?>';
1043
+						return '<?php echo self::shortcode_button(); ?>';
1044 1044
 					}
1045 1045
 				}
1046 1046
 
@@ -1055,11 +1055,11 @@  discard block
 block discarded – undo
1055 1055
 		 *
1056 1056
 		 * @return mixed
1057 1057
 		 */
1058
-		public function widget_css( $advanced = true ) {
1058
+		public function widget_css($advanced = true) {
1059 1059
 			ob_start();
1060 1060
 			?>
1061 1061
 			<style>
1062
-				<?php if( $advanced ){ ?>
1062
+				<?php if ($advanced) { ?>
1063 1063
 				.sd-advanced-setting {
1064 1064
 					display: none;
1065 1065
 				}
@@ -1101,10 +1101,10 @@  discard block
 block discarded – undo
1101 1101
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1102 1102
 			 */
1103 1103
 
1104
-			return str_replace( array(
1104
+			return str_replace(array(
1105 1105
 				'<style>',
1106 1106
 				'</style>'
1107
-			), '', $output );
1107
+			), '', $output);
1108 1108
 		}
1109 1109
 
1110 1110
 		/**
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
 						jQuery($this).data('sd-widget-enabled', true);
1172 1172
 					}
1173 1173
 
1174
-					var $button = '<button title="<?php _e( 'Advanced Settings' );?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>';
1174
+					var $button = '<button title="<?php _e('Advanced Settings'); ?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>';
1175 1175
 					var form = $form ? $form : jQuery($this).parents('' + $selector + '');
1176 1176
 
1177 1177
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
 					});
1263 1263
 
1264 1264
 				}
1265
-				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1265
+				<?php do_action('wp_super_duper_widget_js', $this); ?>
1266 1266
 			</script>
1267 1267
 			<?php
1268 1268
 			$output = ob_get_clean();
@@ -1271,10 +1271,10 @@  discard block
 block discarded – undo
1271 1271
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1272 1272
 			 */
1273 1273
 
1274
-			return str_replace( array(
1274
+			return str_replace(array(
1275 1275
 				'<script>',
1276 1276
 				'</script>'
1277
-			), '', $output );
1277
+			), '', $output);
1278 1278
 		}
1279 1279
 
1280 1280
 
@@ -1285,14 +1285,14 @@  discard block
 block discarded – undo
1285 1285
 		 *
1286 1286
 		 * @return mixed
1287 1287
 		 */
1288
-		private function add_name_from_key( $options, $arguments = false ) {
1289
-			if ( ! empty( $options['arguments'] ) ) {
1290
-				foreach ( $options['arguments'] as $key => $val ) {
1291
-					$options['arguments'][ $key ]['name'] = $key;
1288
+		private function add_name_from_key($options, $arguments = false) {
1289
+			if (!empty($options['arguments'])) {
1290
+				foreach ($options['arguments'] as $key => $val) {
1291
+					$options['arguments'][$key]['name'] = $key;
1292 1292
 				}
1293
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1294
-				foreach ( $options as $key => $val ) {
1295
-					$options[ $key ]['name'] = $key;
1293
+			} elseif ($arguments && is_array($options) && !empty($options)) {
1294
+				foreach ($options as $key => $val) {
1295
+					$options[$key]['name'] = $key;
1296 1296
 				}
1297 1297
 			}
1298 1298
 
@@ -1305,8 +1305,8 @@  discard block
 block discarded – undo
1305 1305
 		 * @since 1.0.0
1306 1306
 		 */
1307 1307
 		public function register_shortcode() {
1308
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1309
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) );
1308
+			add_shortcode($this->base_id, array($this, 'shortcode_output'));
1309
+			add_action('wp_ajax_super_duper_output_shortcode', array($this, 'render_shortcode'));
1310 1310
 		}
1311 1311
 
1312 1312
 		/**
@@ -1315,50 +1315,50 @@  discard block
 block discarded – undo
1315 1315
 		 * @since 1.0.0
1316 1316
 		 */
1317 1317
 		public function render_shortcode() {
1318
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1319
-			if ( ! current_user_can( 'manage_options' ) ) {
1318
+			check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true);
1319
+			if (!current_user_can('manage_options')) {
1320 1320
 				wp_die();
1321 1321
 			}
1322 1322
 
1323 1323
 			// we might need the $post value here so lets set it.
1324
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1325
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1326
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1324
+			if (isset($_POST['post_id']) && $_POST['post_id']) {
1325
+				$post_obj = get_post(absint($_POST['post_id']));
1326
+				if (!empty($post_obj) && empty($post)) {
1327 1327
 					global $post;
1328 1328
 					$post = $post_obj;
1329 1329
 				}
1330 1330
 			}
1331 1331
 
1332
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1332
+			if (isset($_POST['shortcode']) && $_POST['shortcode']) {
1333 1333
 				$is_preview = $this->is_preview();
1334
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1335
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1334
+				$shortcode_name   = sanitize_title_with_dashes($_POST['shortcode']);
1335
+				$attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array();
1336 1336
 				$attributes       = '';
1337
-				if ( ! empty( $attributes_array ) ) {
1338
-					foreach ( $attributes_array as $key => $value ) {
1339
-						if ( is_array( $value ) ) {
1340
-							$value = implode( ",", $value );
1337
+				if (!empty($attributes_array)) {
1338
+					foreach ($attributes_array as $key => $value) {
1339
+						if (is_array($value)) {
1340
+							$value = implode(",", $value);
1341 1341
 						}
1342 1342
 
1343
-						if ( ! empty( $value ) ) {
1344
-							$value = wp_unslash( $value );
1343
+						if (!empty($value)) {
1344
+							$value = wp_unslash($value);
1345 1345
 
1346 1346
 							// Encode [ and ].
1347
-							if ( $is_preview ) {
1348
-								$value = $this->encode_shortcodes( $value );
1347
+							if ($is_preview) {
1348
+								$value = $this->encode_shortcodes($value);
1349 1349
 							}
1350 1350
 						}
1351
-						$attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . esc_attr( $value ) . "' ";
1351
+						$attributes .= " " . sanitize_title_with_dashes($key) . "='" . esc_attr($value) . "' ";
1352 1352
 					}
1353 1353
 				}
1354 1354
 
1355 1355
 				$shortcode = "[" . $shortcode_name . " " . $attributes . "]";
1356 1356
 
1357
-				$content = do_shortcode( $shortcode );
1357
+				$content = do_shortcode($shortcode);
1358 1358
 
1359 1359
 				// Decode [ and ].
1360
-				if ( ! empty( $content ) && $is_preview ) {
1361
-					$content = $this->decode_shortcodes( $content );
1360
+				if (!empty($content) && $is_preview) {
1361
+					$content = $this->decode_shortcodes($content);
1362 1362
 				}
1363 1363
 
1364 1364
 				echo $content;
@@ -1374,21 +1374,21 @@  discard block
 block discarded – undo
1374 1374
 		 *
1375 1375
 		 * @return string
1376 1376
 		 */
1377
-		public function shortcode_output( $args = array(), $content = '' ) {
1377
+		public function shortcode_output($args = array(), $content = '') {
1378 1378
 			$_instance = $args;
1379 1379
 
1380
-			$args = $this->argument_values( $args );
1380
+			$args = $this->argument_values($args);
1381 1381
 
1382 1382
 			// add extra argument so we know its a output to gutenberg
1383 1383
 			//$args
1384
-			$args = $this->string_to_bool( $args );
1384
+			$args = $this->string_to_bool($args);
1385 1385
 
1386 1386
 			// if we have a enclosed shortcode we add it to the special `html` argument
1387
-			if ( ! empty( $content ) ) {
1387
+			if (!empty($content)) {
1388 1388
 				$args['html'] = $content;
1389 1389
 			}
1390 1390
 
1391
-			if ( ! $this->is_preview() ) {
1391
+			if (!$this->is_preview()) {
1392 1392
 				/**
1393 1393
 				 * Filters the settings for a particular widget args.
1394 1394
 				 *
@@ -1399,40 +1399,40 @@  discard block
 block discarded – undo
1399 1399
 				 *@since 1.0.28
1400 1400
 				 *
1401 1401
 				 */
1402
-				$args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );
1402
+				$args = apply_filters('wp_super_duper_widget_display_callback', $args, $this, $_instance);
1403 1403
 
1404
-				if ( ! is_array( $args ) ) {
1404
+				if (!is_array($args)) {
1405 1405
 					return $args;
1406 1406
 				}
1407 1407
 			}
1408 1408
 
1409
-			$class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1410
-			$class .= " sdel-".$this->get_instance_hash();
1409
+			$class = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : '';
1410
+			$class .= " sdel-" . $this->get_instance_hash();
1411 1411
 
1412
-			$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1413
-			$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1412
+			$class = apply_filters('wp_super_duper_div_classname', $class, $args, $this);
1413
+			$class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this);
1414 1414
 
1415
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1416
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1415
+			$attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this);
1416
+			$attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this);
1417 1417
 
1418 1418
 			$shortcode_args = array();
1419 1419
 			$output         = '';
1420
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1421
-			if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1420
+			$no_wrap        = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false;
1421
+			if (isset($args['no_wrap']) && $args['no_wrap']) {
1422 1422
 				$no_wrap = true;
1423 1423
 			}
1424
-			$main_content = $this->output( $args, $shortcode_args, $content );
1425
-			if ( $main_content && ! $no_wrap ) {
1424
+			$main_content = $this->output($args, $shortcode_args, $content);
1425
+			if ($main_content && !$no_wrap) {
1426 1426
 				// wrap the shortcode in a div with the same class as the widget
1427 1427
 				$output .= '<div class="' . $class . '" ' . $attrs . '>';
1428
-				if ( ! empty( $args['title'] ) ) {
1428
+				if (!empty($args['title'])) {
1429 1429
 					// if its a shortcode and there is a title try to grab the title wrappers
1430
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1431
-					if ( empty( $instance ) ) {
1430
+					$shortcode_args = array('before_title' => '', 'after_title' => '');
1431
+					if (empty($instance)) {
1432 1432
 						global $wp_registered_sidebars;
1433
-						if ( ! empty( $wp_registered_sidebars ) ) {
1434
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1435
-								if ( ! empty( $sidebar['before_title'] ) ) {
1433
+						if (!empty($wp_registered_sidebars)) {
1434
+							foreach ($wp_registered_sidebars as $sidebar) {
1435
+								if (!empty($sidebar['before_title'])) {
1436 1436
 									$shortcode_args['before_title'] = $sidebar['before_title'];
1437 1437
 									$shortcode_args['after_title']  = $sidebar['after_title'];
1438 1438
 									break;
@@ -1440,20 +1440,20 @@  discard block
 block discarded – undo
1440 1440
 							}
1441 1441
 						}
1442 1442
 					}
1443
-					$output .= $this->output_title( $shortcode_args, $args );
1443
+					$output .= $this->output_title($shortcode_args, $args);
1444 1444
 				}
1445 1445
 				$output .= $main_content;
1446 1446
 				$output .= '</div>';
1447
-			} elseif ( $main_content && $no_wrap ) {
1447
+			} elseif ($main_content && $no_wrap) {
1448 1448
 				$output .= $main_content;
1449 1449
 			}
1450 1450
 
1451 1451
 			// if preview show a placeholder if empty
1452
-			if ( $this->is_preview() && $output == '' ) {
1453
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1452
+			if ($this->is_preview() && $output == '') {
1453
+				$output = $this->preview_placeholder_text("{{" . $this->base_id . "}}");
1454 1454
 			}
1455 1455
 
1456
-			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1456
+			return apply_filters('wp_super_duper_widget_output', $output, $args, $shortcode_args, $this);
1457 1457
 		}
1458 1458
 
1459 1459
 		/**
@@ -1463,8 +1463,8 @@  discard block
 block discarded – undo
1463 1463
 		 *
1464 1464
 		 * @return string
1465 1465
 		 */
1466
-		public function preview_placeholder_text( $name = '' ) {
1467
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>";
1466
+		public function preview_placeholder_text($name = '') {
1467
+			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf(__('Placeholder for: %s'), $name) . "</div>";
1468 1468
 		}
1469 1469
 
1470 1470
 		/**
@@ -1474,13 +1474,13 @@  discard block
 block discarded – undo
1474 1474
 		 *
1475 1475
 		 * @return mixed
1476 1476
 		 */
1477
-		public function string_to_bool( $options ) {
1477
+		public function string_to_bool($options) {
1478 1478
 			// convert bool strings to booleans
1479
-			foreach ( $options as $key => $val ) {
1480
-				if ( $val == 'false' ) {
1481
-					$options[ $key ] = false;
1482
-				} elseif ( $val == 'true' ) {
1483
-					$options[ $key ] = true;
1479
+			foreach ($options as $key => $val) {
1480
+				if ($val == 'false') {
1481
+					$options[$key] = false;
1482
+				} elseif ($val == 'true') {
1483
+					$options[$key] = true;
1484 1484
 				}
1485 1485
 			}
1486 1486
 
@@ -1496,26 +1496,26 @@  discard block
 block discarded – undo
1496 1496
 		 *@since 1.0.12 Don't set checkbox default value if the value is empty.
1497 1497
 		 *
1498 1498
 		 */
1499
-		public function argument_values( $instance ) {
1499
+		public function argument_values($instance) {
1500 1500
 			$argument_values = array();
1501 1501
 
1502 1502
 			// set widget instance
1503 1503
 			$this->instance = $instance;
1504 1504
 
1505
-			if ( empty( $this->arguments ) ) {
1505
+			if (empty($this->arguments)) {
1506 1506
 				$this->arguments = $this->get_arguments();
1507 1507
 			}
1508 1508
 
1509
-			if ( ! empty( $this->arguments ) ) {
1510
-				foreach ( $this->arguments as $key => $args ) {
1509
+			if (!empty($this->arguments)) {
1510
+				foreach ($this->arguments as $key => $args) {
1511 1511
 					// set the input name from the key
1512 1512
 					$args['name'] = $key;
1513 1513
 					//
1514
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1515
-					if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1514
+					$argument_values[$key] = isset($instance[$key]) ? $instance[$key] : '';
1515
+					if ($args['type'] == 'checkbox' && $argument_values[$key] == '') {
1516 1516
 						// don't set default for an empty checkbox
1517
-					} elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1518
-						$argument_values[ $key ] = $args['default'];
1517
+					} elseif ($argument_values[$key] == '' && isset($args['default'])) {
1518
+						$argument_values[$key] = $args['default'];
1519 1519
 					}
1520 1520
 				}
1521 1521
 			}
@@ -1542,12 +1542,12 @@  discard block
 block discarded – undo
1542 1542
 		 *
1543 1543
 		 */
1544 1544
 		public function get_arguments() {
1545
-			if ( empty( $this->arguments ) ) {
1545
+			if (empty($this->arguments)) {
1546 1546
 				$this->arguments = $this->set_arguments();
1547 1547
 			}
1548 1548
 
1549
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1550
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1549
+			$this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance);
1550
+			$this->arguments = $this->add_name_from_key($this->arguments, true);
1551 1551
 
1552 1552
 			return $this->arguments;
1553 1553
 		}
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
 		 * @param array $widget_args
1560 1560
 		 * @param string $content
1561 1561
 		 */
1562
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1562
+		public function output($args = array(), $widget_args = array(), $content = '') {
1563 1563
 
1564 1564
 		}
1565 1565
 
@@ -1567,9 +1567,9 @@  discard block
 block discarded – undo
1567 1567
 		 * Add the dynamic block code inline when the wp-block in enqueued.
1568 1568
 		 */
1569 1569
 		public function register_block() {
1570
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1571
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1572
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1570
+			wp_add_inline_script('wp-blocks', $this->block());
1571
+			if (class_exists('SiteOrigin_Panels')) {
1572
+				wp_add_inline_script('wp-blocks', $this->siteorigin_js());
1573 1573
 			}
1574 1574
 		}
1575 1575
 
@@ -1583,9 +1583,9 @@  discard block
 block discarded – undo
1583 1583
 			$show      = false;
1584 1584
 			$arguments = $this->get_arguments();
1585 1585
 
1586
-			if ( ! empty( $arguments ) ) {
1587
-				foreach ( $arguments as $argument ) {
1588
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1586
+			if (!empty($arguments)) {
1587
+				foreach ($arguments as $argument) {
1588
+					if (isset($argument['advanced']) && $argument['advanced']) {
1589 1589
 						$show = true;
1590 1590
 						break; // no need to continue if we know we have it
1591 1591
 					}
@@ -1603,19 +1603,19 @@  discard block
 block discarded – undo
1603 1603
 		public function get_url() {
1604 1604
 			$url = $this->url;
1605 1605
 
1606
-			if ( ! $url ) {
1607
-				$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1608
-				$content_url = untrailingslashit( WP_CONTENT_URL );
1606
+			if (!$url) {
1607
+				$content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR));
1608
+				$content_url = untrailingslashit(WP_CONTENT_URL);
1609 1609
 
1610 1610
 				// Replace http:// to https://.
1611
-				if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1612
-					$content_url = str_replace( 'http://', 'https://', $content_url );
1611
+				if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) {
1612
+					$content_url = str_replace('http://', 'https://', $content_url);
1613 1613
 				}
1614 1614
 
1615 1615
 				// Check if we are inside a plugin
1616
-				$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1617
-				$url = str_replace( $content_dir, $content_url, $file_dir );
1618
-				$url = trailingslashit( $url );
1616
+				$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
1617
+				$url = str_replace($content_dir, $content_url, $file_dir);
1618
+				$url = trailingslashit($url);
1619 1619
 				$this->url = $url;
1620 1620
 			}
1621 1621
 
@@ -1631,15 +1631,15 @@  discard block
 block discarded – undo
1631 1631
 
1632 1632
 			$url = $this->url;
1633 1633
 
1634
-			if ( ! $url ) {
1634
+			if (!$url) {
1635 1635
 				// check if we are inside a plugin
1636
-				$file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1636
+				$file_dir = str_replace("/includes", "", dirname(__FILE__));
1637 1637
 
1638
-				$dir_parts = explode( "/wp-content/", $file_dir );
1639
-				$url_parts = explode( "/wp-content/", plugins_url() );
1638
+				$dir_parts = explode("/wp-content/", $file_dir);
1639
+				$url_parts = explode("/wp-content/", plugins_url());
1640 1640
 
1641
-				if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1642
-					$url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1641
+				if (!empty($url_parts[0]) && !empty($dir_parts[1])) {
1642
+					$url       = trailingslashit($url_parts[0] . "/wp-content/" . $dir_parts[1]);
1643 1643
 					$this->url = $url;
1644 1644
 				}
1645 1645
 			}
@@ -1660,46 +1660,46 @@  discard block
 block discarded – undo
1660 1660
 		 * @return string
1661 1661
 		 *@since 1.1.0
1662 1662
 		 */
1663
-		public function get_block_icon( $icon ) {
1663
+		public function get_block_icon($icon) {
1664 1664
 
1665 1665
 			// check if we have a Font Awesome icon
1666 1666
 			$fa_type = '';
1667
-			if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1667
+			if (substr($icon, 0, 7) === "fas fa-") {
1668 1668
 				$fa_type = 'solid';
1669
-			} elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1669
+			} elseif (substr($icon, 0, 7) === "far fa-") {
1670 1670
 				$fa_type = 'regular';
1671
-			} elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1671
+			} elseif (substr($icon, 0, 7) === "fab fa-") {
1672 1672
 				$fa_type = 'brands';
1673 1673
 			} else {
1674 1674
 				$icon = "'" . $icon . "'";
1675 1675
 			}
1676 1676
 
1677 1677
 			// set the icon if we found one
1678
-			if ( $fa_type ) {
1679
-				$fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1678
+			if ($fa_type) {
1679
+				$fa_icon = str_replace(array("fas fa-", "far fa-", "fab fa-"), "", $icon);
1680 1680
 				$icon    = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1681 1681
 			}
1682 1682
 
1683 1683
 			return $icon;
1684 1684
 		}
1685 1685
 
1686
-		public function group_arguments( $arguments ) {
1686
+		public function group_arguments($arguments) {
1687 1687
 //			echo '###';print_r($arguments);
1688
-			if ( ! empty( $arguments ) ) {
1688
+			if (!empty($arguments)) {
1689 1689
 				$temp_arguments = array();
1690
-				$general        = __( "General" );
1690
+				$general        = __("General");
1691 1691
 				$add_sections   = false;
1692
-				foreach ( $arguments as $key => $args ) {
1693
-					if ( isset( $args['group'] ) ) {
1694
-						$temp_arguments[ $args['group'] ][ $key ] = $args;
1692
+				foreach ($arguments as $key => $args) {
1693
+					if (isset($args['group'])) {
1694
+						$temp_arguments[$args['group']][$key] = $args;
1695 1695
 						$add_sections                             = true;
1696 1696
 					} else {
1697
-						$temp_arguments[ $general ][ $key ] = $args;
1697
+						$temp_arguments[$general][$key] = $args;
1698 1698
 					}
1699 1699
 				}
1700 1700
 
1701 1701
 				// only add sections if more than one
1702
-				if ( $add_sections ) {
1702
+				if ($add_sections) {
1703 1703
 					$arguments = $temp_arguments;
1704 1704
 				}
1705 1705
 			}
@@ -1729,7 +1729,7 @@  discard block
 block discarded – undo
1729 1729
 			<script>
1730 1730
 
1731 1731
 			<?php
1732
-			if(!$sd_is_js_functions_loaded){
1732
+			if (!$sd_is_js_functions_loaded) {
1733 1733
                 $sd_is_js_functions_loaded = true;
1734 1734
             ?>
1735 1735
 
@@ -1909,7 +1909,7 @@  discard block
 block discarded – undo
1909 1909
 
1910 1910
 				// maybe use featured image.
1911 1911
 				if( $args['bg_image_use_featured'] !== undefined && $args['bg_image_use_featured'] ){
1912
-					$bg_image = '<?php echo $this->get_url();?>icons/placeholder.png';
1912
+					$bg_image = '<?php echo $this->get_url(); ?>icons/placeholder.png';
1913 1913
 				}
1914 1914
 
1915 1915
                 if( $bg_image !== undefined && $bg_image !== '' ){
@@ -2095,7 +2095,7 @@  discard block
 block discarded – undo
2095 2095
             }
2096 2096
 
2097 2097
 			function sd_get_class_build_keys(){
2098
-				return <?php echo json_encode(sd_get_class_build_keys());?>;
2098
+				return <?php echo json_encode(sd_get_class_build_keys()); ?>;
2099 2099
 			}
2100 2100
 
2101 2101
             <?php
@@ -2103,7 +2103,7 @@  discard block
 block discarded – undo
2103 2103
 
2104 2104
             }
2105 2105
 
2106
-			if(method_exists($this,'block_global_js')){
2106
+			if (method_exists($this, 'block_global_js')) {
2107 2107
 					echo $this->block_global_js();
2108 2108
 			}
2109 2109
 			?>
@@ -2132,9 +2132,9 @@  discard block
 block discarded – undo
2132 2132
                     var InnerBlocks = blockEditor.InnerBlocks;
2133 2133
 
2134 2134
 					var term_query_type = '';
2135
-					var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";}else{echo "[]";} ?>;
2136
-					const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2137
-					const sort_by_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2135
+					var post_type_rest_slugs = <?php if (!empty($this->arguments) && isset($this->arguments['post_type']['onchange_rest']['values'])) {echo "[" . json_encode($this->arguments['post_type']['onchange_rest']['values']) . "]"; } else {echo "[]"; } ?>;
2136
+					const taxonomies_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}];
2137
+					const sort_by_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}];
2138 2138
                     const MediaUpload = wp.blockEditor.MediaUpload;
2139 2139
 
2140 2140
 					/**
@@ -2149,20 +2149,20 @@  discard block
 block discarded – undo
2149 2149
 					 * @return {?WPBlock}          The block, if it has been successfully
2150 2150
 					 *                             registered; otherwise `undefined`.
2151 2151
 					 */
2152
-					registerBlockType('<?php echo str_replace( "_", "-", sanitize_title_with_dashes( $this->options['textdomain'] ) . '/' . sanitize_title_with_dashes( $this->options['class_name'] ) );  ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
2153
-						apiVersion: <?php echo isset($this->options['block-api-version']) ? absint($this->options['block-api-version']) : 2 ; ?>,
2154
-                        title: '<?php echo addslashes( $this->options['name'] ); ?>', // Block title.
2155
-						description: '<?php echo addslashes( $this->options['widget_ops']['description'] )?>', // Block title.
2156
-						icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
2152
+					registerBlockType('<?php echo str_replace("_", "-", sanitize_title_with_dashes($this->options['textdomain']) . '/' . sanitize_title_with_dashes($this->options['class_name'])); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
2153
+						apiVersion: <?php echo isset($this->options['block-api-version']) ? absint($this->options['block-api-version']) : 2; ?>,
2154
+                        title: '<?php echo addslashes($this->options['name']); ?>', // Block title.
2155
+						description: '<?php echo addslashes($this->options['widget_ops']['description'])?>', // Block title.
2156
+						icon: <?php echo $this->get_block_icon($this->options['block-icon']); ?>,//'<?php echo isset($this->options['block-icon']) ? esc_attr($this->options['block-icon']) : 'shield-alt'; ?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
2157 2157
 						supports: {
2158 2158
 							<?php
2159
-							if ( isset( $this->options['block-supports'] ) ) {
2160
-								echo $this->array_to_attributes( $this->options['block-supports'] );
2159
+							if (isset($this->options['block-supports'])) {
2160
+								echo $this->array_to_attributes($this->options['block-supports']);
2161 2161
 							}
2162 2162
 							?>
2163 2163
 						},
2164 2164
 						<?php
2165
-						if ( isset( $this->options['block-label'] ) ) {
2165
+						if (isset($this->options['block-label'])) {
2166 2166
 						?>
2167 2167
 						__experimentalLabel( attributes, { context } ) {
2168 2168
                             return <?php echo $this->options['block-label']; ?>;
@@ -2170,8 +2170,8 @@  discard block
 block discarded – undo
2170 2170
                         <?php
2171 2171
                         }
2172 2172
                         ?>
2173
-						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.
2174
-						<?php if ( isset( $this->options['block-keywords'] ) ) {
2173
+						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.
2174
+						<?php if (isset($this->options['block-keywords'])) {
2175 2175
 						echo "keywords : " . $this->options['block-keywords'] . ",";
2176 2176
 
2177 2177
 //						// block hover preview.
@@ -2198,11 +2198,11 @@  discard block
 block discarded – undo
2198 2198
                         }
2199 2199
 
2200 2200
 						// maybe set no_wrap
2201
-						$no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2202
-						if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2201
+						$no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false;
2202
+						if (isset($this->arguments['no_wrap']) && $this->arguments['no_wrap']) {
2203 2203
 							$no_wrap = true;
2204 2204
 						}
2205
-						if ( $no_wrap ) {
2205
+						if ($no_wrap) {
2206 2206
 							$this->options['block-wrap'] = '';
2207 2207
 						}
2208 2208
 
@@ -2216,10 +2216,10 @@  discard block
 block discarded – undo
2216 2216
 						echo "  html: false";
2217 2217
 						echo "},";*/
2218 2218
 
2219
-						if ( ! empty( $this->arguments ) ) {
2219
+						if (!empty($this->arguments)) {
2220 2220
 							echo "attributes : {";
2221 2221
 
2222
-							if ( $show_advanced ) {
2222
+							if ($show_advanced) {
2223 2223
 								echo "show_advanced: {";
2224 2224
 								echo "	type: 'boolean',";
2225 2225
 								echo "  default: false,";
@@ -2227,56 +2227,56 @@  discard block
 block discarded – undo
2227 2227
 							}
2228 2228
 
2229 2229
 							// block wrap element
2230
-							if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2230
+							if (!empty($this->options['block-wrap'])) { //@todo we should validate this?
2231 2231
 								echo "block_wrap: {";
2232 2232
 								echo "	type: 'string',";
2233
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2233
+								echo "  default: '" . esc_attr($this->options['block-wrap']) . "',";
2234 2234
 								echo "},";
2235 2235
 							}
2236 2236
 
2237 2237
 
2238 2238
 
2239
-							foreach ( $this->arguments as $key => $args ) {
2239
+							foreach ($this->arguments as $key => $args) {
2240 2240
 
2241
-								if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2241
+								if ($args['type'] == 'image' || $args['type'] == 'images') {
2242 2242
 									$img_drag_drop = true;
2243 2243
 								}
2244 2244
 
2245 2245
 								// set if we should show alignment
2246
-								if ( $key == 'alignment' ) {
2246
+								if ($key == 'alignment') {
2247 2247
 									$show_alignment = true;
2248 2248
 								}
2249 2249
 
2250 2250
 								$extra = '';
2251 2251
 
2252
-								if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2252
+								if ($args['type'] == 'notice' || $args['type'] == 'tab') {
2253 2253
 									continue;
2254 2254
 								}
2255
-								elseif ( $args['type'] == 'checkbox' ) {
2255
+								elseif ($args['type'] == 'checkbox') {
2256 2256
 									$type    = 'boolean';
2257
-									$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2258
-								} elseif ( $args['type'] == 'number' ) {
2257
+									$default = isset($args['default']) && $args['default'] ? 'true' : 'false';
2258
+								} elseif ($args['type'] == 'number') {
2259 2259
 									$type    = 'number';
2260
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2261
-								} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2260
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2261
+								} elseif ($args['type'] == 'select' && !empty($args['multiple'])) {
2262 2262
 									$type = 'array';
2263
-									if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2264
-										$default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2263
+									if (isset($args['default']) && is_array($args['default'])) {
2264
+										$default = !empty($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]";
2265 2265
 									} else {
2266
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2266
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2267 2267
 									}
2268
-								} elseif ( $args['type'] == 'tagselect' ) {
2268
+								} elseif ($args['type'] == 'tagselect') {
2269 2269
 									$type    = 'array';
2270
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2271
-								} elseif ( $args['type'] == 'multiselect' ) {
2270
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2271
+								} elseif ($args['type'] == 'multiselect') {
2272 2272
 									$type    = 'array';
2273
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2274
-								} elseif ( $args['type'] == 'image_xy' ) {
2273
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2274
+								} elseif ($args['type'] == 'image_xy') {
2275 2275
 									$type    = 'object';
2276
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2277
-								} elseif ( $args['type'] == 'image' ) {
2276
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2277
+								} elseif ($args['type'] == 'image') {
2278 2278
 									$type    = 'string';
2279
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2279
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2280 2280
 
2281 2281
                                     // add a field for ID
2282 2282
 //                                    echo $key . "_id : {";
@@ -2288,7 +2288,7 @@  discard block
 block discarded – undo
2288 2288
 
2289 2289
 								} else {
2290 2290
 									$type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2291
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2291
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2292 2292
 
2293 2293
 								}
2294 2294
 								echo $key . " : {";
@@ -2312,7 +2312,7 @@  discard block
 block discarded – undo
2312 2312
 
2313 2313
 <?php
2314 2314
 // only include the drag/drop functions if required.
2315
-if( $img_drag_drop ){
2315
+if ($img_drag_drop) {
2316 2316
 
2317 2317
 ?>
2318 2318
 
@@ -2378,9 +2378,9 @@  discard block
 block discarded – undo
2378 2378
 							}
2379 2379
 
2380 2380
                             <?php
2381
-                            if(!empty($this->options['block-edit-raw'])) {
2381
+                            if (!empty($this->options['block-edit-raw'])) {
2382 2382
                                 echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2383
-                            }else{
2383
+                            } else {
2384 2384
                             ?>
2385 2385
 
2386 2386
 function hasSelectedInnerBlock(props) {
@@ -2405,7 +2405,7 @@  discard block
 block discarded – undo
2405 2405
 							var $value = '';
2406 2406
 							<?php
2407 2407
 							// if we have a post_type and a category then link them
2408
-							if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2408
+							if (isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked'])) {
2409 2409
 							?>
2410 2410
 							if(typeof(prev_attributes[props.clientId]) != 'undefined' ){
2411 2411
 								$pt = props.attributes.post_type;
@@ -2421,13 +2421,13 @@  discard block
 block discarded – undo
2421 2421
 
2422 2422
 								// taxonomies
2423 2423
 								if( $value && 'post_type' in prev_attributes[props.clientId] && 'category' in prev_attributes[props.clientId] && run ){
2424
-									wp.apiFetch({path: "<?php if(isset($this->arguments['post_type']['onchange_rest']['path'])){echo $this->arguments['post_type']['onchange_rest']['path'];}else{'/wp/v2/"+$value+"/categories/?per_page=100';} ?>"}).then(terms => {
2425
-										while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) {
2426
-										taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop();
2424
+									wp.apiFetch({path: "<?php if (isset($this->arguments['post_type']['onchange_rest']['path'])) {echo $this->arguments['post_type']['onchange_rest']['path']; } else {'/wp/v2/"+$value+"/categories/?per_page=100'; } ?>"}).then(terms => {
2425
+										while (taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2426
+										taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2427 2427
 									}
2428
-									taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: "All", value: 0});
2428
+									taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: "All", value: 0});
2429 2429
 									jQuery.each( terms, function( key, val ) {
2430
-										taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: val.name, value: val.id});
2430
+										taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val.name, value: val.id});
2431 2431
 									});
2432 2432
 
2433 2433
 									// setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options.
@@ -2435,7 +2435,7 @@  discard block
 block discarded – undo
2435 2435
 									props.setAttributes({category: [0] });
2436 2436
 									props.setAttributes({category: $old_cat_value });
2437 2437
 
2438
-									return taxonomies_<?php echo str_replace("-","_", $this->id);?>;
2438
+									return taxonomies_<?php echo str_replace("-", "_", $this->id); ?>;
2439 2439
 								});
2440 2440
 								}
2441 2441
 
@@ -2447,12 +2447,12 @@  discard block
 block discarded – undo
2447 2447
 									};
2448 2448
 									jQuery.post(ajaxurl, data, function(response) {
2449 2449
 										response = JSON.parse(response);
2450
-										while (sort_by_<?php echo str_replace("-","_", $this->id);?>.length) {
2451
-											sort_by_<?php echo str_replace("-","_", $this->id);?>.pop();
2450
+										while (sort_by_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2451
+											sort_by_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2452 2452
 										}
2453 2453
 
2454 2454
 										jQuery.each( response, function( key, val ) {
2455
-											sort_by_<?php echo str_replace("-","_", $this->id);?>.push({label: val, value: key});
2455
+											sort_by_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val, value: key});
2456 2456
 										});
2457 2457
 
2458 2458
 										// setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options.
@@ -2460,7 +2460,7 @@  discard block
 block discarded – undo
2460 2460
 										props.setAttributes({sort_by: [0] });
2461 2461
 										props.setAttributes({sort_by: $old_sort_by_value });
2462 2462
 
2463
-										return sort_by_<?php echo str_replace("-","_", $this->id);?>;
2463
+										return sort_by_<?php echo str_replace("-", "_", $this->id); ?>;
2464 2464
 									});
2465 2465
 
2466 2466
 								}
@@ -2468,9 +2468,9 @@  discard block
 block discarded – undo
2468 2468
 							<?php } ?>
2469 2469
 <?php
2470 2470
 $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2471
-if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2471
+if (!empty($current_screen->base) && $current_screen->base === 'widgets') {
2472 2472
 	echo 'const { deviceType } = "";';
2473
-}else{
2473
+} else {
2474 2474
 ?>
2475 2475
 /** Get device type const. */
2476 2476
 const { deviceType } = wp.data.useSelect != 'undefined' ?  wp.data.useSelect(select => {
@@ -2499,13 +2499,13 @@  discard block
 block discarded – undo
2499 2499
 
2500 2500
 									var data = {
2501 2501
 										'action': 'super_duper_output_shortcode',
2502
-										'shortcode': '<?php echo $this->options['base_id'];?>',
2502
+										'shortcode': '<?php echo $this->options['base_id']; ?>',
2503 2503
 										'attributes': props.attributes,
2504 2504
 										'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '',
2505
-										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
2505
+										'post_id': <?php global $post; if (isset($post->ID)) {
2506 2506
 										echo $post->ID;
2507
-									}else{echo '0';}?>,
2508
-										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
2507
+									} else {echo '0'; }?>,
2508
+										'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
2509 2509
 									};
2510 2510
 
2511 2511
 									jQuery.post(ajaxurl, data, function (response) {
@@ -2514,17 +2514,17 @@  discard block
 block discarded – undo
2514 2514
 
2515 2515
 										// if the content is empty then we place some placeholder text
2516 2516
 										if (env == '') {
2517
-											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for: ' );?>" + props.name + "</div>";
2517
+											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for: '); ?>" + props.name + "</div>";
2518 2518
 										}
2519 2519
 
2520 2520
                                          <?php
2521
-                                        if(!empty($this->options['nested-block'])){
2521
+                                        if (!empty($this->options['nested-block'])) {
2522 2522
                                             ?>
2523 2523
                                             // props.setAttributes({content: env});
2524 2524
 										is_fetching = false;
2525 2525
 										prev_attributes[props.clientId] = props.attributes;
2526 2526
                                              <?php
2527
-                                        }else{
2527
+                                        } else {
2528 2528
                                         ?>
2529 2529
                                        props.setAttributes({content: env});
2530 2530
 										is_fetching = false;
@@ -2549,8 +2549,8 @@  discard block
 block discarded – undo
2549 2549
 							}
2550 2550
 
2551 2551
                             <?php
2552
-                            if(!empty($this->options['block-edit-js'])) {
2553
-                                echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
2552
+                            if (!empty($this->options['block-edit-js'])) {
2553
+                                echo  $this->options['block-edit-js']; // strings have to be in single quotes, may cause issues
2554 2554
                             }
2555 2555
 
2556 2556
 
@@ -2563,7 +2563,7 @@  discard block
 block discarded – undo
2563 2563
 
2564 2564
 								el(wp.blockEditor.BlockControls, {key: 'controls'},
2565 2565
 
2566
-									<?php if($show_alignment){?>
2566
+									<?php if ($show_alignment) {?>
2567 2567
 									el(
2568 2568
 										wp.blockEditor.AlignmentToolbar,
2569 2569
 										{
@@ -2581,9 +2581,9 @@  discard block
 block discarded – undo
2581 2581
 
2582 2582
 									<?php
2583 2583
 
2584
-									if(! empty( $this->arguments )){
2584
+									if (!empty($this->arguments)) {
2585 2585
 
2586
-									if ( $show_advanced ) {
2586
+									if ($show_advanced) {
2587 2587
 									?>
2588 2588
 									el('div', {
2589 2589
 											style: {'padding-left': '16px','padding-right': '16px'}
@@ -2608,46 +2608,46 @@  discard block
 block discarded – undo
2608 2608
 
2609 2609
 									//echo '####';
2610 2610
 
2611
-									$arguments = $this->group_arguments( $this->arguments );
2611
+									$arguments = $this->group_arguments($this->arguments);
2612 2612
 //print_r($arguments ); exit;
2613 2613
 									// Do we have sections?
2614 2614
 									$has_sections = $arguments == $this->arguments ? false : true;
2615 2615
 
2616 2616
 
2617
-									if($has_sections){
2617
+									if ($has_sections) {
2618 2618
 									$panel_count = 0;
2619 2619
 									$open_tab = '';
2620 2620
 
2621 2621
 									$open_tab_groups = array();
2622 2622
 									$used_tabs = array();
2623
-									foreach($arguments as $key => $args){
2623
+									foreach ($arguments as $key => $args) {
2624 2624
 
2625 2625
 										$close_tab = false;
2626 2626
 										$close_tabs = false;
2627 2627
 
2628
-										 if(!empty($this->options['block_group_tabs'])) {
2629
-											foreach($this->options['block_group_tabs'] as $tab_name => $tab_args){
2630
-												if(in_array($key,$tab_args['groups'])){
2628
+										 if (!empty($this->options['block_group_tabs'])) {
2629
+											foreach ($this->options['block_group_tabs'] as $tab_name => $tab_args) {
2630
+												if (in_array($key, $tab_args['groups'])) {
2631 2631
 
2632 2632
 													$open_tab_groups[] = $key;
2633 2633
 
2634
-													if($open_tab != $tab_name){
2634
+													if ($open_tab != $tab_name) {
2635 2635
 														$tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
2636 2636
 														$tab_args['tab']['open'] = true;
2637 2637
 
2638
-														$this->block_tab_start( '', $tab_args );
2638
+														$this->block_tab_start('', $tab_args);
2639 2639
 //														echo '###open'.$tab_name;print_r($tab_args);
2640 2640
 														$open_tab = $tab_name;
2641 2641
 														$used_tabs[] = $tab_name;
2642 2642
 													}
2643 2643
 
2644
-													if($open_tab_groups == $tab_args['groups']){
2644
+													if ($open_tab_groups == $tab_args['groups']) {
2645 2645
 														//$open_tab = '';
2646 2646
 														$close_tab = true;
2647 2647
 														$open_tab_groups = array();
2648 2648
 
2649 2649
 //													print_r(array_keys($this->options['block_group_tabs']));echo '####';print_r($used_tabs);
2650
-													if($used_tabs == array_keys($this->options['block_group_tabs'])){
2650
+													if ($used_tabs == array_keys($this->options['block_group_tabs'])) {
2651 2651
 //														echo '@@@';
2652 2652
 															$close_tabs = true;
2653 2653
 														}
@@ -2663,8 +2663,8 @@  discard block
 block discarded – undo
2663 2663
 
2664 2664
 										?>
2665 2665
 										el(wp.components.PanelBody, {
2666
-												title: '<?php esc_attr_e( $key ); ?>',
2667
-												initialOpen: <?php if ( $panel_count ) {
2666
+												title: '<?php esc_attr_e($key); ?>',
2667
+												initialOpen: <?php if ($panel_count) {
2668 2668
 												echo "false";
2669 2669
 											} else {
2670 2670
 												echo "true";
@@ -2674,21 +2674,21 @@  discard block
 block discarded – undo
2674 2674
 
2675 2675
 
2676 2676
 
2677
-											foreach ( $args as $k => $a ) {
2677
+											foreach ($args as $k => $a) {
2678 2678
 
2679
-												$this->block_tab_start( $k, $a );
2680
-												$this->block_row_start( $k, $a );
2681
-												$this->build_block_arguments( $k, $a );
2682
-												$this->block_row_end( $k, $a );
2683
-												$this->block_tab_end( $k, $a );
2679
+												$this->block_tab_start($k, $a);
2680
+												$this->block_row_start($k, $a);
2681
+												$this->build_block_arguments($k, $a);
2682
+												$this->block_row_end($k, $a);
2683
+												$this->block_tab_end($k, $a);
2684 2684
 											}
2685 2685
 											?>
2686 2686
 										),
2687 2687
 										<?php
2688
-										$panel_count ++;
2688
+										$panel_count++;
2689 2689
 
2690 2690
 
2691
-										if($close_tab || $close_tabs){
2691
+										if ($close_tab || $close_tabs) {
2692 2692
 											$tab_args = array(
2693 2693
 												'tab'	=> array(
2694 2694
 													'tabs_close' => $close_tabs,
@@ -2696,24 +2696,24 @@  discard block
 block discarded – undo
2696 2696
 												)
2697 2697
 
2698 2698
 											);
2699
-											$this->block_tab_end( '', $tab_args );
2699
+											$this->block_tab_end('', $tab_args);
2700 2700
 //											echo '###close'; print_r($tab_args);
2701 2701
 											$panel_count = 0;
2702 2702
 										}
2703 2703
 //
2704 2704
 
2705 2705
 									}
2706
-									}else {
2706
+									} else {
2707 2707
 									?>
2708 2708
 									el(wp.components.PanelBody, {
2709
-											title: '<?php esc_attr_e( "Settings" ); ?>',
2709
+											title: '<?php esc_attr_e("Settings"); ?>',
2710 2710
 											initialOpen: true
2711 2711
 										},
2712 2712
 										<?php
2713
-										foreach ( $this->arguments as $key => $args ) {
2714
-											$this->block_row_start( $key, $args );
2715
-											$this->build_block_arguments( $key, $args );
2716
-											$this->block_row_end( $key, $args );
2713
+										foreach ($this->arguments as $key => $args) {
2714
+											$this->block_row_start($key, $args);
2715
+											$this->build_block_arguments($key, $args);
2716
+											$this->block_row_end($key, $args);
2717 2717
 										}
2718 2718
 										?>
2719 2719
 									),
@@ -2727,11 +2727,11 @@  discard block
 block discarded – undo
2727 2727
 
2728 2728
 								<?php
2729 2729
 								// If the user sets block-output array then build it
2730
-								if ( ! empty( $this->options['block-output'] ) ) {
2731
-								$this->block_element( $this->options['block-output'] );
2732
-							}elseif(!empty($this->options['block-edit-return'])){
2730
+								if (!empty($this->options['block-output'])) {
2731
+								$this->block_element($this->options['block-output']);
2732
+							}elseif (!empty($this->options['block-edit-return'])) {
2733 2733
                                    echo $this->options['block-edit-return'];
2734
-							}else{
2734
+							} else {
2735 2735
 								// if no block-output is set then we try and get the shortcode html output via ajax.
2736 2736
 								?>
2737 2737
 								el('div', wp.blockEditor.useBlockProps({
@@ -2756,22 +2756,22 @@  discard block
 block discarded – undo
2756 2756
 							var align = '';
2757 2757
 
2758 2758
 							// build the shortcode.
2759
-							var content = "[<?php echo $this->options['base_id'];?>";
2759
+							var content = "[<?php echo $this->options['base_id']; ?>";
2760 2760
 							$html = '';
2761 2761
 							<?php
2762 2762
 
2763
-							if(! empty( $this->arguments )){
2763
+							if (!empty($this->arguments)) {
2764 2764
 
2765
-							foreach($this->arguments as $key => $args){
2765
+							foreach ($this->arguments as $key => $args) {
2766 2766
                                // if($args['type']=='tabs'){continue;}
2767 2767
 							?>
2768
-							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
2769
-								if ('<?php echo esc_attr( $key );?>' == 'html') {
2770
-									$html = attr.<?php echo esc_attr( $key );?>;
2771
-								} else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') {
2772
-									content += " <?php echo esc_attr( $key );?>='{x:" + attr.<?php echo esc_attr( $key );?>.x + ",y:"+attr.<?php echo esc_attr( $key );?>.y +"}' ";
2768
+							if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) {
2769
+								if ('<?php echo esc_attr($key); ?>' == 'html') {
2770
+									$html = attr.<?php echo esc_attr($key); ?>;
2771
+								} else if ('<?php echo esc_attr($args['type']); ?>' == 'image_xy') {
2772
+									content += " <?php echo esc_attr($key); ?>='{x:" + attr.<?php echo esc_attr($key); ?>.x + ",y:"+attr.<?php echo esc_attr($key); ?>.y +"}' ";
2773 2773
 								} else {
2774
-									content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' ";
2774
+									content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>+ "' ";
2775 2775
 								}
2776 2776
 							}
2777 2777
 							<?php
@@ -2790,7 +2790,7 @@  discard block
 block discarded – undo
2790 2790
                             ?>
2791 2791
 							// if has html element
2792 2792
 							if ($html) {
2793
-								content += $html + "[/<?php echo $this->options['base_id'];?>]";
2793
+								content += $html + "[/<?php echo $this->options['base_id']; ?>]";
2794 2794
 							}
2795 2795
 
2796 2796
 							// @todo should we add inline style here or just css classes?
@@ -2820,7 +2820,7 @@  discard block
 block discarded – undo
2820 2820
 //                                <x?php
2821 2821
 //							}else
2822 2822
 
2823
-                            if(!empty($this->options['block-output'])){
2823
+                            if (!empty($this->options['block-output'])) {
2824 2824
 //                               echo "return";
2825 2825
 //                               $this->block_element( $this->options['block-output'], true );
2826 2826
 //                               echo ";";
@@ -2830,30 +2830,30 @@  discard block
 block discarded – undo
2830 2830
                                    '',
2831 2831
                                    {},
2832 2832
                                    el('', {dangerouslySetInnerHTML: {__html: content}}),
2833
-                                   <?php $this->block_element( $this->options['block-output'], true ); ?>
2834
-                                   el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
2833
+                                   <?php $this->block_element($this->options['block-output'], true); ?>
2834
+                                   el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}})
2835 2835
                                );
2836 2836
                                 <?php
2837 2837
 
2838
-							}elseif(!empty($this->options['block-save-return'])){
2838
+							}elseif (!empty($this->options['block-save-return'])) {
2839 2839
                                    echo 'return ' . $this->options['block-save-return'];
2840
-							}elseif(!empty($this->options['nested-block'])){
2840
+							}elseif (!empty($this->options['nested-block'])) {
2841 2841
                                 ?>
2842 2842
                               return el(
2843 2843
                                    '',
2844 2844
                                    {},
2845 2845
                                    el('', {dangerouslySetInnerHTML: {__html: content+"\n"}}),
2846 2846
                                    InnerBlocks.Content ? el( InnerBlocks.Content ) : '', // @todo i think we need a comma here
2847
-                                   el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
2847
+                                   el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}})
2848 2848
                                );
2849 2849
                                 <?php
2850
-							}elseif(!empty( $this->options['block-save-return'] ) ){
2851
-                                echo "return ". $this->options['block-edit-return'].";";
2852
-							}elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
2850
+							}elseif (!empty($this->options['block-save-return'])) {
2851
+                                echo "return " . $this->options['block-edit-return'] . ";";
2852
+							}elseif (isset($this->options['block-wrap']) && $this->options['block-wrap'] == '') {
2853 2853
 							?>
2854 2854
 							return content;
2855 2855
 							<?php
2856
-							}else{
2856
+							} else {
2857 2857
 							?>
2858 2858
 							var block_wrap = 'div';
2859 2859
 							if (attr.hasOwnProperty("block_wrap")) {
@@ -2882,48 +2882,48 @@  discard block
 block discarded – undo
2882 2882
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
2883 2883
 			 */
2884 2884
 
2885
-			return str_replace( array(
2885
+			return str_replace(array(
2886 2886
 				'<script>',
2887 2887
 				'</script>'
2888
-			), '', $output );
2888
+			), '', $output);
2889 2889
 		}
2890 2890
 
2891 2891
 
2892 2892
 
2893
-		public function block_row_start($key, $args){
2893
+		public function block_row_start($key, $args) {
2894 2894
 
2895 2895
 			// check for row
2896
-			if(!empty($args['row'])){
2896
+			if (!empty($args['row'])) {
2897 2897
 
2898
-				if(!empty($args['row']['open'])){
2898
+				if (!empty($args['row']['open'])) {
2899 2899
 
2900 2900
 				// element require
2901
-				$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
2902
-                $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
2903
-                $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
2901
+				$element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : "";
2902
+                $device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : '';
2903
+                $device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
2904 2904
                 $device_type_icon = '';
2905
-                if($device_type=='Desktop'){
2905
+                if ($device_type == 'Desktop') {
2906 2906
                     $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
2907
-                }elseif($device_type=='Tablet'){
2907
+                }elseif ($device_type == 'Tablet') {
2908 2908
                     $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
2909
-                }elseif($device_type=='Mobile'){
2909
+                }elseif ($device_type == 'Mobile') {
2910 2910
                     $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
2911 2911
                 }
2912 2912
 				echo $element_require;
2913 2913
                 echo $device_type_require;
2914 2914
 
2915
-					if(false){?><script><?php }?>
2915
+					if (false) {?><script><?php }?>
2916 2916
 						el('div', {
2917 2917
 								className: 'bsui components-base-control',
2918 2918
 							},
2919
-							<?php if(!empty($args['row']['title'])){ ?>
2919
+							<?php if (!empty($args['row']['title'])) { ?>
2920 2920
 							el('label', {
2921 2921
 									className: 'components-base-control__label position-relative',
2922 2922
 									style: {width:"100%"}
2923 2923
 								},
2924
-								el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['row']['title'] ) ?>'}}),
2925
-								<?php if($device_type_icon){ ?>
2926
-                                    deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})
2924
+								el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes($args['row']['title']) ?>'}}),
2925
+								<?php if ($device_type_icon) { ?>
2926
+                                    deviceType == '<?php echo $device_type; ?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})
2927 2927
 								<?php
2928 2928
                                 }
2929 2929
                                 ?>
@@ -2931,17 +2931,17 @@  discard block
 block discarded – undo
2931 2931
 
2932 2932
 							),
2933 2933
 							<?php }?>
2934
-							<?php if(!empty($args['row']['desc'])){ ?>
2934
+							<?php if (!empty($args['row']['desc'])) { ?>
2935 2935
 							el('p', {
2936 2936
 									className: 'components-base-control__help mb-0',
2937 2937
 								},
2938
-								'<?php echo addslashes( $args['row']['desc'] ); ?>'
2938
+								'<?php echo addslashes($args['row']['desc']); ?>'
2939 2939
 							),
2940 2940
 							<?php }?>
2941 2941
 							el(
2942 2942
 								'div',
2943 2943
 								{
2944
-									className: 'row mb-n2 <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>',
2944
+									className: 'row mb-n2 <?php if (!empty($args['row']['class'])) { echo esc_attr($args['row']['class']); } ?>',
2945 2945
 								},
2946 2946
 								el(
2947 2947
 									'div',
@@ -2950,36 +2950,36 @@  discard block
 block discarded – undo
2950 2950
 									},
2951 2951
 
2952 2952
 					<?php
2953
-					if(false){?></script><?php }
2954
-				}elseif(!empty($args['row']['close'])){
2955
-					if(false){?><script><?php }?>
2953
+					if (false) {?></script><?php }
2954
+				}elseif (!empty($args['row']['close'])) {
2955
+					if (false) {?><script><?php }?>
2956 2956
 						el(
2957 2957
 							'div',
2958 2958
 							{
2959 2959
 								className: 'col pl-0',
2960 2960
 							},
2961 2961
 					<?php
2962
-					if(false){?></script><?php }
2963
-				}else{
2964
-					if(false){?><script><?php }?>
2962
+					if (false) {?></script><?php }
2963
+				} else {
2964
+					if (false) {?><script><?php }?>
2965 2965
 						el(
2966 2966
 							'div',
2967 2967
 							{
2968 2968
 								className: 'col pl-0 pr-2',
2969 2969
 							},
2970 2970
 					<?php
2971
-					if(false){?></script><?php }
2971
+					if (false) {?></script><?php }
2972 2972
 				}
2973 2973
 
2974 2974
 			}
2975 2975
 
2976 2976
 		}
2977 2977
 
2978
-		public function block_row_end($key, $args){
2978
+		public function block_row_end($key, $args) {
2979 2979
 
2980
-			if(!empty($args['row'])){
2980
+			if (!empty($args['row'])) {
2981 2981
 				// maybe close
2982
-				if(!empty($args['row']['close'])){
2982
+				if (!empty($args['row']['close'])) {
2983 2983
 					echo "))";
2984 2984
 				}
2985 2985
 
@@ -2987,14 +2987,14 @@  discard block
 block discarded – undo
2987 2987
 			}
2988 2988
 		}
2989 2989
 
2990
-		public function block_tab_start($key, $args){
2990
+		public function block_tab_start($key, $args) {
2991 2991
 
2992 2992
 			// check for row
2993
-			if(!empty($args['tab'])){
2993
+			if (!empty($args['tab'])) {
2994 2994
 
2995
-				if(!empty($args['tab']['tabs_open'])){
2995
+				if (!empty($args['tab']['tabs_open'])) {
2996 2996
 
2997
-					if(false){?><script><?php }?>
2997
+					if (false) {?><script><?php }?>
2998 2998
 
2999 2999
 el('div',{className: 'bsui'},
3000 3000
 
@@ -3003,41 +3003,41 @@  discard block
 block discarded – undo
3003 3003
 									{
3004 3004
                                         activeClass: 'is-active',
3005 3005
                                         className: 'btn-groupx',
3006
-                                        initialTabName: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3006
+                                        initialTabName: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>',
3007 3007
 										tabs: [
3008 3008
 
3009 3009
 					<?php
3010
-					if(false){?></script><?php }
3010
+					if (false) {?></script><?php }
3011 3011
 				}
3012 3012
 
3013
-				if(!empty($args['tab']['open'])){
3013
+				if (!empty($args['tab']['open'])) {
3014 3014
 
3015
-					if(false){?><script><?php }?>
3015
+					if (false) {?><script><?php }?>
3016 3016
 							{
3017
-												name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3018
-												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}),
3019
-												className: '<?php echo addslashes( esc_attr( $args['tab']['class']) ); ?>',
3020
-												content: el('div',{}, <?php if(!empty($args['tab']['desc'])){ ?>el('p', {
3017
+												name: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>',
3018
+												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes(esc_attr($args['tab']['title'])); ?>'}}),
3019
+												className: '<?php echo addslashes(esc_attr($args['tab']['class'])); ?>',
3020
+												content: el('div',{}, <?php if (!empty($args['tab']['desc'])) { ?>el('p', {
3021 3021
 									className: 'components-base-control__help mb-0',
3022
-									dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'}
3022
+									dangerouslySetInnerHTML: {__html:'<?php echo addslashes($args['tab']['desc']); ?>'}
3023 3023
 								}),<?php }
3024
-					if(false){?></script><?php }
3024
+					if (false) {?></script><?php }
3025 3025
 				}
3026 3026
 
3027 3027
 			}
3028 3028
 
3029 3029
 		}
3030 3030
 
3031
-		public function block_tab_end($key, $args){
3031
+		public function block_tab_end($key, $args) {
3032 3032
 
3033
-			if(!empty($args['tab'])){
3033
+			if (!empty($args['tab'])) {
3034 3034
 				// maybe close
3035
-				if(!empty($args['tab']['close'])){
3035
+				if (!empty($args['tab']['close'])) {
3036 3036
 					echo ")}, /* tab close */";
3037 3037
 				}
3038 3038
 
3039
-				if(!empty($args['tab']['tabs_close'])){
3040
-					if(false){?><script><?php }?>
3039
+				if (!empty($args['tab']['tabs_close'])) {
3040
+					if (false) {?><script><?php }?>
3041 3041
 							],
3042 3042
 									},
3043 3043
 									( tab ) => {
@@ -3046,42 +3046,42 @@  discard block
 block discarded – undo
3046 3046
 
3047 3047
 								}
3048 3048
 								)), /* tabs close */
3049
-					<?php if(false){ ?></script><?php }
3049
+					<?php if (false) { ?></script><?php }
3050 3050
 				}
3051 3051
 			}
3052 3052
 		}
3053 3053
 
3054
-		public function build_block_arguments( $key, $args ) {
3055
-			$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3054
+		public function build_block_arguments($key, $args) {
3055
+			$custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
3056 3056
 			$options           = '';
3057 3057
 			$extra             = '';
3058 3058
 			$require           = '';
3059
-            $inside_elements   = '';
3059
+            $inside_elements = '';
3060 3060
 			$after_elements	   = '';
3061 3061
 
3062 3062
 			// `content` is a protected and special argument
3063
-			if ( $key == 'content' ) {
3063
+			if ($key == 'content') {
3064 3064
 				return;
3065 3065
 			}
3066 3066
 
3067
-            $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3068
-            $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3067
+            $device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : '';
3068
+            $device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3069 3069
             $device_type_icon = '';
3070
-            if($device_type=='Desktop'){
3070
+            if ($device_type == 'Desktop') {
3071 3071
                 $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3072
-            }elseif($device_type=='Tablet'){
3072
+            }elseif ($device_type == 'Tablet') {
3073 3073
                 $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3074
-            }elseif($device_type=='Mobile'){
3074
+            }elseif ($device_type == 'Mobile') {
3075 3075
                 $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3076 3076
             }
3077 3077
 
3078 3078
 			// icon
3079 3079
 			$icon = '';
3080
-			if( !empty( $args['icon'] ) ){
3080
+			if (!empty($args['icon'])) {
3081 3081
 				$icon .= "el('div', {";
3082
-									$icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3082
+									$icon .= "dangerouslySetInnerHTML: {__html: '" . self::get_widget_icon(esc_attr($args['icon'])) . "'},";
3083 3083
 									$icon .= "className: 'text-center',";
3084
-									$icon .= "title: '".addslashes( $args['title'] )."',";
3084
+									$icon .= "title: '" . addslashes($args['title']) . "',";
3085 3085
 								$icon .= "}),";
3086 3086
 
3087 3087
 				// blank title as its added to the icon.
@@ -3089,28 +3089,28 @@  discard block
 block discarded – undo
3089 3089
 			}
3090 3090
 
3091 3091
 			// require advanced
3092
-			$require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3092
+			$require_advanced = !empty($args['advanced']) ? "props.attributes.show_advanced && " : "";
3093 3093
 
3094 3094
 			// element require
3095
-			$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3095
+			$element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : "";
3096 3096
 
3097 3097
 
3098 3098
 			$onchange  = "props.setAttributes({ $key: $key } )";
3099
-			$onchangecomplete  = "";
3099
+			$onchangecomplete = "";
3100 3100
 			$value     = "props.attributes.$key";
3101
-			$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3102
-			if ( in_array( $args['type'], $text_type ) ) {
3101
+			$text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'colorx', 'range');
3102
+			if (in_array($args['type'], $text_type)) {
3103 3103
 				$type = 'TextControl';
3104 3104
 				// Save numbers as numbers and not strings
3105
-				if ( $args['type'] == 'number' ) {
3105
+				if ($args['type'] == 'number') {
3106 3106
 					$onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3107 3107
 				}
3108
-			}else if ( $args['type'] == 'styleid' ) {
3108
+			} else if ($args['type'] == 'styleid') {
3109 3109
 				$type = 'TextControl';
3110 3110
 				$args['type'] == 'text';
3111 3111
 				// Save numbers as numbers and not strings
3112
-				$value     = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'";
3113
-			}else if ( $args['type'] == 'notice' ) {
3112
+				$value = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'";
3113
+			} else if ($args['type'] == 'notice') {
3114 3114
 
3115 3115
 				$notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3116 3116
 				$notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
@@ -3172,11 +3172,11 @@  discard block
 block discarded – undo
3172 3172
 							return;
3173 3173
 						}
3174 3174
 */
3175
-			elseif ( $args['type'] == 'color' ) {
3175
+			elseif ($args['type'] == 'color') {
3176 3176
 				$type = 'ColorPicker';
3177 3177
 				$onchange = "";
3178 3178
 				$extra = "color: $value,";
3179
-				if(!empty($args['disable_alpha'])){
3179
+				if (!empty($args['disable_alpha'])) {
3180 3180
 					$extra .= "disableAlpha: true,";
3181 3181
 				}
3182 3182
 				$onchangecomplete = "onChangeComplete: function($key) {
@@ -3185,14 +3185,14 @@  discard block
 block discarded – undo
3185 3185
                             $key: value
3186 3186
                         });
3187 3187
                     },";
3188
-			}elseif ( $args['type'] == 'gradient' ) {
3188
+			}elseif ($args['type'] == 'gradient') {
3189 3189
 				$type = 'GradientPicker';
3190 3190
 
3191
-			}elseif ( $args['type'] == 'image' ) {
3191
+			}elseif ($args['type'] == 'image') {
3192 3192
 //                print_r($args);
3193 3193
 
3194 3194
                 $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
3195
-                            url:  props.attributes.{$key}_use_featured === true ? '".$this->get_url()."icons/placeholder.png'  : props.attributes.$key,
3195
+                            url:  props.attributes.{$key}_use_featured === true ? '" . $this->get_url() . "icons/placeholder.png'  : props.attributes.$key,
3196 3196
                             value: props.attributes.{$key}_xy.x !== undefined && props.attributes.{$key}_xy.x >= 0 ? props.attributes.{$key}_xy  : {x: 0.5,y: 0.5,},
3197 3197
 //                            value: props.attributes.{$key}_xy,
3198 3198
                             onChange: function(focalPoint){
@@ -3250,7 +3250,7 @@  discard block
 block discarded – undo
3250 3250
                 $onchange = "";
3251 3251
 
3252 3252
                 //$inside_elements = ",el('div',{},'file upload')";
3253
-			}elseif ( $args['type'] == 'images' ) {
3253
+			}elseif ($args['type'] == 'images') {
3254 3254
 				//                print_r($args);
3255 3255
 
3256 3256
                 $img_preview = "props.attributes.$key && (function() {
@@ -3262,7 +3262,7 @@  discard block
 block discarded – undo
3262 3262
 							images.push( el('div',{className: 'col p-2',draggable: 'true','data-index': index}, el('img', { src: upload.sizes.thumbnail.url,style: {maxWidth:'100%',background: '#ccc',pointerEvents:'none'}}),el('i',{
3263 3263
 							className: 'fas fa-times-circle text-danger position-absolute  ml-n2 mt-n1 bg-white rounded-circle c-pointer',
3264 3264
 							onClick: function(){
3265
-							    aui_confirm('".__('Are you sure?')."', '".__('Delete')."', '".__('Cancel')."', true).then(function(confirmed) {
3265
+							    aui_confirm('" . __('Are you sure?') . "', '" . __('Delete') . "', '" . __('Cancel') . "', true).then(function(confirmed) {
3266 3266
 if (confirmed) {
3267 3267
 											let new_uploads = JSON.parse(props.attributes.$key);
3268 3268
 											new_uploads.splice(index, 1); //remove
@@ -3336,36 +3336,36 @@  discard block
 block discarded – undo
3336 3336
 
3337 3337
                 //$inside_elements = ",el('div',{},'file upload')";
3338 3338
 			}
3339
-			elseif ( $args['type'] == 'checkbox' ) {
3339
+			elseif ($args['type'] == 'checkbox') {
3340 3340
 				$type = 'CheckboxControl';
3341 3341
 				$extra .= "checked: props.attributes.$key,";
3342 3342
 				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3343
-			} elseif ( $args['type'] == 'textarea' ) {
3343
+			} elseif ($args['type'] == 'textarea') {
3344 3344
 				$type = 'TextareaControl';
3345 3345
 
3346
-			} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3346
+			} elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') {
3347 3347
 				$type = 'SelectControl';
3348 3348
 
3349
-				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3350
-					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3351
-				}elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3352
-					$options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3353
-				}else {
3349
+				if ($args['name'] == 'category' && !empty($args['post_type_linked'])) {
3350
+					$options .= "options: taxonomies_" . str_replace("-", "_", $this->id) . ",";
3351
+				}elseif ($args['name'] == 'sort_by' && !empty($args['post_type_linked'])) {
3352
+					$options .= "options: sort_by_" . str_replace("-", "_", $this->id) . ",";
3353
+				} else {
3354 3354
 
3355
-					if ( ! empty( $args['options'] ) ) {
3355
+					if (!empty($args['options'])) {
3356 3356
 						$options .= "options: [";
3357
-						foreach ( $args['options'] as $option_val => $option_label ) {
3358
-							$options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },";
3357
+						foreach ($args['options'] as $option_val => $option_label) {
3358
+							$options .= "{ value: '" . esc_attr($option_val) . "', label: '" . addslashes($option_label) . "' },";
3359 3359
 						}
3360 3360
 						$options .= "],";
3361 3361
 					}
3362 3362
 				}
3363
-				if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3363
+				if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3364 3364
 					$extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3365 3365
 				}
3366 3366
 
3367
-				if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3368
-					$after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3367
+				if ($args['type'] == 'multiselect' || (isset($args['multiple']) && $args['multiple'])) {
3368
+					$after_elements .= "props.attributes.$key && el( wp.components.Button, {
3369 3369
                                       className: 'components-button components-circular-option-picker__clear is-secondary is-small',
3370 3370
                                       style: {margin:'-8px 0 8px 0',display: 'block'},
3371 3371
                                       onClick: function(){
@@ -3377,7 +3377,7 @@  discard block
 block discarded – undo
3377 3377
                                     'Clear'
3378 3378
                             ),";
3379 3379
 				}
3380
-			} elseif ( $args['type'] == 'tagselect' ) {
3380
+			} elseif ($args['type'] == 'tagselect') {
3381 3381
 //				$type = 'FormTokenField';
3382 3382
 //
3383 3383
 //				if ( ! empty( $args['options'] ) ) {
@@ -3412,23 +3412,23 @@  discard block
 block discarded – undo
3412 3412
 //				$value     = "[]";
3413 3413
 //				$extra .= ' __experimentalExpandOnFocus: true,';
3414 3414
 
3415
-			} elseif ( $args['type'] == 'alignment' ) {
3415
+			} elseif ($args['type'] == 'alignment') {
3416 3416
 				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
3417
-			}elseif ( $args['type'] == 'margins' ) {
3417
+			}elseif ($args['type'] == 'margins') {
3418 3418
 
3419 3419
 			} else {
3420
-				return;// if we have not implemented the control then don't break the JS.
3420
+				return; // if we have not implemented the control then don't break the JS.
3421 3421
 			}
3422 3422
 
3423 3423
 
3424 3424
 
3425 3425
 			// color input does not show the labels so we add them
3426
-			if($args['type']=='color'){
3426
+			if ($args['type'] == 'color') {
3427 3427
 				// add show only if advanced
3428 3428
 				echo $require_advanced;
3429 3429
 				// add setting require if defined
3430 3430
 				echo $element_require;
3431
-				echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
3431
+				echo "el('div', {style: {'marginBottom': '8px'}}, '" . addslashes($args['title']) . "'),";
3432 3432
 			}
3433 3433
 
3434 3434
 			// add show only if advanced
@@ -3440,18 +3440,18 @@  discard block
 block discarded – undo
3440 3440
 			// icon
3441 3441
 			echo $icon;
3442 3442
 			?>
3443
-			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type  : "wp.components.".$type; ?>, {
3443
+			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components." . $type; ?>, {
3444 3444
 			label: <?php
3445
-			if(empty($args['title'])){
3445
+			if (empty($args['title'])) {
3446 3446
                 echo "''";
3447
-			}elseif(empty($args['row']) && !empty($args['device_type'])){
3447
+			}elseif (empty($args['row']) && !empty($args['device_type'])) {
3448 3448
                 ?>el('label', {
3449 3449
 									className: 'components-base-control__label',
3450 3450
 									style: {width:"100%"}
3451 3451
 								},
3452
-								el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['title'] ) ?>'}}),
3453
-								<?php if($device_type_icon){ ?>
3454
-                                    deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})
3452
+								el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes($args['title']) ?>'}}),
3453
+								<?php if ($device_type_icon) { ?>
3454
+                                    deviceType == '<?php echo $device_type; ?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})
3455 3455
 								<?php
3456 3456
                                 }
3457 3457
                                 ?>
@@ -3459,27 +3459,27 @@  discard block
 block discarded – undo
3459 3459
 
3460 3460
 							)<?php
3461 3461
 
3462
-			}else{
3463
-                 ?>'<?php echo addslashes( $args['title'] ); ?>'<?php
3462
+			} else {
3463
+                 ?>'<?php echo addslashes($args['title']); ?>'<?php
3464 3464
 
3465 3465
 			}
3466 3466
 
3467 3467
 			?>,
3468
-			help: <?php if ( isset( $args['desc'] ) ) {
3469
-				echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})";
3470
-			}else{ echo "''"; } ?>,
3468
+			help: <?php if (isset($args['desc'])) {
3469
+				echo "el('span',{dangerouslySetInnerHTML: {__html: '" . wp_kses_post(addslashes($args['desc'])) . "'}})";
3470
+			} else { echo "''"; } ?>,
3471 3471
 			value: <?php echo $value; ?>,
3472
-			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
3473
-				echo "type: '" . addslashes( $args['type'] ) . "',";
3472
+			<?php if ($type == 'TextControl' && $args['type'] != 'text') {
3473
+				echo "type: '" . addslashes($args['type']) . "',";
3474 3474
 			} ?>
3475
-			<?php if ( ! empty( $args['placeholder'] ) ) {
3476
-				echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',";
3475
+			<?php if (!empty($args['placeholder'])) {
3476
+				echo "placeholder: '" . addslashes($args['placeholder']) . "',";
3477 3477
 			} ?>
3478 3478
 			<?php echo $options; ?>
3479 3479
 			<?php echo $extra; ?>
3480 3480
 			<?php echo $custom_attributes; ?>
3481 3481
 			<?php echo $onchangecomplete;
3482
-            if($onchange){
3482
+            if ($onchange) {
3483 3483
             ?>
3484 3484
 			onChange: function ( <?php echo $key; ?> ) {
3485 3485
 			<?php echo $onchange; ?>
@@ -3500,15 +3500,15 @@  discard block
 block discarded – undo
3500 3500
 		 *@todo there is prob a faster way to do this, also we could add some validation here.
3501 3501
 		 *
3502 3502
 		 */
3503
-		public function array_to_attributes( $custom_attributes, $html = false ) {
3503
+		public function array_to_attributes($custom_attributes, $html = false) {
3504 3504
 			$attributes = '';
3505
-			if ( ! empty( $custom_attributes ) ) {
3505
+			if (!empty($custom_attributes)) {
3506 3506
 
3507
-				foreach ( $custom_attributes as $key => $val ) {
3508
-					if(is_array($val)){
3509
-						$attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
3510
-					}else{
3511
-						$attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
3507
+				foreach ($custom_attributes as $key => $val) {
3508
+					if (is_array($val)) {
3509
+						$attributes .= $key . ': {' . $this->array_to_attributes($val, $html) . '},';
3510
+					} else {
3511
+						$attributes .= $html ? " $key='$val' " : "'$key': '$val',";
3512 3512
 					}
3513 3513
 				}
3514 3514
 
@@ -3526,112 +3526,112 @@  discard block
 block discarded – undo
3526 3526
 		 *
3527 3527
 		 * @param $args
3528 3528
 		 */
3529
-		public function block_element( $args, $save = false ) {
3529
+		public function block_element($args, $save = false) {
3530 3530
 
3531 3531
 
3532
-			if ( ! empty( $args ) ) {
3533
-				foreach ( $args as $element => $new_args ) {
3532
+			if (!empty($args)) {
3533
+				foreach ($args as $element => $new_args) {
3534 3534
 
3535
-					if ( is_array( $new_args ) ) { // its an element
3535
+					if (is_array($new_args)) { // its an element
3536 3536
 
3537 3537
 
3538
-						if ( isset( $new_args['element'] ) ) {
3538
+						if (isset($new_args['element'])) {
3539 3539
 
3540
-							if ( isset( $new_args['element_require'] ) ) {
3541
-								echo str_replace( array(
3540
+							if (isset($new_args['element_require'])) {
3541
+								echo str_replace(array(
3542 3542
 										"'+",
3543 3543
 										"+'"
3544
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
3545
-								unset( $new_args['element_require'] );
3544
+									), '', $this->block_props_replace($new_args['element_require'])) . " &&  ";
3545
+								unset($new_args['element_require']);
3546 3546
 							}
3547 3547
 
3548
-                            if($new_args['element']=='InnerBlocks'){
3548
+                            if ($new_args['element'] == 'InnerBlocks') {
3549 3549
                                 echo "\n el( InnerBlocks, {";
3550
-                            }elseif($new_args['element']=='innerBlocksProps'){
3550
+                            }elseif ($new_args['element'] == 'innerBlocksProps') {
3551 3551
                                 $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
3552 3552
                               //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
3553 3553
 //                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
3554 3554
                                 echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
3555 3555
                                 echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
3556
-                                echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
3556
+                                echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : '';
3557 3557
 
3558 3558
                                 echo "} ), {";
3559
-                                echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
3559
+                                echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element($new_args['innerBlocksProps'], $save) : '';
3560 3560
                             //    echo '###';
3561 3561
 
3562 3562
                               //  echo '###';
3563
-                            }elseif($new_args['element']=='BlocksProps'){
3563
+                            }elseif ($new_args['element'] == 'BlocksProps') {
3564 3564
 
3565
-								if ( isset($new_args['if_inner_element']) ) {
3565
+								if (isset($new_args['if_inner_element'])) {
3566 3566
 									$element = $new_args['if_inner_element'];
3567
-								}else {
3568
-									$element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
3567
+								} else {
3568
+									$element = isset($new_args['inner_element']) ? "'" . esc_attr($new_args['inner_element']) . "'" : "'div'";
3569 3569
 								}
3570 3570
 
3571 3571
 								unset($new_args['inner_element']);
3572 3572
                                 echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
3573
-                                echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
3573
+                                echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : '';
3574 3574
 
3575 3575
 
3576 3576
                                // echo "} ),";
3577 3577
 
3578
-                            }else{
3578
+                            } else {
3579 3579
                                 echo "\n el( '" . $new_args['element'] . "', {";
3580 3580
                             }
3581 3581
 
3582 3582
 
3583 3583
 							// get the attributes
3584
-							foreach ( $new_args as $new_key => $new_value ) {
3584
+							foreach ($new_args as $new_key => $new_value) {
3585 3585
 
3586 3586
 
3587
-								if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
3587
+								if ($new_key == 'element' || $new_key == 'content' || $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) {
3588 3588
 									// do nothing
3589 3589
 								} else {
3590
-									echo $this->block_element( array( $new_key => $new_value ),$save );
3590
+									echo $this->block_element(array($new_key => $new_value), $save);
3591 3591
 								}
3592 3592
 							}
3593 3593
 
3594
-							echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
3594
+							echo $new_args['element'] == 'BlocksProps' ? '} ),' : "},"; // end attributes
3595 3595
 
3596 3596
 							// get the content
3597 3597
 							$first_item = 0;
3598
-							foreach ( $new_args as $new_key => $new_value ) {
3599
-								if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
3598
+							foreach ($new_args as $new_key => $new_value) {
3599
+								if ($new_key === 'content' || $new_key === 'if_content' || is_array($new_value)) {
3600 3600
 
3601
-									if ( $new_key === 'content' ) {
3602
-										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
3603
-									}else if ( $new_key === 'if_content' ) {
3604
-										echo  $this->block_props_replace(  $new_value  );
3601
+									if ($new_key === 'content') {
3602
+										echo "'" . $this->block_props_replace(wp_slash($new_value)) . "'";
3603
+									} else if ($new_key === 'if_content') {
3604
+										echo  $this->block_props_replace($new_value);
3605 3605
 									}
3606 3606
 
3607
-									if ( is_array( $new_value ) ) {
3607
+									if (is_array($new_value)) {
3608 3608
 
3609
-										if ( isset( $new_value['element_require'] ) ) {
3610
-											echo str_replace( array(
3609
+										if (isset($new_value['element_require'])) {
3610
+											echo str_replace(array(
3611 3611
 													"'+",
3612 3612
 													"+'"
3613
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
3614
-											unset( $new_value['element_require'] );
3613
+												), '', $this->block_props_replace($new_value['element_require'])) . " &&  ";
3614
+											unset($new_value['element_require']);
3615 3615
 										}
3616 3616
 
3617
-										if ( isset( $new_value['element_repeat'] ) ) {
3617
+										if (isset($new_value['element_repeat'])) {
3618 3618
 											$x = 1;
3619
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
3620
-												$this->block_element( array( '' => $new_value ),$save );
3621
-												$x ++;
3619
+											while ($x <= absint($new_value['element_repeat'])) {
3620
+												$this->block_element(array('' => $new_value), $save);
3621
+												$x++;
3622 3622
 											}
3623 3623
 										} else {
3624
-											$this->block_element( array( '' => $new_value ),$save );
3624
+											$this->block_element(array('' => $new_value), $save);
3625 3625
 										}
3626 3626
 									}
3627
-									$first_item ++;
3627
+									$first_item++;
3628 3628
 								}
3629 3629
 							}
3630 3630
 
3631
-                            if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
3632
-                                echo "))";// end content
3633
-                            }else{
3634
-                                echo ")";// end content
3631
+                            if ($new_args['element'] == 'innerBlocksProps' || $new_args['element'] == 'xBlocksProps') {
3632
+                                echo "))"; // end content
3633
+                            } else {
3634
+                                echo ")"; // end content
3635 3635
                             }
3636 3636
 
3637 3637
 
@@ -3640,26 +3640,26 @@  discard block
 block discarded – undo
3640 3640
 						}
3641 3641
 					} else {
3642 3642
 
3643
-						if ( substr( $element, 0, 3 ) === "if_" ) {
3643
+						if (substr($element, 0, 3) === "if_") {
3644 3644
 							$extra = '';
3645
-							if( strpos($new_args, '[%WrapClass%]') !== false ){
3646
-								$new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
3647
-								$new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
3645
+							if (strpos($new_args, '[%WrapClass%]') !== false) {
3646
+								$new_args = str_replace('[%WrapClass%]"', '" + sd_build_aui_class(props.attributes)', $new_args);
3647
+								$new_args = str_replace('[%WrapClass%]', '+ sd_build_aui_class(props.attributes)', $new_args);
3648 3648
 							}
3649
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
3650
-						} elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
3651
-                            $new_args = str_replace('[%WrapStyle%]','',$new_args);
3652
-                            echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
3649
+							echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ",";
3650
+						} elseif ($element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false) {
3651
+                            $new_args = str_replace('[%WrapStyle%]', '', $new_args);
3652
+                            echo $element . ": {..." . $this->block_props_replace($new_args) . " , ...sd_build_aui_styles(props.attributes) },";
3653 3653
 //                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
3654
-						} elseif ( $element == 'style' ) {
3655
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
3656
-						} elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
3657
-                            $new_args = str_replace('[%WrapClass%]','',$new_args);
3658
-                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
3659
-						} elseif ( $element == 'template' && $new_args ) {
3654
+						} elseif ($element == 'style') {
3655
+							echo $element . ": " . $this->block_props_replace($new_args) . ",";
3656
+						} elseif (($element == 'class' || $element == 'className') && strpos($new_args, '[%WrapClass%]') !== false) {
3657
+                            $new_args = str_replace('[%WrapClass%]', '', $new_args);
3658
+                            echo $element . ": '" . $this->block_props_replace($new_args) . "' + sd_build_aui_class(props.attributes),";
3659
+						} elseif ($element == 'template' && $new_args) {
3660 3660
 							echo $element . ": $new_args,";
3661 3661
 						} else {
3662
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
3662
+							echo $element . ": '" . $this->block_props_replace($new_args) . "',";
3663 3663
 						}
3664 3664
 
3665 3665
 					}
@@ -3674,12 +3674,12 @@  discard block
 block discarded – undo
3674 3674
 		 *
3675 3675
 		 * @return mixed
3676 3676
 		 */
3677
-		public function block_props_replace( $string, $no_wrap = false ) {
3677
+		public function block_props_replace($string, $no_wrap = false) {
3678 3678
 
3679
-			if ( $no_wrap ) {
3680
-				$string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
3679
+			if ($no_wrap) {
3680
+				$string = str_replace(array("[%", "%]"), array("props.attributes.", ""), $string);
3681 3681
 			} else {
3682
-				$string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
3682
+				$string = str_replace(array("[%", "%]"), array("'+props.attributes.", "+'"), $string);
3683 3683
 			}
3684 3684
 
3685 3685
 			return $string;
@@ -3691,62 +3691,62 @@  discard block
 block discarded – undo
3691 3691
 		 * @param array $args
3692 3692
 		 * @param array $instance
3693 3693
 		 */
3694
-		public function widget( $args, $instance ) {
3694
+		public function widget($args, $instance) {
3695 3695
 
3696 3696
 			// get the filtered values
3697
-			$argument_values = $this->argument_values( $instance );
3698
-			$argument_values = $this->string_to_bool( $argument_values );
3699
-			$output          = $this->output( $argument_values, $args );
3697
+			$argument_values = $this->argument_values($instance);
3698
+			$argument_values = $this->string_to_bool($argument_values);
3699
+			$output          = $this->output($argument_values, $args);
3700 3700
 
3701 3701
 			$no_wrap = false;
3702
-			if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
3702
+			if (isset($argument_values['no_wrap']) && $argument_values['no_wrap']) {
3703 3703
 				$no_wrap = true;
3704 3704
 			}
3705 3705
 
3706 3706
 			ob_start();
3707
-			if ( $output && ! $no_wrap ) {
3707
+			if ($output && !$no_wrap) {
3708 3708
 
3709 3709
 				$class_original = $this->options['widget_ops']['classname'];
3710
-				$class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
3710
+				$class = $this->options['widget_ops']['classname'] . " sdel-" . $this->get_instance_hash();
3711 3711
 
3712 3712
 				// Before widget
3713 3713
 				$before_widget = $args['before_widget'];
3714
-				$before_widget = str_replace($class_original,$class,$before_widget);
3715
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
3716
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
3714
+				$before_widget = str_replace($class_original, $class, $before_widget);
3715
+				$before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this);
3716
+				$before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this);
3717 3717
 
3718 3718
 				// After widget
3719 3719
 				$after_widget = $args['after_widget'];
3720
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
3721
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
3720
+				$after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this);
3721
+				$after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this);
3722 3722
 
3723 3723
 				echo $before_widget;
3724 3724
 				// elementor strips the widget wrapping div so we check for and add it back if needed
3725
-				if ( $this->is_elementor_widget_output() ) {
3725
+				if ($this->is_elementor_widget_output()) {
3726 3726
 					// Filter class & attrs for elementor widget output.
3727
-					$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
3728
-					$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
3727
+					$class = apply_filters('wp_super_duper_div_classname', $class, $args, $this);
3728
+					$class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this);
3729 3729
 
3730
-					$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
3731
-					$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
3730
+					$attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this);
3731
+					$attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this);
3732 3732
 
3733
-					echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
3733
+					echo "<span class='" . esc_attr($class) . "' " . $attrs . ">";
3734 3734
 				}
3735
-				echo $this->output_title( $args, $instance );
3735
+				echo $this->output_title($args, $instance);
3736 3736
 				echo $output;
3737
-				if ( $this->is_elementor_widget_output() ) {
3737
+				if ($this->is_elementor_widget_output()) {
3738 3738
 					echo "</span>";
3739 3739
 				}
3740 3740
 				echo $after_widget;
3741
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
3742
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
3741
+			} elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty
3742
+				$output = $this->preview_placeholder_text("{{" . $this->base_id . "}}");
3743 3743
 				echo $output;
3744
-			} elseif ( $output && $no_wrap ) {
3744
+			} elseif ($output && $no_wrap) {
3745 3745
 				echo $output;
3746 3746
 			}
3747 3747
 			$output = ob_get_clean();
3748 3748
 
3749
-			$output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
3749
+			$output = apply_filters('wp_super_duper_widget_output', $output, $instance, $args, $this);
3750 3750
 
3751 3751
 			echo $output;
3752 3752
 		}
@@ -3759,7 +3759,7 @@  discard block
 block discarded – undo
3759 3759
 		 */
3760 3760
 		public function is_elementor_widget_output() {
3761 3761
 			$result = false;
3762
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
3762
+			if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') {
3763 3763
 				$result = true;
3764 3764
 			}
3765 3765
 
@@ -3774,7 +3774,7 @@  discard block
 block discarded – undo
3774 3774
 		 */
3775 3775
 		public function is_elementor_preview() {
3776 3776
 			$result = false;
3777
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
3777
+			if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) {
3778 3778
 				$result = true;
3779 3779
 			}
3780 3780
 
@@ -3789,7 +3789,7 @@  discard block
 block discarded – undo
3789 3789
 		 */
3790 3790
 		public function is_divi_preview() {
3791 3791
 			$result = false;
3792
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
3792
+			if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) {
3793 3793
 				$result = true;
3794 3794
 			}
3795 3795
 
@@ -3804,7 +3804,7 @@  discard block
 block discarded – undo
3804 3804
 		 */
3805 3805
 		public function is_beaver_preview() {
3806 3806
 			$result = false;
3807
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
3807
+			if (isset($_REQUEST['fl_builder'])) {
3808 3808
 				$result = true;
3809 3809
 			}
3810 3810
 
@@ -3819,7 +3819,7 @@  discard block
 block discarded – undo
3819 3819
 		 */
3820 3820
 		public function is_siteorigin_preview() {
3821 3821
 			$result = false;
3822
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
3822
+			if (!empty($_REQUEST['siteorigin_panels_live_editor'])) {
3823 3823
 				$result = true;
3824 3824
 			}
3825 3825
 
@@ -3834,7 +3834,7 @@  discard block
 block discarded – undo
3834 3834
 		 */
3835 3835
 		public function is_cornerstone_preview() {
3836 3836
 			$result = false;
3837
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
3837
+			if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') {
3838 3838
 				$result = true;
3839 3839
 			}
3840 3840
 
@@ -3849,7 +3849,7 @@  discard block
 block discarded – undo
3849 3849
 		 */
3850 3850
 		public function is_fusion_preview() {
3851 3851
 			$result = false;
3852
-			if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
3852
+			if (!empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce'])) {
3853 3853
 				$result = true;
3854 3854
 			}
3855 3855
 
@@ -3864,7 +3864,7 @@  discard block
 block discarded – undo
3864 3864
 		 */
3865 3865
 		public function is_oxygen_preview() {
3866 3866
 			$result = false;
3867
-			if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
3867
+			if (!empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_"))) {
3868 3868
 				$result = true;
3869 3869
 			}
3870 3870
 
@@ -3879,21 +3879,21 @@  discard block
 block discarded – undo
3879 3879
 		 */
3880 3880
 		public function is_preview() {
3881 3881
 			$preview = false;
3882
-			if ( $this->is_divi_preview() ) {
3882
+			if ($this->is_divi_preview()) {
3883 3883
 				$preview = true;
3884
-			} elseif ( $this->is_elementor_preview() ) {
3884
+			} elseif ($this->is_elementor_preview()) {
3885 3885
 				$preview = true;
3886
-			} elseif ( $this->is_beaver_preview() ) {
3886
+			} elseif ($this->is_beaver_preview()) {
3887 3887
 				$preview = true;
3888
-			} elseif ( $this->is_siteorigin_preview() ) {
3888
+			} elseif ($this->is_siteorigin_preview()) {
3889 3889
 				$preview = true;
3890
-			} elseif ( $this->is_cornerstone_preview() ) {
3890
+			} elseif ($this->is_cornerstone_preview()) {
3891 3891
 				$preview = true;
3892
-			} elseif ( $this->is_fusion_preview() ) {
3892
+			} elseif ($this->is_fusion_preview()) {
3893 3893
 				$preview = true;
3894
-			} elseif ( $this->is_oxygen_preview() ) {
3894
+			} elseif ($this->is_oxygen_preview()) {
3895 3895
 				$preview = true;
3896
-			} elseif( $this->is_block_content_call() ) {
3896
+			} elseif ($this->is_block_content_call()) {
3897 3897
 				$preview = true;
3898 3898
 			}
3899 3899
 
@@ -3908,34 +3908,34 @@  discard block
 block discarded – undo
3908 3908
 		 *
3909 3909
 		 * @return string
3910 3910
 		 */
3911
-		public function output_title( $args, $instance = array() ) {
3911
+		public function output_title($args, $instance = array()) {
3912 3912
 			$output = '';
3913
-			if ( ! empty( $instance['title'] ) ) {
3913
+			if (!empty($instance['title'])) {
3914 3914
 				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
3915
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
3915
+				$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
3916 3916
 
3917
-				if(empty($instance['widget_title_tag'])){
3917
+				if (empty($instance['widget_title_tag'])) {
3918 3918
 					$output = $args['before_title'] . $title . $args['after_title'];
3919
-				}else{
3920
-					$title_tag = esc_attr( $instance['widget_title_tag'] );
3919
+				} else {
3920
+					$title_tag = esc_attr($instance['widget_title_tag']);
3921 3921
 
3922 3922
 					// classes
3923 3923
 					$title_classes = array();
3924
-					$title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
3925
-					$title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
3926
-					$title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
3927
-					$title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
3928
-					$title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
3929
-					$title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
3930
-					$title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
3931
-					$title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
3932
-					$title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
3933
-					$title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
3934
-					$title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
3935
-					$title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
3936
-					$title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
3937
-
3938
-					$class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
3924
+					$title_classes[] = !empty($instance['widget_title_size_class']) ? sanitize_html_class($instance['widget_title_size_class']) : '';
3925
+					$title_classes[] = !empty($instance['widget_title_align_class']) ? sanitize_html_class($instance['widget_title_align_class']) : '';
3926
+					$title_classes[] = !empty($instance['widget_title_color_class']) ? "text-" . sanitize_html_class($instance['widget_title_color_class']) : '';
3927
+					$title_classes[] = !empty($instance['widget_title_border_class']) ? sanitize_html_class($instance['widget_title_border_class']) : '';
3928
+					$title_classes[] = !empty($instance['widget_title_border_color_class']) ? "border-" . sanitize_html_class($instance['widget_title_border_color_class']) : '';
3929
+					$title_classes[] = !empty($instance['widget_title_mt_class']) ? "mt-" . absint($instance['widget_title_mt_class']) : '';
3930
+					$title_classes[] = !empty($instance['widget_title_mr_class']) ? "mr-" . absint($instance['widget_title_mr_class']) : '';
3931
+					$title_classes[] = !empty($instance['widget_title_mb_class']) ? "mb-" . absint($instance['widget_title_mb_class']) : '';
3932
+					$title_classes[] = !empty($instance['widget_title_ml_class']) ? "ml-" . absint($instance['widget_title_ml_class']) : '';
3933
+					$title_classes[] = !empty($instance['widget_title_pt_class']) ? "pt-" . absint($instance['widget_title_pt_class']) : '';
3934
+					$title_classes[] = !empty($instance['widget_title_pr_class']) ? "pr-" . absint($instance['widget_title_pr_class']) : '';
3935
+					$title_classes[] = !empty($instance['widget_title_pb_class']) ? "pb-" . absint($instance['widget_title_pb_class']) : '';
3936
+					$title_classes[] = !empty($instance['widget_title_pl_class']) ? "pl-" . absint($instance['widget_title_pl_class']) : '';
3937
+
3938
+					$class = !empty($title_classes) ? implode(" ", $title_classes) : '';
3939 3939
 					$output = "<$title_tag class='$class' >$title</$title_tag>";
3940 3940
 				}
3941 3941
 
@@ -3949,7 +3949,7 @@  discard block
 block discarded – undo
3949 3949
 		 *
3950 3950
 		 * @param array $instance The widget options.
3951 3951
 		 */
3952
-		public function form( $instance ) {
3952
+		public function form($instance) {
3953 3953
 
3954 3954
 			// set widget instance
3955 3955
 			$this->instance = $instance;
@@ -3957,20 +3957,20 @@  discard block
 block discarded – undo
3957 3957
 			// set it as a SD widget
3958 3958
 			echo $this->widget_advanced_toggle();
3959 3959
 
3960
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
3960
+			echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>";
3961 3961
 			$arguments_raw = $this->get_arguments();
3962 3962
 
3963
-			if ( is_array( $arguments_raw ) ) {
3963
+			if (is_array($arguments_raw)) {
3964 3964
 
3965
-				$arguments = $this->group_arguments( $arguments_raw );
3965
+				$arguments = $this->group_arguments($arguments_raw);
3966 3966
 
3967 3967
 				// Do we have sections?
3968 3968
 				$has_sections = $arguments == $arguments_raw ? false : true;
3969 3969
 
3970 3970
 
3971
-				if ( $has_sections ) {
3971
+				if ($has_sections) {
3972 3972
 					$panel_count = 0;
3973
-					foreach ( $arguments as $key => $args ) {
3973
+					foreach ($arguments as $key => $args) {
3974 3974
 
3975 3975
 						?>
3976 3976
 						<script>
@@ -3980,26 +3980,26 @@  discard block
 block discarded – undo
3980 3980
 
3981 3981
 						$hide       = $panel_count ? ' style="display:none;" ' : '';
3982 3982
 						$icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
3983
-						echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
3984
-						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
3983
+						echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes($key) . "'>" . esc_attr($key) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
3984
+						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes($key) . "' $hide>";
3985 3985
 
3986
-						foreach ( $args as $k => $a ) {
3986
+						foreach ($args as $k => $a) {
3987 3987
 
3988 3988
 							$this->widget_inputs_row_start($k, $a);
3989
-							$this->widget_inputs( $a, $instance );
3989
+							$this->widget_inputs($a, $instance);
3990 3990
 							$this->widget_inputs_row_end($k, $a);
3991 3991
 
3992 3992
 						}
3993 3993
 
3994 3994
 						echo "</div>";
3995 3995
 
3996
-						$panel_count ++;
3996
+						$panel_count++;
3997 3997
 
3998 3998
 					}
3999 3999
 				} else {
4000
-					foreach ( $arguments as $key => $args ) {
4000
+					foreach ($arguments as $key => $args) {
4001 4001
 						$this->widget_inputs_row_start($key, $args);
4002
-						$this->widget_inputs( $args, $instance );
4002
+						$this->widget_inputs($args, $instance);
4003 4003
 						$this->widget_inputs_row_end($key, $args);
4004 4004
 					}
4005 4005
 				}
@@ -4007,33 +4007,33 @@  discard block
 block discarded – undo
4007 4007
 			}
4008 4008
 		}
4009 4009
 
4010
-		public function widget_inputs_row_start($key, $args){
4011
-			if(!empty($args['row'])){
4010
+		public function widget_inputs_row_start($key, $args) {
4011
+			if (!empty($args['row'])) {
4012 4012
 				// maybe open
4013
-				if(!empty($args['row']['open'])){
4013
+				if (!empty($args['row']['open'])) {
4014 4014
 					?>
4015
-					<div class='bsui sd-argument ' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php if ( !empty($args['row']['element_require'])) {
4016
-						echo $this->convert_element_require( $args['row']['element_require'] );
4015
+					<div class='bsui sd-argument ' data-argument='<?php echo esc_attr($args['row']['key']); ?>' data-element_require='<?php if (!empty($args['row']['element_require'])) {
4016
+						echo $this->convert_element_require($args['row']['element_require']);
4017 4017
 					} ?>'>
4018
-					<?php if(!empty($args['row']['title'])){ ?>
4019
-					<label class="mb-0 "><?php echo esc_attr( $args['row']['title'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label>
4018
+					<?php if (!empty($args['row']['title'])) { ?>
4019
+					<label class="mb-0 "><?php echo esc_attr($args['row']['title']); ?><?php echo $this->widget_field_desc($args['row']); ?></label>
4020 4020
 					<?php }?>
4021
-					<div class='row <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>'>
4021
+					<div class='row <?php if (!empty($args['row']['class'])) { echo esc_attr($args['row']['class']); } ?>'>
4022 4022
 					<div class='col pr-2'>
4023 4023
 					<?php
4024
-				}elseif(!empty($args['row']['close'])){
4024
+				}elseif (!empty($args['row']['close'])) {
4025 4025
 					echo "<div class='col pl-0'>";
4026
-				}else{
4026
+				} else {
4027 4027
 					echo "<div class='col pl-0 pr-2'>";
4028 4028
 				}
4029 4029
 			}
4030 4030
 		}
4031 4031
 
4032
-		public function widget_inputs_row_end($key, $args){
4032
+		public function widget_inputs_row_end($key, $args) {
4033 4033
 
4034
-			if(!empty($args['row'])){
4034
+			if (!empty($args['row'])) {
4035 4035
 				// maybe close
4036
-				if(!empty($args['row']['close'])){
4036
+				if (!empty($args['row']['close'])) {
4037 4037
 					echo "</div></div>";
4038 4038
 				}
4039 4039
 
@@ -4049,7 +4049,7 @@  discard block
 block discarded – undo
4049 4049
 		public function widget_advanced_toggle() {
4050 4050
 
4051 4051
 			$output = '';
4052
-			if ( $this->block_show_advanced() ) {
4052
+			if ($this->block_show_advanced()) {
4053 4053
 				$val = 1;
4054 4054
 			} else {
4055 4055
 				$val = 0;
@@ -4069,14 +4069,14 @@  discard block
 block discarded – undo
4069 4069
 		 *@since 1.0.0
4070 4070
 		 *
4071 4071
 		 */
4072
-		public function convert_element_require( $input ) {
4072
+		public function convert_element_require($input) {
4073 4073
 
4074
-			$input = str_replace( "'", '"', $input );// we only want double quotes
4074
+			$input = str_replace("'", '"', $input); // we only want double quotes
4075 4075
 
4076
-			$output = esc_attr( str_replace( array( "[%", "%]" ), array(
4076
+			$output = esc_attr(str_replace(array("[%", "%]"), array(
4077 4077
 				"jQuery(form).find('[data-argument=\"",
4078 4078
 				"\"]').find('input,select,textarea').val()"
4079
-			), $input ) );
4079
+			), $input));
4080 4080
 
4081 4081
 			return $output;
4082 4082
 		}
@@ -4087,56 +4087,56 @@  discard block
 block discarded – undo
4087 4087
 		 * @param $args
4088 4088
 		 * @param $instance
4089 4089
 		 */
4090
-		public function widget_inputs( $args, $instance ) {
4090
+		public function widget_inputs($args, $instance) {
4091 4091
 
4092 4092
 			$class             = "";
4093 4093
 			$element_require   = "";
4094 4094
 			$custom_attributes = "";
4095 4095
 
4096 4096
 			// get value
4097
-			if ( isset( $instance[ $args['name'] ] ) ) {
4098
-				$value = $instance[ $args['name'] ];
4099
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4100
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4097
+			if (isset($instance[$args['name']])) {
4098
+				$value = $instance[$args['name']];
4099
+			} elseif (!isset($instance[$args['name']]) && !empty($args['default'])) {
4100
+				$value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']);
4101 4101
 			} else {
4102 4102
 				$value = '';
4103 4103
 			}
4104 4104
 
4105 4105
 			// get placeholder
4106
-			if ( ! empty( $args['placeholder'] ) ) {
4107
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4106
+			if (!empty($args['placeholder'])) {
4107
+				$placeholder = "placeholder='" . esc_html($args['placeholder']) . "'";
4108 4108
 			} else {
4109 4109
 				$placeholder = '';
4110 4110
 			}
4111 4111
 
4112 4112
 			// get if advanced
4113
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4113
+			if (isset($args['advanced']) && $args['advanced']) {
4114 4114
 				$class .= " sd-advanced-setting ";
4115 4115
 			}
4116 4116
 
4117 4117
 			// element_require
4118
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4118
+			if (isset($args['element_require']) && $args['element_require']) {
4119 4119
 				$element_require = $args['element_require'];
4120 4120
 			}
4121 4121
 
4122 4122
 			// custom_attributes
4123
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4124
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4123
+			if (isset($args['custom_attributes']) && $args['custom_attributes']) {
4124
+				$custom_attributes = $this->array_to_attributes($args['custom_attributes'], true);
4125 4125
 			}
4126 4126
 
4127 4127
 
4128 4128
 			// before wrapper
4129 4129
 			?>
4130
-			<p class="sd-argument <?php echo esc_attr( $class ); ?>"
4131
-			data-argument='<?php echo esc_attr( $args['name'] ); ?>'
4132
-			data-element_require='<?php if ( $element_require ) {
4133
-				echo $this->convert_element_require( $element_require );
4130
+			<p class="sd-argument <?php echo esc_attr($class); ?>"
4131
+			data-argument='<?php echo esc_attr($args['name']); ?>'
4132
+			data-element_require='<?php if ($element_require) {
4133
+				echo $this->convert_element_require($element_require);
4134 4134
 			} ?>'
4135 4135
 			>
4136 4136
 			<?php
4137 4137
 
4138 4138
 
4139
-			switch ( $args['type'] ) {
4139
+			switch ($args['type']) {
4140 4140
 				//array('text','password','number','email','tel','url','color')
4141 4141
 				case "text":
4142 4142
 				case "password":
@@ -4147,46 +4147,46 @@  discard block
 block discarded – undo
4147 4147
 				case "color":
4148 4148
 					?>
4149 4149
 					<label
4150
-						for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4150
+						for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label>
4151 4151
 					<input <?php echo $placeholder; ?> class="widefat"
4152 4152
 						<?php echo $custom_attributes; ?>
4153
-						                               id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
4154
-						                               name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"
4155
-						                               type="<?php echo esc_attr( $args['type'] ); ?>"
4156
-						                               value="<?php echo esc_attr( $value ); ?>">
4153
+						                               id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
4154
+						                               name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>"
4155
+						                               type="<?php echo esc_attr($args['type']); ?>"
4156
+						                               value="<?php echo esc_attr($value); ?>">
4157 4157
 					<?php
4158 4158
 
4159 4159
 					break;
4160 4160
 				case "select":
4161
-					$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4162
-					if ( $multiple ) {
4163
-						if ( empty( $value ) ) {
4161
+					$multiple = isset($args['multiple']) && $args['multiple'] ? true : false;
4162
+					if ($multiple) {
4163
+						if (empty($value)) {
4164 4164
 							$value = array();
4165 4165
 						}
4166 4166
 					}
4167 4167
 					?>
4168 4168
 					<label
4169
-						for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4169
+						for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label>
4170 4170
 					<select <?php echo $placeholder; ?> class="widefat"
4171 4171
 						<?php echo $custom_attributes; ?>
4172
-						                                id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
4173
-						                                name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) );
4174
-						                                if ( $multiple ) {
4172
+						                                id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
4173
+						                                name="<?php echo esc_attr($this->get_field_name($args['name']));
4174
+						                                if ($multiple) {
4175 4175
 							                                echo "[]";
4176 4176
 						                                } ?>"
4177
-						<?php if ( $multiple ) {
4177
+						<?php if ($multiple) {
4178 4178
 							echo "multiple";
4179 4179
 						} //@todo not implemented yet due to gutenberg not supporting it
4180 4180
 						?>
4181 4181
 					>
4182 4182
 						<?php
4183 4183
 
4184
-						if ( ! empty( $args['options'] ) ) {
4185
-							foreach ( $args['options'] as $val => $label ) {
4186
-								if ( $multiple ) {
4187
-									$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4184
+						if (!empty($args['options'])) {
4185
+							foreach ($args['options'] as $val => $label) {
4186
+								if ($multiple) {
4187
+									$selected = in_array($val, $value) ? 'selected="selected"' : '';
4188 4188
 								} else {
4189
-									$selected = selected( $value, $val, false );
4189
+									$selected = selected($value, $val, false);
4190 4190
 								}
4191 4191
 								echo "<option value='$val' " . $selected . ">$label</option>";
4192 4192
 							}
@@ -4198,32 +4198,32 @@  discard block
 block discarded – undo
4198 4198
 				case "checkbox":
4199 4199
 					?>
4200 4200
 					<input <?php echo $placeholder; ?>
4201
-						<?php checked( 1, $value, true ) ?>
4201
+						<?php checked(1, $value, true) ?>
4202 4202
 						<?php echo $custom_attributes; ?>
4203
-						class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
4204
-						name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox"
4203
+						class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
4204
+						name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox"
4205 4205
 						value="1">
4206 4206
 					<label
4207
-						for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4207
+						for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label>
4208 4208
 					<?php
4209 4209
 					break;
4210 4210
 				case "textarea":
4211 4211
 					?>
4212 4212
 					<label
4213
-						for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4213
+						for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label>
4214 4214
 					<textarea <?php echo $placeholder; ?> class="widefat"
4215 4215
 						<?php echo $custom_attributes; ?>
4216
-						                                  id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
4217
-						                                  name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"
4218
-					><?php echo esc_attr( $value ); ?></textarea>
4216
+						                                  id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
4217
+						                                  name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>"
4218
+					><?php echo esc_attr($value); ?></textarea>
4219 4219
 					<?php
4220 4220
 
4221 4221
 					break;
4222 4222
 				case "hidden":
4223 4223
 					?>
4224
-					<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
4225
-					       name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden"
4226
-					       value="<?php echo esc_attr( $value ); ?>">
4224
+					<input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
4225
+					       name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden"
4226
+					       value="<?php echo esc_attr($value); ?>">
4227 4227
 					<?php
4228 4228
 					break;
4229 4229
 				default:
@@ -4238,15 +4238,15 @@  discard block
 block discarded – undo
4238 4238
 
4239 4239
 		}
4240 4240
 
4241
-		public function get_widget_icon($icon = 'box-top', $title = ''){
4242
-			if($icon=='box-top'){
4243
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4244
-			}elseif($icon=='box-right'){
4245
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4246
-			}elseif($icon=='box-bottom'){
4247
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4248
-			}elseif($icon=='box-left'){
4249
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4241
+		public function get_widget_icon($icon = 'box-top', $title = '') {
4242
+			if ($icon == 'box-top') {
4243
+				return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4244
+			}elseif ($icon == 'box-right') {
4245
+				return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4246
+			}elseif ($icon == 'box-bottom') {
4247
+				return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4248
+			}elseif ($icon == 'box-left') {
4249
+				return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4250 4250
 			}
4251 4251
 		}
4252 4252
 
@@ -4258,14 +4258,14 @@  discard block
 block discarded – undo
4258 4258
 		 * @return string
4259 4259
 		 * @todo, need to make its own tooltip script
4260 4260
 		 */
4261
-		public function widget_field_desc( $args ) {
4261
+		public function widget_field_desc($args) {
4262 4262
 
4263 4263
 			$description = '';
4264
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
4265
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4266
-					$description = $this->desc_tip( $args['desc'] );
4264
+			if (isset($args['desc']) && $args['desc']) {
4265
+				if (isset($args['desc_tip']) && $args['desc_tip']) {
4266
+					$description = $this->desc_tip($args['desc']);
4267 4267
 				} else {
4268
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4268
+					$description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>';
4269 4269
 				}
4270 4270
 			}
4271 4271
 
@@ -4279,12 +4279,12 @@  discard block
 block discarded – undo
4279 4279
 		 *
4280 4280
 		 * @return string
4281 4281
 		 */
4282
-		public function widget_field_title( $args ) {
4282
+		public function widget_field_title($args) {
4283 4283
 
4284 4284
 			$title = '';
4285
-			if ( isset( $args['title'] ) && $args['title'] ) {
4286
-				if ( isset( $args['icon'] ) && $args['icon'] ) {
4287
-					$title = self::get_widget_icon( $args['icon'], $args['title']  );
4285
+			if (isset($args['title']) && $args['title']) {
4286
+				if (isset($args['icon']) && $args['icon']) {
4287
+					$title = self::get_widget_icon($args['icon'], $args['title']);
4288 4288
 				} else {
4289 4289
 					$title = esc_attr($args['title']);
4290 4290
 				}
@@ -4301,11 +4301,11 @@  discard block
 block discarded – undo
4301 4301
 		 *
4302 4302
 		 * @return string
4303 4303
 		 */
4304
-		function desc_tip( $tip, $allow_html = false ) {
4305
-			if ( $allow_html ) {
4306
-				$tip = $this->sanitize_tooltip( $tip );
4304
+		function desc_tip($tip, $allow_html = false) {
4305
+			if ($allow_html) {
4306
+				$tip = $this->sanitize_tooltip($tip);
4307 4307
 			} else {
4308
-				$tip = esc_attr( $tip );
4308
+				$tip = esc_attr($tip);
4309 4309
 			}
4310 4310
 
4311 4311
 			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -4318,8 +4318,8 @@  discard block
 block discarded – undo
4318 4318
 		 *
4319 4319
 		 * @return string
4320 4320
 		 */
4321
-		public function sanitize_tooltip( $var ) {
4322
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4321
+		public function sanitize_tooltip($var) {
4322
+			return htmlspecialchars(wp_kses(html_entity_decode($var), array(
4323 4323
 				'br'     => array(),
4324 4324
 				'em'     => array(),
4325 4325
 				'strong' => array(),
@@ -4329,7 +4329,7 @@  discard block
 block discarded – undo
4329 4329
 				'li'     => array(),
4330 4330
 				'ol'     => array(),
4331 4331
 				'p'      => array(),
4332
-			) ) );
4332
+			)));
4333 4333
 		}
4334 4334
 
4335 4335
 		/**
@@ -4341,23 +4341,23 @@  discard block
 block discarded – undo
4341 4341
 		 * @return array
4342 4342
 		 * @todo we should add some sanitation here.
4343 4343
 		 */
4344
-		public function update( $new_instance, $old_instance ) {
4344
+		public function update($new_instance, $old_instance) {
4345 4345
 
4346 4346
 			//save the widget
4347
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
4347
+			$instance = array_merge((array) $old_instance, (array) $new_instance);
4348 4348
 
4349 4349
 			// set widget instance
4350 4350
 			$this->instance = $instance;
4351 4351
 
4352
-			if ( empty( $this->arguments ) ) {
4352
+			if (empty($this->arguments)) {
4353 4353
 				$this->get_arguments();
4354 4354
 			}
4355 4355
 
4356 4356
 			// check for checkboxes
4357
-			if ( ! empty( $this->arguments ) ) {
4358
-				foreach ( $this->arguments as $argument ) {
4359
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4360
-						$instance[ $argument['name'] ] = '0';
4357
+			if (!empty($this->arguments)) {
4358
+				foreach ($this->arguments as $argument) {
4359
+					if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) {
4360
+						$instance[$argument['name']] = '0';
4361 4361
 					}
4362 4362
 				}
4363 4363
 			}
@@ -4375,7 +4375,7 @@  discard block
 block discarded – undo
4375 4375
 		 */
4376 4376
 		public function is_block_content_call() {
4377 4377
 			$result = false;
4378
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4378
+			if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') {
4379 4379
 				$result = true;
4380 4380
 			}
4381 4381
 
@@ -4388,9 +4388,9 @@  discard block
 block discarded – undo
4388 4388
 		 * @return string
4389 4389
 		 *@since 1.0.20
4390 4390
 		 */
4391
-		public function get_instance_hash(){
4392
-			$instance_string = $this->base_id.serialize($this->instance);
4393
-			return hash('crc32b',$instance_string);
4391
+		public function get_instance_hash() {
4392
+			$instance_string = $this->base_id . serialize($this->instance);
4393
+			return hash('crc32b', $instance_string);
4394 4394
 		}
4395 4395
 
4396 4396
 		/**
@@ -4401,14 +4401,14 @@  discard block
 block discarded – undo
4401 4401
 		 * @return string
4402 4402
 		 *@since 1.0.20
4403 4403
 		 */
4404
-		public function get_instance_style($rules = array()){
4404
+		public function get_instance_style($rules = array()) {
4405 4405
 			$css = '';
4406 4406
 
4407
-			if(!empty($rules)){
4407
+			if (!empty($rules)) {
4408 4408
 				$rules = array_unique($rules);
4409 4409
 				$instance_hash = $this->get_instance_hash();
4410 4410
 				$css .= "<style>";
4411
-				foreach($rules as $rule){
4411
+				foreach ($rules as $rule) {
4412 4412
 					$css .= ".sdel-$instance_hash $rule";
4413 4413
 				}
4414 4414
 				$css .= "</style>";
@@ -4426,9 +4426,9 @@  discard block
 block discarded – undo
4426 4426
 		 *@since 1.0.28
4427 4427
 		 *
4428 4428
 		 */
4429
-		public function encode_shortcodes( $content ) {
4429
+		public function encode_shortcodes($content) {
4430 4430
 			// Avoids existing encoded tags.
4431
-			$trans   = array(
4431
+			$trans = array(
4432 4432
 				'&#91;' => '&#091;',
4433 4433
 				'&#93;' => '&#093;',
4434 4434
 				'&amp;#91;' => '&#091;',
@@ -4439,7 +4439,7 @@  discard block
 block discarded – undo
4439 4439
 				'&amp;gt;' => '&0gt;',
4440 4440
 			);
4441 4441
 
4442
-			$content = strtr( $content, $trans );
4442
+			$content = strtr($content, $trans);
4443 4443
 
4444 4444
 			$trans   = array(
4445 4445
 				'[' => '&#91;',
@@ -4450,7 +4450,7 @@  discard block
 block discarded – undo
4450 4450
 				"'" => '&apos;',
4451 4451
 			);
4452 4452
 
4453
-			$content = strtr( $content, $trans );
4453
+			$content = strtr($content, $trans);
4454 4454
 
4455 4455
 			return $content;
4456 4456
 		}
@@ -4464,8 +4464,8 @@  discard block
 block discarded – undo
4464 4464
 		 *@since 1.0.28
4465 4465
 		 *
4466 4466
 		 */
4467
-		public function decode_shortcodes( $content ) {
4468
-			$trans   = array(
4467
+		public function decode_shortcodes($content) {
4468
+			$trans = array(
4469 4469
 				'&#91;' => '[',
4470 4470
 				'&#93;' => ']',
4471 4471
 				'&amp;#91;' => '[',
@@ -4478,7 +4478,7 @@  discard block
 block discarded – undo
4478 4478
 				'&apos;' => "'",
4479 4479
 			);
4480 4480
 
4481
-			$content = strtr( $content, $trans );
4481
+			$content = strtr($content, $trans);
4482 4482
 
4483 4483
 			$trans   = array(
4484 4484
 				'&#091;' => '&#91;',
@@ -4491,7 +4491,7 @@  discard block
 block discarded – undo
4491 4491
 				'&amp;0gt;' => '&gt;',
4492 4492
 			);
4493 4493
 
4494
-			$content = strtr( $content, $trans );
4494
+			$content = strtr($content, $trans);
4495 4495
 
4496 4496
 			return $content;
4497 4497
 		}
Please login to merge, or discard this patch.