@@ -7,21 +7,21 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Make sure that the form is active. |
| 13 | -if ( ! $form->is_active() ) { |
|
| 13 | +if (!$form->is_active()) { |
|
| 14 | 14 | echo aui()->alert( |
| 15 | 15 | array( |
| 16 | 16 | 'type' => 'warning', |
| 17 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
| 17 | + 'content' => __('This payment form is no longer active', 'invoicing'), |
|
| 18 | 18 | ) |
| 19 | 19 | ); |
| 20 | 20 | return; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | // Fires before displaying a payment form. |
| 24 | -do_action( 'getpaid_before_payment_form', $form ); |
|
| 24 | +do_action('getpaid_before_payment_form', $form); |
|
| 25 | 25 | |
| 26 | 26 | ?> |
| 27 | 27 | |
@@ -31,44 +31,44 @@ discard block |
||
| 31 | 31 | <?php |
| 32 | 32 | |
| 33 | 33 | // Fires when printing the top of a payment form. |
| 34 | - do_action( 'getpaid_payment_form_top', $form ); |
|
| 34 | + do_action('getpaid_payment_form_top', $form); |
|
| 35 | 35 | |
| 36 | 36 | // Add the vat validation nonce. |
| 37 | - wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
| 37 | + wp_nonce_field('vat_validation', '_wpi_nonce'); |
|
| 38 | 38 | |
| 39 | 39 | // And the optional invoice id. |
| 40 | - if ( ! empty( $form->invoice ) ) { |
|
| 41 | - echo getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() ); |
|
| 40 | + if (!empty($form->invoice)) { |
|
| 41 | + echo getpaid_hidden_field('invoice_id', $form->invoice->get_id()); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // We also want to include the form id. |
| 45 | - echo getpaid_hidden_field( 'form_id', $form->get_id() ); |
|
| 45 | + echo getpaid_hidden_field('form_id', $form->get_id()); |
|
| 46 | 46 | |
| 47 | 47 | // And an indication that this is a payment form submission. |
| 48 | - echo getpaid_hidden_field( 'getpaid_payment_form_submission', '1' ); |
|
| 48 | + echo getpaid_hidden_field('getpaid_payment_form_submission', '1'); |
|
| 49 | 49 | |
| 50 | 50 | // Fires before displaying payment form elements. |
| 51 | - do_action( 'getpaid_payment_form_before_elements', $form ); |
|
| 51 | + do_action('getpaid_payment_form_before_elements', $form); |
|
| 52 | 52 | |
| 53 | 53 | // Display the elements. |
| 54 | - foreach ( $form->get_elements() as $element ) { |
|
| 55 | - if ( isset( $element['type'] ) ) { |
|
| 56 | - do_action( 'getpaid_payment_form_element', $element, $form ); |
|
| 57 | - do_action( "getpaid_payment_form_element_{$element['type']}_template", $element, $form ); |
|
| 54 | + foreach ($form->get_elements() as $element) { |
|
| 55 | + if (isset($element['type'])) { |
|
| 56 | + do_action('getpaid_payment_form_element', $element, $form); |
|
| 57 | + do_action("getpaid_payment_form_element_{$element['type']}_template", $element, $form); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Fires after displaying payment form elements. |
| 62 | - do_action( 'getpaid_payment_form_after_elements', $form ); |
|
| 62 | + do_action('getpaid_payment_form_after_elements', $form); |
|
| 63 | 63 | |
| 64 | 64 | echo "<div class='getpaid-payment-form-errors alert alert-danger d-none'></div>"; |
| 65 | 65 | |
| 66 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
| 66 | + if (wpinv_current_user_can_manage_invoicing()) { |
|
| 67 | 67 | |
| 68 | 68 | edit_post_link( |
| 69 | - __( 'Edit this form.', 'invoicing' ), |
|
| 69 | + __('Edit this form.', 'invoicing'), |
|
| 70 | 70 | '<small class="form-text text-muted">', |
| 71 | - ' ' . __( 'This is only visible to website administators.', 'invoicing' ) . '</small>', |
|
| 71 | + ' ' . __('This is only visible to website administators.', 'invoicing') . '</small>', |
|
| 72 | 72 | $form->get_id(), |
| 73 | 73 | 'text-danger' |
| 74 | 74 | ); |
@@ -82,4 +82,4 @@ discard block |
||
| 82 | 82 | <?php |
| 83 | 83 | |
| 84 | 84 | // Fires after displaying a payment form. |
| 85 | -do_action( 'getpaid_after_payment_form', $form ); |
|
| 85 | +do_action('getpaid_after_payment_form', $form); |
|
@@ -7,13 +7,13 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -if ( empty( $text ) ) { |
|
| 13 | - $text = __( 'Total to pay:', 'invoicing' ); |
|
| 12 | +if (empty($text)) { |
|
| 13 | + $text = __('Total to pay:', 'invoicing'); |
|
| 14 | 14 | } |
| 15 | 15 | ?> |
| 16 | 16 | <div class="form-group mt-4"> |
| 17 | - <strong><?php echo sanitize_text_field( $text ); ?></strong> |
|
| 17 | + <strong><?php echo sanitize_text_field($text); ?></strong> |
|
| 18 | 18 | <span class="getpaid-checkout-total-payable"></span> |
| 19 | 19 | </div> |
@@ -7,14 +7,14 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | global $wpinv_euvat; |
| 13 | 13 | |
| 14 | 14 | // Prepare the company name. |
| 15 | 15 | $company_name = $wpinv_euvat->get_company_name(); |
| 16 | 16 | |
| 17 | -if ( empty( $company_name ) ) { |
|
| 17 | +if (empty($company_name)) { |
|
| 18 | 18 | $company_name = wpinv_get_business_name(); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -24,30 +24,30 @@ discard block |
||
| 24 | 24 | <div class="row"> |
| 25 | 25 | |
| 26 | 26 | <div class="invoice-company-address-label col-2"> |
| 27 | - <strong><?php _e( 'From:', 'invoicing' ) ?></strong> |
|
| 27 | + <strong><?php _e('From:', 'invoicing') ?></strong> |
|
| 28 | 28 | </div> |
| 29 | 29 | |
| 30 | 30 | <div class="invoice-company-address-value col-10"> |
| 31 | 31 | |
| 32 | - <?php do_action( 'getpaid_company_address_top' ); ?> |
|
| 32 | + <?php do_action('getpaid_company_address_top'); ?> |
|
| 33 | 33 | |
| 34 | 34 | <div class="name"> |
| 35 | - <a target="_blank" class="text-dark" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
| 36 | - <?php echo esc_html( wpinv_get_business_name() ); ?> |
|
| 35 | + <a target="_blank" class="text-dark" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
| 36 | + <?php echo esc_html(wpinv_get_business_name()); ?> |
|
| 37 | 37 | </a> |
| 38 | 38 | </div> |
| 39 | 39 | |
| 40 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
| 41 | - <?php echo $address;?> |
|
| 40 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
| 41 | + <?php echo $address; ?> |
|
| 42 | 42 | <?php } ?> |
| 43 | 43 | |
| 44 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
| 44 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
| 45 | 45 | <div class="email_from"> |
| 46 | - <?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?> |
|
| 46 | + <?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?> |
|
| 47 | 47 | </div> |
| 48 | 48 | <?php } ?> |
| 49 | 49 | |
| 50 | - <?php do_action( 'getpaid_company_address_bottom' ); ?> |
|
| 50 | + <?php do_action('getpaid_company_address_bottom'); ?> |
|
| 51 | 51 | |
| 52 | 52 | </div> |
| 53 | 53 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if (!defined('ABSPATH')) { |
|
| 4 | 4 | exit; // Exit if accessed directly |
| 5 | 5 | } |
| 6 | 6 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return string The rendered component. |
| 20 | 20 | */ |
| 21 | - public static function get($args = array()){ |
|
| 21 | + public static function get($args = array()) { |
|
| 22 | 22 | $defaults = array( |
| 23 | 23 | 'type' => 'a', // a, button, badge |
| 24 | 24 | 'href' => '#', |
@@ -42,38 +42,38 @@ discard block |
||
| 42 | 42 | /** |
| 43 | 43 | * Parse incoming $args into an array and merge it with $defaults |
| 44 | 44 | */ |
| 45 | - $args = wp_parse_args( $args, $defaults ); |
|
| 45 | + $args = wp_parse_args($args, $defaults); |
|
| 46 | 46 | $output = ''; |
| 47 | - if ( ! empty( $args['type'] ) ) { |
|
| 47 | + if (!empty($args['type'])) { |
|
| 48 | 48 | $type = $args['type'] != 'a' ? esc_attr($args['type']) : 'a'; |
| 49 | 49 | |
| 50 | 50 | // open/type |
| 51 | - if($type=='a'){ |
|
| 51 | + if ($type == 'a') { |
|
| 52 | 52 | $new_window = !empty($args['new_window']) ? ' target="_blank" ' : ''; |
| 53 | - $output .= '<a href="' . $args['href'] . '"'.$new_window; |
|
| 54 | - }elseif($type=='badge'){ |
|
| 53 | + $output .= '<a href="' . $args['href'] . '"' . $new_window; |
|
| 54 | + }elseif ($type == 'badge') { |
|
| 55 | 55 | $output .= '<span '; |
| 56 | - }else{ |
|
| 56 | + } else { |
|
| 57 | 57 | $output .= '<button type="' . $type . '" '; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // name |
| 61 | - if(!empty($args['name'])){ |
|
| 61 | + if (!empty($args['name'])) { |
|
| 62 | 62 | $output .= AUI_Component_Helper::name($args['name']); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // id |
| 66 | - if(!empty($args['id'])){ |
|
| 66 | + if (!empty($args['id'])) { |
|
| 67 | 67 | $output .= AUI_Component_Helper::id($args['id']); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // title |
| 71 | - if(!empty($args['title'])){ |
|
| 71 | + if (!empty($args['title'])) { |
|
| 72 | 72 | $output .= AUI_Component_Helper::title($args['title']); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // value |
| 76 | - if(!empty($args['value'])){ |
|
| 76 | + if (!empty($args['value'])) { |
|
| 77 | 77 | $output .= AUI_Component_Helper::value($args['value']); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -88,18 +88,18 @@ discard block |
||
| 88 | 88 | $output .= AUI_Component_Helper::aria_attributes($args); |
| 89 | 89 | |
| 90 | 90 | // extra attributes |
| 91 | - if(!empty($args['extra_attributes'])){ |
|
| 91 | + if (!empty($args['extra_attributes'])) { |
|
| 92 | 92 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // onclick, we don't escape this |
| 96 | - if(!empty($args['onclick'])){ |
|
| 97 | - $output .= ' onclick="'.$args['onclick'].'" '; |
|
| 96 | + if (!empty($args['onclick'])) { |
|
| 97 | + $output .= ' onclick="' . $args['onclick'] . '" '; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // style, we don't escape this |
| 101 | - if(!empty($args['style'])){ |
|
| 102 | - $output .= ' style="'.$args['style'].'" '; |
|
| 101 | + if (!empty($args['style'])) { |
|
| 102 | + $output .= ' style="' . $args['style'] . '" '; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // close opening tag |
@@ -108,37 +108,37 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | // hover content |
| 110 | 110 | $hover_content = false; |
| 111 | - if(!empty($args['hover_content']) || !empty($args['hover_icon'])){ |
|
| 112 | - $output .= "<span class='hover-content'>".AUI_Component_Helper::icon($args['hover_icon'],$args['hover_content']).$args['hover_content']."</span>"; |
|
| 111 | + if (!empty($args['hover_content']) || !empty($args['hover_icon'])) { |
|
| 112 | + $output .= "<span class='hover-content'>" . AUI_Component_Helper::icon($args['hover_icon'], $args['hover_content']) . $args['hover_content'] . "</span>"; |
|
| 113 | 113 | $hover_content = true; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // content |
| 117 | - if($hover_content){$output .= "<span class='hover-content-original'>";} |
|
| 118 | - if(!empty($args['content']) || !empty($args['icon'])){ |
|
| 119 | - $output .= AUI_Component_Helper::icon($args['icon'],$args['content'],$args['icon_extra_attributes']).$args['content']; |
|
| 117 | + if ($hover_content) {$output .= "<span class='hover-content-original'>"; } |
|
| 118 | + if (!empty($args['content']) || !empty($args['icon'])) { |
|
| 119 | + $output .= AUI_Component_Helper::icon($args['icon'], $args['content'], $args['icon_extra_attributes']) . $args['content']; |
|
| 120 | 120 | } |
| 121 | - if($hover_content){$output .= "</span>";} |
|
| 121 | + if ($hover_content) {$output .= "</span>"; } |
|
| 122 | 122 | |
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | // close |
| 126 | - if($type=='a'){ |
|
| 126 | + if ($type == 'a') { |
|
| 127 | 127 | $output .= '</a>'; |
| 128 | - }elseif($type=='badge'){ |
|
| 128 | + }elseif ($type == 'badge') { |
|
| 129 | 129 | $output .= '</span>'; |
| 130 | - }else{ |
|
| 130 | + } else { |
|
| 131 | 131 | $output .= '</button>'; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // maybe new line after? This adds better spacing between buttons. |
| 135 | - if(!empty($args['new_line_after'])){ |
|
| 135 | + if (!empty($args['new_line_after'])) { |
|
| 136 | 136 | $output .= PHP_EOL; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | // wrap |
| 141 | - if(!$args['no_wrap']){ |
|
| 141 | + if (!$args['no_wrap']) { |
|
| 142 | 142 | $output = AUI_Component_Input::wrap(array( |
| 143 | 143 | 'content' => $output, |
| 144 | 144 | )); |
@@ -12,14 +12,14 @@ discard block |
||
| 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. |
@@ -98,22 +98,22 @@ discard block |
||
| 98 | 98 | * @return AyeCode_UI_Settings - Main instance. |
| 99 | 99 | */ |
| 100 | 100 | public static function instance() { |
| 101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 101 | + if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) { |
|
| 102 | 102 | self::$instance = new AyeCode_UI_Settings; |
| 103 | 103 | |
| 104 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 104 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
| 105 | 105 | |
| 106 | - if ( is_admin() ) { |
|
| 107 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 108 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 106 | + if (is_admin()) { |
|
| 107 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
| 108 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
| 109 | 109 | |
| 110 | 110 | // Maybe show example page |
| 111 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 111 | + add_action('template_redirect', array(self::$instance, 'maybe_show_examples')); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 114 | + add_action('customize_register', array(self::$instance, 'customizer_settings')); |
|
| 115 | 115 | |
| 116 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
| 116 | + do_action('ayecode_ui_settings_loaded'); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | return self::$instance; |
@@ -131,24 +131,24 @@ discard block |
||
| 131 | 131 | * |
| 132 | 132 | * We load super early in case there is a theme version that might change the colors |
| 133 | 133 | */ |
| 134 | - if ( $this->settings['css'] ) { |
|
| 135 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 134 | + if ($this->settings['css']) { |
|
| 135 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
| 136 | 136 | } |
| 137 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 138 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 137 | + if ($this->settings['css_backend'] && $this->load_admin_scripts()) { |
|
| 138 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // maybe load JS |
| 142 | - if ( $this->settings['js'] ) { |
|
| 143 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 142 | + if ($this->settings['js']) { |
|
| 143 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 1); |
|
| 144 | 144 | } |
| 145 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 146 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 145 | + if ($this->settings['js_backend'] && $this->load_admin_scripts()) { |
|
| 146 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | // Maybe set the HTML font size |
| 150 | - if ( $this->settings['html_font_size'] ) { |
|
| 151 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 150 | + if ($this->settings['html_font_size']) { |
|
| 151 | + add_action('wp_footer', array($this, 'html_font_size'), 10); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @return bool |
| 161 | 161 | */ |
| 162 | - public function load_admin_scripts(){ |
|
| 162 | + public function load_admin_scripts() { |
|
| 163 | 163 | $result = true; |
| 164 | 164 | |
| 165 | - if(!empty($this->settings['disable_admin'])){ |
|
| 166 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 167 | - foreach($url_parts as $part){ |
|
| 168 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 165 | + if (!empty($this->settings['disable_admin'])) { |
|
| 166 | + $url_parts = explode("\n", $this->settings['disable_admin']); |
|
| 167 | + foreach ($url_parts as $part) { |
|
| 168 | + if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) { |
|
| 169 | 169 | return false; // return early, no point checking further |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -177,9 +177,9 @@ discard block |
||
| 177 | 177 | /** |
| 178 | 178 | * Add a html font size to the footer. |
| 179 | 179 | */ |
| 180 | - public function html_font_size(){ |
|
| 180 | + public function html_font_size() { |
|
| 181 | 181 | $this->settings = $this->get_settings(); |
| 182 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 182 | + echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>"; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -189,18 +189,18 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
| 191 | 191 | |
| 192 | - if($this->settings[$css_setting]){ |
|
| 193 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 194 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui.css' : $this->url.'assets/css/ayecode-ui-compatibility.css'; |
|
| 195 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
| 196 | - wp_enqueue_style( 'ayecode-ui' ); |
|
| 192 | + if ($this->settings[$css_setting]) { |
|
| 193 | + $compatibility = $this->settings[$css_setting] == 'core' ? false : true; |
|
| 194 | + $url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets/css/ayecode-ui.css' : $this->url . 'assets/css/ayecode-ui-compatibility.css'; |
|
| 195 | + wp_register_style('ayecode-ui', $url, array(), $this->latest); |
|
| 196 | + wp_enqueue_style('ayecode-ui'); |
|
| 197 | 197 | |
| 198 | 198 | // flatpickr |
| 199 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
| 199 | + wp_register_style('flatpickr', $this->url . 'assets/css/flatpickr.min.css', array(), $this->latest); |
|
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | // fix some wp-admin issues |
| 203 | - if(is_admin()){ |
|
| 203 | + if (is_admin()) { |
|
| 204 | 204 | $custom_css = " |
| 205 | 205 | body{ |
| 206 | 206 | background-color: #f1f1f1; |
@@ -243,11 +243,11 @@ discard block |
||
| 243 | 243 | padding: 0; |
| 244 | 244 | } |
| 245 | 245 | "; |
| 246 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 246 | + wp_add_inline_style('ayecode-ui', $custom_css); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | // custom changes |
| 250 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 250 | + wp_add_inline_style('ayecode-ui', self::custom_css($compatibility)); |
|
| 251 | 251 | |
| 252 | 252 | } |
| 253 | 253 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * If this remains small then its best to use this than to add another JS file. |
| 259 | 259 | */ |
| 260 | - public function inline_script(){ |
|
| 260 | + public function inline_script() { |
|
| 261 | 261 | ob_start(); |
| 262 | 262 | ?> |
| 263 | 263 | <script> |
@@ -483,10 +483,10 @@ discard block |
||
| 483 | 483 | /* |
| 484 | 484 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 485 | 485 | */ |
| 486 | - return str_replace( array( |
|
| 486 | + return str_replace(array( |
|
| 487 | 487 | '<script>', |
| 488 | 488 | '</script>' |
| 489 | - ), '', $output ); |
|
| 489 | + ), '', $output); |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | /** |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | * |
| 495 | 495 | * If this remains small then its best to use this than to add another JS file. |
| 496 | 496 | */ |
| 497 | - public function inline_script_file_browser(){ |
|
| 497 | + public function inline_script_file_browser() { |
|
| 498 | 498 | ob_start(); |
| 499 | 499 | ?> |
| 500 | 500 | <script> |
@@ -509,10 +509,10 @@ discard block |
||
| 509 | 509 | /* |
| 510 | 510 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 511 | 511 | */ |
| 512 | - return str_replace( array( |
|
| 512 | + return str_replace(array( |
|
| 513 | 513 | '<script>', |
| 514 | 514 | '</script>' |
| 515 | - ), '', $output ); |
|
| 515 | + ), '', $output); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | /** |
@@ -523,40 +523,40 @@ discard block |
||
| 523 | 523 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
| 524 | 524 | |
| 525 | 525 | // select2 |
| 526 | - wp_register_script( 'select2', $this->url.'assets/js/select2.min.js', array('jquery'), $this->select2_version ); |
|
| 526 | + wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version); |
|
| 527 | 527 | |
| 528 | 528 | // flatpickr |
| 529 | - wp_register_script( 'flatpickr', $this->url.'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
| 529 | + wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest); |
|
| 530 | 530 | |
| 531 | 531 | // Bootstrap file browser |
| 532 | - wp_register_script( 'aui-custom-file-input', $url = $this->url.'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version ); |
|
| 533 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 532 | + wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version); |
|
| 533 | + wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser()); |
|
| 534 | 534 | |
| 535 | 535 | $load_inline = false; |
| 536 | 536 | |
| 537 | - if($this->settings[$js_setting]=='core-popper'){ |
|
| 537 | + if ($this->settings[$js_setting] == 'core-popper') { |
|
| 538 | 538 | // Bootstrap bundle |
| 539 | - $url = $this->url.'assets/js/bootstrap.bundle.min.js'; |
|
| 540 | - wp_register_script( 'bootstrap-js-bundle', $url, array('select2','jquery'), $this->latest ); |
|
| 539 | + $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
| 540 | + wp_register_script('bootstrap-js-bundle', $url, array('select2', 'jquery'), $this->latest); |
|
| 541 | 541 | // if in admin then add to footer for compatibility. |
| 542 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle'); |
|
| 542 | + is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle'); |
|
| 543 | 543 | $script = $this->inline_script(); |
| 544 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 545 | - }elseif($this->settings[$js_setting]=='popper'){ |
|
| 546 | - $url = $this->url.'assets/js/popper.min.js'; |
|
| 547 | - wp_register_script( 'bootstrap-js-popper', $url, array('jquery'), $this->latest ); |
|
| 548 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 544 | + wp_add_inline_script('bootstrap-js-bundle', $script); |
|
| 545 | + }elseif ($this->settings[$js_setting] == 'popper') { |
|
| 546 | + $url = $this->url . 'assets/js/popper.min.js'; |
|
| 547 | + wp_register_script('bootstrap-js-popper', $url, array('jquery'), $this->latest); |
|
| 548 | + wp_enqueue_script('bootstrap-js-popper'); |
|
| 549 | 549 | $load_inline = true; |
| 550 | - }else{ |
|
| 550 | + } else { |
|
| 551 | 551 | $load_inline = true; |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
| 555 | - if($load_inline){ |
|
| 556 | - wp_register_script( 'bootstrap-dummy', '',array('jquery') ); |
|
| 557 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 555 | + if ($load_inline) { |
|
| 556 | + wp_register_script('bootstrap-dummy', '', array('jquery')); |
|
| 557 | + wp_enqueue_script('bootstrap-dummy'); |
|
| 558 | 558 | $script = $this->inline_script(); |
| 559 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 559 | + wp_add_inline_script('bootstrap-dummy', $script); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | } |
@@ -564,9 +564,9 @@ discard block |
||
| 564 | 564 | /** |
| 565 | 565 | * Enqueue flatpickr if called. |
| 566 | 566 | */ |
| 567 | - public function enqueue_flatpickr(){ |
|
| 568 | - wp_enqueue_style( 'flatpickr' ); |
|
| 569 | - wp_enqueue_script( 'flatpickr' ); |
|
| 567 | + public function enqueue_flatpickr() { |
|
| 568 | + wp_enqueue_style('flatpickr'); |
|
| 569 | + wp_enqueue_script('flatpickr'); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | /** |
@@ -578,15 +578,15 @@ discard block |
||
| 578 | 578 | |
| 579 | 579 | $url = ''; |
| 580 | 580 | // check if we are inside a plugin |
| 581 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 581 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
| 582 | 582 | |
| 583 | 583 | // add check in-case user has changed wp-content dir name. |
| 584 | 584 | $wp_content_folder_name = basename(WP_CONTENT_DIR); |
| 585 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 586 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 585 | + $dir_parts = explode("/$wp_content_folder_name/", $file_dir); |
|
| 586 | + $url_parts = explode("/$wp_content_folder_name/", plugins_url()); |
|
| 587 | 587 | |
| 588 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 589 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 588 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
| 589 | + $url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | return $url; |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | * Register the database settings with WordPress. |
| 597 | 597 | */ |
| 598 | 598 | public function register_settings() { |
| 599 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 599 | + register_setting('ayecode-ui-settings', 'ayecode-ui-settings'); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | /** |
@@ -605,10 +605,10 @@ discard block |
||
| 605 | 605 | */ |
| 606 | 606 | public function menu_item() { |
| 607 | 607 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
| 608 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 608 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 609 | 609 | $this, |
| 610 | 610 | 'settings_page' |
| 611 | - ) ); |
|
| 611 | + )); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | /** |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | * |
| 617 | 617 | * @return array |
| 618 | 618 | */ |
| 619 | - public function theme_js_settings(){ |
|
| 619 | + public function theme_js_settings() { |
|
| 620 | 620 | return array( |
| 621 | 621 | 'ayetheme' => 'popper', |
| 622 | 622 | 'listimia' => 'required', |
@@ -632,17 +632,17 @@ discard block |
||
| 632 | 632 | */ |
| 633 | 633 | public function get_settings() { |
| 634 | 634 | |
| 635 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 635 | + $db_settings = get_option('ayecode-ui-settings'); |
|
| 636 | 636 | $js_default = 'core-popper'; |
| 637 | 637 | $js_default_backend = $js_default; |
| 638 | 638 | |
| 639 | 639 | // maybe set defaults (if no settings set) |
| 640 | - if(empty($db_settings)){ |
|
| 641 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 640 | + if (empty($db_settings)) { |
|
| 641 | + $active_theme = strtolower(get_template()); // active parent theme. |
|
| 642 | 642 | $theme_js_settings = self::theme_js_settings(); |
| 643 | - if(isset($theme_js_settings[$active_theme])){ |
|
| 643 | + if (isset($theme_js_settings[$active_theme])) { |
|
| 644 | 644 | $js_default = $theme_js_settings[$active_theme]; |
| 645 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 645 | + $js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default; |
|
| 646 | 646 | } |
| 647 | 647 | } |
| 648 | 648 | |
@@ -655,14 +655,14 @@ discard block |
||
| 655 | 655 | 'disable_admin' => '', // URL snippets to disable loading on admin |
| 656 | 656 | ); |
| 657 | 657 | |
| 658 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 658 | + $settings = wp_parse_args($db_settings, $defaults); |
|
| 659 | 659 | |
| 660 | 660 | /** |
| 661 | 661 | * Filter the Bootstrap settings. |
| 662 | 662 | * |
| 663 | 663 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
| 664 | 664 | */ |
| 665 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 665 | + return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults); |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | |
@@ -670,90 +670,90 @@ discard block |
||
| 670 | 670 | * The settings page html output. |
| 671 | 671 | */ |
| 672 | 672 | public function settings_page() { |
| 673 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 674 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 673 | + if (!current_user_can('manage_options')) { |
|
| 674 | + wp_die(__('You do not have sufficient permissions to access this page.', 'aui')); |
|
| 675 | 675 | } |
| 676 | 676 | ?> |
| 677 | 677 | <div class="wrap"> |
| 678 | 678 | <h1><?php echo $this->name; ?></h1> |
| 679 | - <p><?php _e("Here you can adjust settings if you are having compatibility issues.","aui");?></p> |
|
| 679 | + <p><?php _e("Here you can adjust settings if you are having compatibility issues.", "aui"); ?></p> |
|
| 680 | 680 | <form method="post" action="options.php"> |
| 681 | 681 | <?php |
| 682 | - settings_fields( 'ayecode-ui-settings' ); |
|
| 683 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
| 682 | + settings_fields('ayecode-ui-settings'); |
|
| 683 | + do_settings_sections('ayecode-ui-settings'); |
|
| 684 | 684 | ?> |
| 685 | 685 | |
| 686 | - <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
|
| 686 | + <h2><?php _e('Frontend', 'aui'); ?></h2> |
|
| 687 | 687 | <table class="form-table wpbs-table-settings"> |
| 688 | 688 | <tr valign="top"> |
| 689 | 689 | <th scope="row"><label |
| 690 | - for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
| 690 | + for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
| 691 | 691 | <td> |
| 692 | 692 | <select name="ayecode-ui-settings[css]" id="wpbs-css"> |
| 693 | - <option value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode', 'aui' ); ?></option> |
|
| 694 | - <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
|
| 695 | - <option value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
| 693 | + <option value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode', 'aui'); ?></option> |
|
| 694 | + <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option> |
|
| 695 | + <option value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
| 696 | 696 | </select> |
| 697 | 697 | </td> |
| 698 | 698 | </tr> |
| 699 | 699 | |
| 700 | 700 | <tr valign="top"> |
| 701 | 701 | <th scope="row"><label |
| 702 | - for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
| 702 | + for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th> |
|
| 703 | 703 | <td> |
| 704 | 704 | <select name="ayecode-ui-settings[js]" id="wpbs-js"> |
| 705 | - <option value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
| 706 | - <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
| 707 | - <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
| 708 | - <option value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
| 705 | + <option value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
| 706 | + <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
| 707 | + <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
| 708 | + <option value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
| 709 | 709 | </select> |
| 710 | 710 | </td> |
| 711 | 711 | </tr> |
| 712 | 712 | |
| 713 | 713 | <tr valign="top"> |
| 714 | 714 | <th scope="row"><label |
| 715 | - for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th> |
|
| 715 | + for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th> |
|
| 716 | 716 | <td> |
| 717 | - <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" /> |
|
| 718 | - <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> |
|
| 717 | + <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" /> |
|
| 718 | + <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> |
|
| 719 | 719 | </td> |
| 720 | 720 | </tr> |
| 721 | 721 | |
| 722 | 722 | </table> |
| 723 | 723 | |
| 724 | - <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2> |
|
| 724 | + <h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2> |
|
| 725 | 725 | <table class="form-table wpbs-table-settings"> |
| 726 | 726 | <tr valign="top"> |
| 727 | 727 | <th scope="row"><label |
| 728 | - for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
| 728 | + for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
| 729 | 729 | <td> |
| 730 | 730 | <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin"> |
| 731 | - <option value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode', 'aui' ); ?></option> |
|
| 732 | - <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
|
| 733 | - <option value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
| 731 | + <option value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode', 'aui'); ?></option> |
|
| 732 | + <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option> |
|
| 733 | + <option value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
| 734 | 734 | </select> |
| 735 | 735 | </td> |
| 736 | 736 | </tr> |
| 737 | 737 | |
| 738 | 738 | <tr valign="top"> |
| 739 | 739 | <th scope="row"><label |
| 740 | - for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
| 740 | + for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th> |
|
| 741 | 741 | <td> |
| 742 | 742 | <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin"> |
| 743 | - <option value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
| 744 | - <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
| 745 | - <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
| 746 | - <option value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
| 743 | + <option value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
| 744 | + <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
| 745 | + <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
| 746 | + <option value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
| 747 | 747 | </select> |
| 748 | 748 | </td> |
| 749 | 749 | </tr> |
| 750 | 750 | |
| 751 | 751 | <tr valign="top"> |
| 752 | 752 | <th scope="row"><label |
| 753 | - for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th> |
|
| 753 | + for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th> |
|
| 754 | 754 | <td> |
| 755 | - <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> |
|
| 756 | - <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin'];?></textarea> |
|
| 755 | + <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> |
|
| 756 | + <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin']; ?></textarea> |
|
| 757 | 757 | |
| 758 | 758 | </td> |
| 759 | 759 | </tr> |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | <?php |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - public function customizer_settings($wp_customize){ |
|
| 774 | + public function customizer_settings($wp_customize) { |
|
| 775 | 775 | $wp_customize->add_section('aui_settings', array( |
| 776 | 776 | 'title' => __('AyeCode UI'), |
| 777 | 777 | 'priority' => 120, |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | 'type' => 'option', |
| 788 | 788 | 'transport' => 'refresh', |
| 789 | 789 | )); |
| 790 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 790 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 791 | 791 | 'label' => __('Primary Color'), |
| 792 | 792 | 'section' => 'aui_settings', |
| 793 | 793 | 'settings' => 'aui_options[color_primary]', |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | 'type' => 'option', |
| 801 | 801 | 'transport' => 'refresh', |
| 802 | 802 | )); |
| 803 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 803 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 804 | 804 | 'label' => __('Secondary Color'), |
| 805 | 805 | 'section' => 'aui_settings', |
| 806 | 806 | 'settings' => 'aui_options[color_secondary]', |
@@ -815,12 +815,12 @@ discard block |
||
| 815 | 815 | ?> |
| 816 | 816 | <style> |
| 817 | 817 | <?php |
| 818 | - if(!empty($settings['color_primary']) && $settings['color_primary'] != "#1e73be"){ |
|
| 819 | - echo self::css_primary($settings['color_primary'],$compatibility); |
|
| 818 | + if (!empty($settings['color_primary']) && $settings['color_primary'] != "#1e73be") { |
|
| 819 | + echo self::css_primary($settings['color_primary'], $compatibility); |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | - if(!empty($settings['color_secondary']) && $settings['color_secondary'] != "#6c757d"){ |
|
| 823 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
| 822 | + if (!empty($settings['color_secondary']) && $settings['color_secondary'] != "#6c757d") { |
|
| 823 | + echo self::css_secondary($settings['color_secondary'], $compatibility); |
|
| 824 | 824 | } |
| 825 | 825 | ?> |
| 826 | 826 | </style> |
@@ -830,50 +830,50 @@ discard block |
||
| 830 | 830 | /* |
| 831 | 831 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 832 | 832 | */ |
| 833 | - return str_replace( array( |
|
| 833 | + return str_replace(array( |
|
| 834 | 834 | '<style>', |
| 835 | 835 | '</style>' |
| 836 | 836 | ), '', ob_get_clean()); |
| 837 | 837 | } |
| 838 | 838 | |
| 839 | - public static function css_primary($color_code,$compatibility){; |
|
| 839 | + public static function css_primary($color_code, $compatibility) {; |
|
| 840 | 840 | $color_code = sanitize_hex_color($color_code); |
| 841 | - if(!$color_code){return '';} |
|
| 841 | + if (!$color_code) {return ''; } |
|
| 842 | 842 | /** |
| 843 | 843 | * c = color, b = background color, o = border-color, f = fill |
| 844 | 844 | */ |
| 845 | 845 | $selectors = array( |
| 846 | 846 | 'a' => array('c'), |
| 847 | - '.btn-primary' => array('b','o'), |
|
| 848 | - '.btn-primary.disabled' => array('b','o'), |
|
| 849 | - '.btn-primary:disabled' => array('b','o'), |
|
| 850 | - '.btn-outline-primary' => array('c','o'), |
|
| 851 | - '.btn-outline-primary:hover' => array('b','o'), |
|
| 852 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 853 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 854 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 847 | + '.btn-primary' => array('b', 'o'), |
|
| 848 | + '.btn-primary.disabled' => array('b', 'o'), |
|
| 849 | + '.btn-primary:disabled' => array('b', 'o'), |
|
| 850 | + '.btn-outline-primary' => array('c', 'o'), |
|
| 851 | + '.btn-outline-primary:hover' => array('b', 'o'), |
|
| 852 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
| 853 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
| 854 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'), |
|
| 855 | 855 | '.btn-link' => array('c'), |
| 856 | 856 | '.dropdown-item.active' => array('b'), |
| 857 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 858 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 857 | + '.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'), |
|
| 858 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'), |
|
| 859 | 859 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 860 | 860 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 861 | 861 | // '.custom-range::-ms-thumb' => array('b'), |
| 862 | 862 | '.nav-pills .nav-link.active' => array('b'), |
| 863 | 863 | '.nav-pills .show>.nav-link' => array('b'), |
| 864 | 864 | '.page-link' => array('c'), |
| 865 | - '.page-item.active .page-link' => array('b','o'), |
|
| 865 | + '.page-item.active .page-link' => array('b', 'o'), |
|
| 866 | 866 | '.badge-primary' => array('b'), |
| 867 | - '.alert-primary' => array('b','o'), |
|
| 867 | + '.alert-primary' => array('b', 'o'), |
|
| 868 | 868 | '.progress-bar' => array('b'), |
| 869 | - '.list-group-item.active' => array('b','o'), |
|
| 870 | - '.bg-primary' => array('b','f'), |
|
| 869 | + '.list-group-item.active' => array('b', 'o'), |
|
| 870 | + '.bg-primary' => array('b', 'f'), |
|
| 871 | 871 | '.btn-link.btn-primary' => array('c'), |
| 872 | 872 | '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
| 873 | 873 | ); |
| 874 | 874 | |
| 875 | 875 | $important_selectors = array( |
| 876 | - '.bg-primary' => array('b','f'), |
|
| 876 | + '.bg-primary' => array('b', 'f'), |
|
| 877 | 877 | '.border-primary' => array('o'), |
| 878 | 878 | '.text-primary' => array('c'), |
| 879 | 879 | ); |
@@ -890,116 +890,116 @@ discard block |
||
| 890 | 890 | $output = ''; |
| 891 | 891 | |
| 892 | 892 | // build rules into each type |
| 893 | - foreach($selectors as $selector => $types){ |
|
| 894 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 895 | - $types = array_combine($types,$types); |
|
| 896 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 897 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 898 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 899 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 893 | + foreach ($selectors as $selector => $types) { |
|
| 894 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 895 | + $types = array_combine($types, $types); |
|
| 896 | + if (isset($types['c'])) {$color[] = $selector; } |
|
| 897 | + if (isset($types['b'])) {$background[] = $selector; } |
|
| 898 | + if (isset($types['o'])) {$border[] = $selector; } |
|
| 899 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | // build rules into each type |
| 903 | - foreach($important_selectors as $selector => $types){ |
|
| 904 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 905 | - $types = array_combine($types,$types); |
|
| 906 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 907 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 908 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 909 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 903 | + foreach ($important_selectors as $selector => $types) { |
|
| 904 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 905 | + $types = array_combine($types, $types); |
|
| 906 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
| 907 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
| 908 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
| 909 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | // add any color rules |
| 913 | - if(!empty($color)){ |
|
| 914 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 913 | + if (!empty($color)) { |
|
| 914 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
| 915 | 915 | } |
| 916 | - if(!empty($color_i)){ |
|
| 917 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 916 | + if (!empty($color_i)) { |
|
| 917 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | // add any background color rules |
| 921 | - if(!empty($background)){ |
|
| 922 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 921 | + if (!empty($background)) { |
|
| 922 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
| 923 | 923 | } |
| 924 | - if(!empty($background_i)){ |
|
| 925 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 924 | + if (!empty($background_i)) { |
|
| 925 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
| 926 | 926 | } |
| 927 | 927 | |
| 928 | 928 | // add any border color rules |
| 929 | - if(!empty($border)){ |
|
| 930 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 929 | + if (!empty($border)) { |
|
| 930 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
| 931 | 931 | } |
| 932 | - if(!empty($border_i)){ |
|
| 933 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 932 | + if (!empty($border_i)) { |
|
| 933 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | // add any fill color rules |
| 937 | - if(!empty($fill)){ |
|
| 938 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 937 | + if (!empty($fill)) { |
|
| 938 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
| 939 | 939 | } |
| 940 | - if(!empty($fill_i)){ |
|
| 941 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 940 | + if (!empty($fill_i)) { |
|
| 941 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
| 942 | 942 | } |
| 943 | 943 | |
| 944 | 944 | |
| 945 | 945 | $prefix = $compatibility ? ".bsui " : ""; |
| 946 | 946 | |
| 947 | 947 | // darken |
| 948 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 949 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 950 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 948 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
| 949 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
| 950 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
| 951 | 951 | |
| 952 | 952 | // lighten |
| 953 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 953 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
| 954 | 954 | |
| 955 | 955 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
| 956 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 956 | + $op_25 = $color_code . "40"; // 25% opacity |
|
| 957 | 957 | |
| 958 | 958 | |
| 959 | 959 | // button states |
| 960 | - $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 961 | - $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;} "; |
|
| 962 | - $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.";} "; |
|
| 963 | - $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;} "; |
|
| 960 | + $output .= $prefix . " .btn-primary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
| 961 | + $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;} "; |
|
| 962 | + $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 . ";} "; |
|
| 963 | + $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;} "; |
|
| 964 | 964 | |
| 965 | 965 | |
| 966 | 966 | // dropdown's |
| 967 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 967 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 968 | 968 | |
| 969 | 969 | |
| 970 | 970 | // input states |
| 971 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 971 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 972 | 972 | |
| 973 | 973 | // page link |
| 974 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 974 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 975 | 975 | |
| 976 | 976 | return $output; |
| 977 | 977 | } |
| 978 | 978 | |
| 979 | - public static function css_secondary($color_code,$compatibility){; |
|
| 979 | + public static function css_secondary($color_code, $compatibility) {; |
|
| 980 | 980 | $color_code = sanitize_hex_color($color_code); |
| 981 | - if(!$color_code){return '';} |
|
| 981 | + if (!$color_code) {return ''; } |
|
| 982 | 982 | /** |
| 983 | 983 | * c = color, b = background color, o = border-color, f = fill |
| 984 | 984 | */ |
| 985 | 985 | $selectors = array( |
| 986 | - '.btn-secondary' => array('b','o'), |
|
| 987 | - '.btn-secondary.disabled' => array('b','o'), |
|
| 988 | - '.btn-secondary:disabled' => array('b','o'), |
|
| 989 | - '.btn-outline-secondary' => array('c','o'), |
|
| 990 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
| 986 | + '.btn-secondary' => array('b', 'o'), |
|
| 987 | + '.btn-secondary.disabled' => array('b', 'o'), |
|
| 988 | + '.btn-secondary:disabled' => array('b', 'o'), |
|
| 989 | + '.btn-outline-secondary' => array('c', 'o'), |
|
| 990 | + '.btn-outline-secondary:hover' => array('b', 'o'), |
|
| 991 | 991 | '.btn-outline-secondary.disabled' => array('c'), |
| 992 | 992 | '.btn-outline-secondary:disabled' => array('c'), |
| 993 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 994 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 995 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 993 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
| 994 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
| 995 | + '.btn-outline-secondary.dropdown-toggle' => array('b', 'o'), |
|
| 996 | 996 | '.badge-secondary' => array('b'), |
| 997 | - '.alert-secondary' => array('b','o'), |
|
| 997 | + '.alert-secondary' => array('b', 'o'), |
|
| 998 | 998 | '.btn-link.btn-secondary' => array('c'), |
| 999 | 999 | ); |
| 1000 | 1000 | |
| 1001 | 1001 | $important_selectors = array( |
| 1002 | - '.bg-secondary' => array('b','f'), |
|
| 1002 | + '.bg-secondary' => array('b', 'f'), |
|
| 1003 | 1003 | '.border-secondary' => array('o'), |
| 1004 | 1004 | '.text-secondary' => array('c'), |
| 1005 | 1005 | ); |
@@ -1016,77 +1016,77 @@ discard block |
||
| 1016 | 1016 | $output = ''; |
| 1017 | 1017 | |
| 1018 | 1018 | // build rules into each type |
| 1019 | - foreach($selectors as $selector => $types){ |
|
| 1020 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1021 | - $types = array_combine($types,$types); |
|
| 1022 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1023 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1024 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1025 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1019 | + foreach ($selectors as $selector => $types) { |
|
| 1020 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1021 | + $types = array_combine($types, $types); |
|
| 1022 | + if (isset($types['c'])) {$color[] = $selector; } |
|
| 1023 | + if (isset($types['b'])) {$background[] = $selector; } |
|
| 1024 | + if (isset($types['o'])) {$border[] = $selector; } |
|
| 1025 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | // build rules into each type |
| 1029 | - foreach($important_selectors as $selector => $types){ |
|
| 1030 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1031 | - $types = array_combine($types,$types); |
|
| 1032 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1033 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1034 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1035 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1029 | + foreach ($important_selectors as $selector => $types) { |
|
| 1030 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1031 | + $types = array_combine($types, $types); |
|
| 1032 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
| 1033 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
| 1034 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
| 1035 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | // add any color rules |
| 1039 | - if(!empty($color)){ |
|
| 1040 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1039 | + if (!empty($color)) { |
|
| 1040 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
| 1041 | 1041 | } |
| 1042 | - if(!empty($color_i)){ |
|
| 1043 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1042 | + if (!empty($color_i)) { |
|
| 1043 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | 1046 | // add any background color rules |
| 1047 | - if(!empty($background)){ |
|
| 1048 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1047 | + if (!empty($background)) { |
|
| 1048 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
| 1049 | 1049 | } |
| 1050 | - if(!empty($background_i)){ |
|
| 1051 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1050 | + if (!empty($background_i)) { |
|
| 1051 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | 1054 | // add any border color rules |
| 1055 | - if(!empty($border)){ |
|
| 1056 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1055 | + if (!empty($border)) { |
|
| 1056 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
| 1057 | 1057 | } |
| 1058 | - if(!empty($border_i)){ |
|
| 1059 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1058 | + if (!empty($border_i)) { |
|
| 1059 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | 1062 | // add any fill color rules |
| 1063 | - if(!empty($fill)){ |
|
| 1064 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1063 | + if (!empty($fill)) { |
|
| 1064 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
| 1065 | 1065 | } |
| 1066 | - if(!empty($fill_i)){ |
|
| 1067 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1066 | + if (!empty($fill_i)) { |
|
| 1067 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | |
| 1071 | 1071 | $prefix = $compatibility ? ".bsui " : ""; |
| 1072 | 1072 | |
| 1073 | 1073 | // darken |
| 1074 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1075 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1076 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1074 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
| 1075 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
| 1076 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
| 1077 | 1077 | |
| 1078 | 1078 | // lighten |
| 1079 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1079 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
| 1080 | 1080 | |
| 1081 | 1081 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
| 1082 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1082 | + $op_25 = $color_code . "40"; // 25% opacity |
|
| 1083 | 1083 | |
| 1084 | 1084 | |
| 1085 | 1085 | // button states |
| 1086 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1087 | - $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;} "; |
|
| 1088 | - $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.";} "; |
|
| 1089 | - $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;} "; |
|
| 1086 | + $output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
| 1087 | + $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;} "; |
|
| 1088 | + $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 . ";} "; |
|
| 1089 | + $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;} "; |
|
| 1090 | 1090 | |
| 1091 | 1091 | |
| 1092 | 1092 | return $output; |
@@ -1122,8 +1122,8 @@ discard block |
||
| 1122 | 1122 | /** |
| 1123 | 1123 | * Check if we should display examples. |
| 1124 | 1124 | */ |
| 1125 | - public function maybe_show_examples(){ |
|
| 1126 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 1125 | + public function maybe_show_examples() { |
|
| 1126 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
| 1127 | 1127 | echo "<head>"; |
| 1128 | 1128 | wp_head(); |
| 1129 | 1129 | echo "</head>"; |
@@ -1139,7 +1139,7 @@ discard block |
||
| 1139 | 1139 | * |
| 1140 | 1140 | * @return string |
| 1141 | 1141 | */ |
| 1142 | - public function get_examples(){ |
|
| 1142 | + public function get_examples() { |
|
| 1143 | 1143 | $output = ''; |
| 1144 | 1144 | |
| 1145 | 1145 | |
@@ -1,9 +1,9 @@ discard block |
||
| 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 | 8 | |
| 9 | 9 | /** |
@@ -37,27 +37,27 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * Take the array options and use them to build. |
| 39 | 39 | */ |
| 40 | - public function __construct( $options ) { |
|
| 40 | + public function __construct($options) { |
|
| 41 | 41 | global $sd_widgets; |
| 42 | 42 | |
| 43 | - $sd_widgets[ $options['base_id'] ] = array( |
|
| 43 | + $sd_widgets[$options['base_id']] = array( |
|
| 44 | 44 | 'name' => $options['name'], |
| 45 | 45 | 'class_name' => $options['class_name'] |
| 46 | 46 | ); |
| 47 | - $this->base_id = $options['base_id']; |
|
| 47 | + $this->base_id = $options['base_id']; |
|
| 48 | 48 | // lets filter the options before we do anything |
| 49 | - $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 50 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 51 | - $options = $this->add_name_from_key( $options ); |
|
| 49 | + $options = apply_filters("wp_super_duper_options", $options); |
|
| 50 | + $options = apply_filters("wp_super_duper_options_{$this->base_id}", $options); |
|
| 51 | + $options = $this->add_name_from_key($options); |
|
| 52 | 52 | $this->options = $options; |
| 53 | 53 | |
| 54 | 54 | $this->base_id = $options['base_id']; |
| 55 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 55 | + $this->arguments = isset($options['arguments']) ? $options['arguments'] : array(); |
|
| 56 | 56 | |
| 57 | 57 | // init parent |
| 58 | - parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
|
| 58 | + parent::__construct($options['base_id'], $options['name'], $options['widget_ops']); |
|
| 59 | 59 | |
| 60 | - if ( isset( $options['class_name'] ) ) { |
|
| 60 | + if (isset($options['class_name'])) { |
|
| 61 | 61 | // register widget |
| 62 | 62 | $this->class_name = $options['class_name']; |
| 63 | 63 | |
@@ -65,66 +65,66 @@ discard block |
||
| 65 | 65 | $this->register_shortcode(); |
| 66 | 66 | |
| 67 | 67 | // Fusion Builder (avada) support |
| 68 | - if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 69 | - add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 68 | + if (function_exists('fusion_builder_map')) { |
|
| 69 | + add_action('init', array($this, 'register_fusion_element')); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // register block |
| 73 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 73 | + add_action('admin_enqueue_scripts', array($this, 'register_block')); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // add the CSS and JS we need ONCE |
| 77 | 77 | global $sd_widget_scripts; |
| 78 | 78 | |
| 79 | - if ( ! $sd_widget_scripts ) { |
|
| 80 | - wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 81 | - wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 82 | - wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 79 | + if (!$sd_widget_scripts) { |
|
| 80 | + wp_add_inline_script('admin-widgets', $this->widget_js()); |
|
| 81 | + wp_add_inline_script('customize-controls', $this->widget_js()); |
|
| 82 | + wp_add_inline_style('widgets', $this->widget_css()); |
|
| 83 | 83 | |
| 84 | 84 | // maybe add elementor editor styles |
| 85 | - add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 85 | + add_action('elementor/editor/after_enqueue_styles', array($this, 'elementor_editor_styles')); |
|
| 86 | 86 | |
| 87 | 87 | $sd_widget_scripts = true; |
| 88 | 88 | |
| 89 | 89 | // add shortcode insert button once |
| 90 | - add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 90 | + add_action('media_buttons', array($this, 'shortcode_insert_button')); |
|
| 91 | 91 | // generatepress theme sections compatibility |
| 92 | - if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 93 | - add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 92 | + if (function_exists('generate_sections_sections_metabox')) { |
|
| 93 | + add_action('generate_sections_metabox', array($this, 'shortcode_insert_button_script')); |
|
| 94 | 94 | } |
| 95 | - if ( $this->is_preview() ) { |
|
| 96 | - add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 95 | + if ($this->is_preview()) { |
|
| 96 | + add_action('wp_footer', array($this, 'shortcode_insert_button_script')); |
|
| 97 | 97 | // this makes the insert button work for elementor |
| 98 | - add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 98 | + add_action('elementor/editor/after_enqueue_scripts', array( |
|
| 99 | 99 | $this, |
| 100 | 100 | 'shortcode_insert_button_script' |
| 101 | - ) ); // for elementor |
|
| 101 | + )); // for elementor |
|
| 102 | 102 | } |
| 103 | 103 | // this makes the insert button work for cornerstone |
| 104 | - add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 104 | + add_action('wp_print_footer_scripts', array(__CLASS__, 'maybe_cornerstone_builder')); |
|
| 105 | 105 | |
| 106 | - add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 107 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 106 | + add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings')); |
|
| 107 | + add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker')); |
|
| 108 | 108 | |
| 109 | 109 | // add generator text to admin head |
| 110 | - add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 110 | + add_action('admin_head', array($this, 'generator')); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 113 | + do_action('wp_super_duper_widget_init', $options, $this); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * Add our widget CSS to elementor editor. |
| 118 | 118 | */ |
| 119 | 119 | public function elementor_editor_styles() { |
| 120 | - wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 120 | + wp_add_inline_style('elementor-editor', $this->widget_css(false)); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | public function register_fusion_element() { |
| 124 | 124 | |
| 125 | 125 | $options = $this->options; |
| 126 | 126 | |
| 127 | - if ( $this->base_id ) { |
|
| 127 | + if ($this->base_id) { |
|
| 128 | 128 | |
| 129 | 129 | $params = $this->get_fusion_params(); |
| 130 | 130 | |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | 'allow_generator' => true, |
| 136 | 136 | ); |
| 137 | 137 | |
| 138 | - if ( ! empty( $params ) ) { |
|
| 138 | + if (!empty($params)) { |
|
| 139 | 139 | $args['params'] = $params; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - fusion_builder_map( $args ); |
|
| 142 | + fusion_builder_map($args); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | } |
@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | $params = array(); |
| 149 | 149 | $arguments = $this->get_arguments(); |
| 150 | 150 | |
| 151 | - if ( ! empty( $arguments ) ) { |
|
| 152 | - foreach ( $arguments as $key => $val ) { |
|
| 151 | + if (!empty($arguments)) { |
|
| 152 | + foreach ($arguments as $key => $val) { |
|
| 153 | 153 | $param = array(); |
| 154 | 154 | // type |
| 155 | 155 | $param['type'] = str_replace( |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $val['type'] ); |
| 172 | 172 | |
| 173 | 173 | // multiselect |
| 174 | - if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 174 | + if ($val['type'] == 'multiselect' || (($param['type'] == 'select' || $val['type'] == 'select') && !empty($val['multiple']))) { |
|
| 175 | 175 | $param['type'] = 'multiple_select'; |
| 176 | 176 | $param['multiple'] = true; |
| 177 | 177 | } |
@@ -180,29 +180,29 @@ discard block |
||
| 180 | 180 | $param['heading'] = $val['title']; |
| 181 | 181 | |
| 182 | 182 | // description |
| 183 | - $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 183 | + $param['description'] = isset($val['desc']) ? $val['desc'] : ''; |
|
| 184 | 184 | |
| 185 | 185 | // param_name |
| 186 | 186 | $param['param_name'] = $key; |
| 187 | 187 | |
| 188 | 188 | // Default |
| 189 | - $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 189 | + $param['default'] = isset($val['default']) ? $val['default'] : ''; |
|
| 190 | 190 | |
| 191 | 191 | // Group |
| 192 | - if ( isset( $val['group'] ) ) { |
|
| 192 | + if (isset($val['group'])) { |
|
| 193 | 193 | $param['group'] = $val['group']; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // value |
| 197 | - if ( $val['type'] == 'checkbox' ) { |
|
| 198 | - if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 199 | - unset( $param['default'] ); |
|
| 197 | + if ($val['type'] == 'checkbox') { |
|
| 198 | + if (isset($val['default']) && $val['default'] == '0') { |
|
| 199 | + unset($param['default']); |
|
| 200 | 200 | } |
| 201 | - $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) ); |
|
| 202 | - } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 203 | - $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 201 | + $param['value'] = array('' => __("No"), '1' => __("Yes")); |
|
| 202 | + } elseif ($param['type'] == 'select' || $param['type'] == 'multiple_select') { |
|
| 203 | + $param['value'] = isset($val['options']) ? $val['options'] : array(); |
|
| 204 | 204 | } else { |
| 205 | - $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 205 | + $param['value'] = isset($val['default']) ? $val['default'] : ''; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // setup the param |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
| 220 | 220 | */ |
| 221 | 221 | public static function maybe_cornerstone_builder() { |
| 222 | - if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 222 | + if (did_action('cornerstone_before_boot_app')) { |
|
| 223 | 223 | self::shortcode_insert_button_script(); |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -231,12 +231,12 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @return string |
| 233 | 233 | */ |
| 234 | - public static function get_picker( $editor_id = '' ) { |
|
| 234 | + public static function get_picker($editor_id = '') { |
|
| 235 | 235 | |
| 236 | 236 | ob_start(); |
| 237 | - if ( isset( $_POST['editor_id'] ) ) { |
|
| 238 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 239 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 237 | + if (isset($_POST['editor_id'])) { |
|
| 238 | + $editor_id = esc_attr($_POST['editor_id']); |
|
| 239 | + } elseif (isset($_REQUEST['et_fb'])) { |
|
| 240 | 240 | $editor_id = 'main_content_content_vb_tiny_mce'; |
| 241 | 241 | } |
| 242 | 242 | |
@@ -245,13 +245,13 @@ discard block |
||
| 245 | 245 | |
| 246 | 246 | <div class="sd-shortcode-left-wrap"> |
| 247 | 247 | <?php |
| 248 | - ksort( $sd_widgets ); |
|
| 248 | + ksort($sd_widgets); |
|
| 249 | 249 | // print_r($sd_widgets);exit; |
| 250 | - if ( ! empty( $sd_widgets ) ) { |
|
| 250 | + if (!empty($sd_widgets)) { |
|
| 251 | 251 | echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
| 252 | - echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 253 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 254 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 252 | + echo "<option>" . __('Select shortcode') . "</option>"; |
|
| 253 | + foreach ($sd_widgets as $shortcode => $class) { |
|
| 254 | + echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>"; |
|
| 255 | 255 | } |
| 256 | 256 | echo "</select>"; |
| 257 | 257 | |
@@ -264,37 +264,37 @@ discard block |
||
| 264 | 264 | <div class="sd-shortcode-right-wrap"> |
| 265 | 265 | <textarea id='sd-shortcode-output' disabled></textarea> |
| 266 | 266 | <div id='sd-shortcode-output-actions'> |
| 267 | - <?php if ( $editor_id != '' ) { ?> |
|
| 267 | + <?php if ($editor_id != '') { ?> |
|
| 268 | 268 | <button class="button sd-insert-shortcode-button" |
| 269 | - onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { |
|
| 269 | + onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) { |
|
| 270 | 270 | echo "'" . $editor_id . "'"; |
| 271 | - } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 271 | + } ?>)"><?php _e('Insert shortcode'); ?></button> |
|
| 272 | 272 | <?php } ?> |
| 273 | 273 | <button class="button" |
| 274 | - onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button> |
|
| 274 | + onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button> |
|
| 275 | 275 | </div> |
| 276 | 276 | </div> |
| 277 | 277 | <?php |
| 278 | 278 | |
| 279 | 279 | $html = ob_get_clean(); |
| 280 | 280 | |
| 281 | - if ( wp_doing_ajax() ) { |
|
| 281 | + if (wp_doing_ajax()) { |
|
| 282 | 282 | echo $html; |
| 283 | 283 | $should_die = true; |
| 284 | 284 | |
| 285 | 285 | // some builder get the editor via ajax so we should not die on those ocasions |
| 286 | 286 | $dont_die = array( |
| 287 | - 'parent_tag',// WP Bakery |
|
| 287 | + 'parent_tag', // WP Bakery |
|
| 288 | 288 | 'avia_request' // enfold |
| 289 | 289 | ); |
| 290 | 290 | |
| 291 | - foreach ( $dont_die as $request ) { |
|
| 292 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 291 | + foreach ($dont_die as $request) { |
|
| 292 | + if (isset($_REQUEST[$request])) { |
|
| 293 | 293 | $should_die = false; |
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if ( $should_die ) { |
|
| 297 | + if ($should_die) { |
|
| 298 | 298 | wp_die(); |
| 299 | 299 | } |
| 300 | 300 | |
@@ -321,16 +321,16 @@ discard block |
||
| 321 | 321 | public static function get_widget_settings() { |
| 322 | 322 | global $sd_widgets; |
| 323 | 323 | |
| 324 | - $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 325 | - if ( ! $shortcode ) { |
|
| 324 | + $shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : ''; |
|
| 325 | + if (!$shortcode) { |
|
| 326 | 326 | wp_die(); |
| 327 | 327 | } |
| 328 | - $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 329 | - if ( ! $widget_args ) { |
|
| 328 | + $widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : ''; |
|
| 329 | + if (!$widget_args) { |
|
| 330 | 330 | wp_die(); |
| 331 | 331 | } |
| 332 | - $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 333 | - if ( ! $class_name ) { |
|
| 332 | + $class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 333 | + if (!$class_name) { |
|
| 334 | 334 | wp_die(); |
| 335 | 335 | } |
| 336 | 336 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | $widget = new $class_name; |
| 339 | 339 | |
| 340 | 340 | ob_start(); |
| 341 | - $widget->form( array() ); |
|
| 341 | + $widget->form(array()); |
|
| 342 | 342 | $form = ob_get_clean(); |
| 343 | 343 | echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
| 344 | 344 | echo "<style>" . $widget->widget_css() . "</style>"; |
@@ -356,9 +356,9 @@ discard block |
||
| 356 | 356 | * @param string $editor_id Optional. Shortcode editor id. Default null. |
| 357 | 357 | * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null. |
| 358 | 358 | */ |
| 359 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 359 | + public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') { |
|
| 360 | 360 | global $sd_widgets, $shortcode_insert_button_once; |
| 361 | - if ( $shortcode_insert_button_once ) { |
|
| 361 | + if ($shortcode_insert_button_once) { |
|
| 362 | 362 | return; |
| 363 | 363 | } |
| 364 | 364 | add_thickbox(); |
@@ -368,21 +368,21 @@ discard block |
||
| 368 | 368 | * Cornerstone makes us play dirty tricks :/ |
| 369 | 369 | * 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. |
| 370 | 370 | */ |
| 371 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 371 | + if (function_exists('cornerstone_plugin_init') && !is_admin()) { |
|
| 372 | 372 | echo '<span id="insert-media-button">'; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - echo self::shortcode_button( 'this', 'true' ); |
|
| 375 | + echo self::shortcode_button('this', 'true'); |
|
| 376 | 376 | |
| 377 | 377 | // see opening note |
| 378 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 378 | + if (function_exists('cornerstone_plugin_init') && !is_admin()) { |
|
| 379 | 379 | echo '</span>'; // end #insert-media-button |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | // Add separate script for generatepress theme sections |
| 383 | - if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 383 | + if (function_exists('generate_sections_sections_metabox') && did_action('generate_sections_metabox')) { |
|
| 384 | 384 | } else { |
| 385 | - self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 385 | + self::shortcode_insert_button_script($editor_id, $insert_shortcode_function); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | $shortcode_insert_button_once = true; |
@@ -396,12 +396,12 @@ discard block |
||
| 396 | 396 | * |
| 397 | 397 | * @return mixed |
| 398 | 398 | */ |
| 399 | - public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 399 | + public static function shortcode_button($id = '', $search_for_id = '') { |
|
| 400 | 400 | ob_start(); |
| 401 | 401 | ?> |
| 402 | 402 | <span class="sd-lable-shortcode-inserter"> |
| 403 | 403 | <a onclick="sd_ajax_get_picker(<?php echo $id; |
| 404 | - if ( $search_for_id ) { |
|
| 404 | + if ($search_for_id) { |
|
| 405 | 405 | echo "," . $search_for_id; |
| 406 | 406 | } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
| 407 | 407 | class="thickbox button super-duper-content-open" title="Add Shortcode"> |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | $html = ob_get_clean(); |
| 418 | 418 | |
| 419 | 419 | // remove line breaks so we can use it in js |
| 420 | - return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 420 | + return preg_replace("/\r|\n/", "", trim($html)); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | /** |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | jQuery($this).data('sd-widget-enabled', true); |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - 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>'; |
|
| 478 | + 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>'; |
|
| 479 | 479 | var form = jQuery($this).parents('' + $selector + ''); |
| 480 | 480 | |
| 481 | 481 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -512,10 +512,10 @@ discard block |
||
| 512 | 512 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 513 | 513 | */ |
| 514 | 514 | |
| 515 | - return str_replace( array( |
|
| 515 | + return str_replace(array( |
|
| 516 | 516 | '<script>', |
| 517 | 517 | '</script>' |
| 518 | - ), '', $output ); |
|
| 518 | + ), '', $output); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | /** |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | * @param string $editor_id |
| 527 | 527 | * @param string $insert_shortcode_function |
| 528 | 528 | */ |
| 529 | - public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 529 | + public static function shortcode_insert_button_script($editor_id = '', $insert_shortcode_function = '') { |
|
| 530 | 530 | ?> |
| 531 | 531 | <style> |
| 532 | 532 | .sd-shortcode-left-wrap { |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | width: 100%; |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | - <?php if ( function_exists( 'generate_sections_sections_metabox' ) ) { ?> |
|
| 648 | + <?php if (function_exists('generate_sections_sections_metabox')) { ?> |
|
| 649 | 649 | .generate-sections-modal #custom-media-buttons > .sd-lable-shortcode-inserter { |
| 650 | 650 | display: inline; |
| 651 | 651 | } |
@@ -653,15 +653,15 @@ discard block |
||
| 653 | 653 | <?php } ?> |
| 654 | 654 | </style> |
| 655 | 655 | <?php |
| 656 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 656 | + if (class_exists('SiteOrigin_Panels')) { |
|
| 657 | 657 | echo "<script>" . self::siteorigin_js() . "</script>"; |
| 658 | 658 | } |
| 659 | 659 | ?> |
| 660 | 660 | <script> |
| 661 | 661 | <?php |
| 662 | - if(! empty( $insert_shortcode_function )){ |
|
| 662 | + if (!empty($insert_shortcode_function)) { |
|
| 663 | 663 | echo $insert_shortcode_function; |
| 664 | - }else{ |
|
| 664 | + } else { |
|
| 665 | 665 | |
| 666 | 666 | /** |
| 667 | 667 | * Function for super duper insert shortcode. |
@@ -674,9 +674,9 @@ discard block |
||
| 674 | 674 | if ($shortcode) { |
| 675 | 675 | if (!$editor_id) { |
| 676 | 676 | <?php |
| 677 | - if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 677 | + if (isset($_REQUEST['et_fb'])) { |
|
| 678 | 678 | echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
| 679 | - } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 679 | + } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') { |
|
| 680 | 680 | echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
| 681 | 681 | } else { |
| 682 | 682 | echo '$editor_id = "#wp-content-editor-container textarea";'; |
@@ -761,11 +761,11 @@ discard block |
||
| 761 | 761 | 'shortcode': $short_code, |
| 762 | 762 | 'attributes': 123, |
| 763 | 763 | 'post_id': 321, |
| 764 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
|
| 764 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>' |
|
| 765 | 765 | }; |
| 766 | 766 | |
| 767 | 767 | if (typeof ajaxurl === 'undefined') { |
| 768 | - var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>"; |
|
| 768 | + var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | jQuery.post(ajaxurl, data, function (response) { |
@@ -974,11 +974,11 @@ discard block |
||
| 974 | 974 | var data = { |
| 975 | 975 | 'action': 'super_duper_get_picker', |
| 976 | 976 | 'editor_id': $id, |
| 977 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_picker' );?>' |
|
| 977 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_picker'); ?>' |
|
| 978 | 978 | }; |
| 979 | 979 | |
| 980 | 980 | if (!ajaxurl) { |
| 981 | - var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>"; |
|
| 981 | + var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; |
|
| 982 | 982 | } |
| 983 | 983 | |
| 984 | 984 | jQuery.post(ajaxurl, data, function (response) { |
@@ -999,9 +999,9 @@ discard block |
||
| 999 | 999 | */ |
| 1000 | 1000 | function sd_shortcode_button($id) { |
| 1001 | 1001 | if ($id) { |
| 1002 | - return '<?php echo self::shortcode_button( "\\''+\$id+'\\'" );?>'; |
|
| 1002 | + return '<?php echo self::shortcode_button("\\''+\$id+'\\'"); ?>'; |
|
| 1003 | 1003 | } else { |
| 1004 | - return '<?php echo self::shortcode_button();?>'; |
|
| 1004 | + return '<?php echo self::shortcode_button(); ?>'; |
|
| 1005 | 1005 | } |
| 1006 | 1006 | } |
| 1007 | 1007 | |
@@ -1016,11 +1016,11 @@ discard block |
||
| 1016 | 1016 | * |
| 1017 | 1017 | * @return mixed |
| 1018 | 1018 | */ |
| 1019 | - public function widget_css( $advanced = true ) { |
|
| 1019 | + public function widget_css($advanced = true) { |
|
| 1020 | 1020 | ob_start(); |
| 1021 | 1021 | ?> |
| 1022 | 1022 | <style> |
| 1023 | - <?php if( $advanced ){ ?> |
|
| 1023 | + <?php if ($advanced) { ?> |
|
| 1024 | 1024 | .sd-advanced-setting { |
| 1025 | 1025 | display: none; |
| 1026 | 1026 | } |
@@ -1062,10 +1062,10 @@ discard block |
||
| 1062 | 1062 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1063 | 1063 | */ |
| 1064 | 1064 | |
| 1065 | - return str_replace( array( |
|
| 1065 | + return str_replace(array( |
|
| 1066 | 1066 | '<style>', |
| 1067 | 1067 | '</style>' |
| 1068 | - ), '', $output ); |
|
| 1068 | + ), '', $output); |
|
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | 1071 | /** |
@@ -1135,7 +1135,7 @@ discard block |
||
| 1135 | 1135 | jQuery($this).data('sd-widget-enabled', true); |
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | - 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>'; |
|
| 1138 | + 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>'; |
|
| 1139 | 1139 | var form = jQuery($this).parents('' + $selector + ''); |
| 1140 | 1140 | |
| 1141 | 1141 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -1227,7 +1227,7 @@ discard block |
||
| 1227 | 1227 | }); |
| 1228 | 1228 | |
| 1229 | 1229 | } |
| 1230 | - <?php do_action( 'wp_super_duper_widget_js', $this ); ?> |
|
| 1230 | + <?php do_action('wp_super_duper_widget_js', $this); ?> |
|
| 1231 | 1231 | </script> |
| 1232 | 1232 | <?php |
| 1233 | 1233 | $output = ob_get_clean(); |
@@ -1236,10 +1236,10 @@ discard block |
||
| 1236 | 1236 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1237 | 1237 | */ |
| 1238 | 1238 | |
| 1239 | - return str_replace( array( |
|
| 1239 | + return str_replace(array( |
|
| 1240 | 1240 | '<script>', |
| 1241 | 1241 | '</script>' |
| 1242 | - ), '', $output ); |
|
| 1242 | + ), '', $output); |
|
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | 1245 | |
@@ -1250,14 +1250,14 @@ discard block |
||
| 1250 | 1250 | * |
| 1251 | 1251 | * @return mixed |
| 1252 | 1252 | */ |
| 1253 | - private function add_name_from_key( $options, $arguments = false ) { |
|
| 1254 | - if ( ! empty( $options['arguments'] ) ) { |
|
| 1255 | - foreach ( $options['arguments'] as $key => $val ) { |
|
| 1256 | - $options['arguments'][ $key ]['name'] = $key; |
|
| 1253 | + private function add_name_from_key($options, $arguments = false) { |
|
| 1254 | + if (!empty($options['arguments'])) { |
|
| 1255 | + foreach ($options['arguments'] as $key => $val) { |
|
| 1256 | + $options['arguments'][$key]['name'] = $key; |
|
| 1257 | 1257 | } |
| 1258 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1259 | - foreach ( $options as $key => $val ) { |
|
| 1260 | - $options[ $key ]['name'] = $key; |
|
| 1258 | + } elseif ($arguments && is_array($options) && !empty($options)) { |
|
| 1259 | + foreach ($options as $key => $val) { |
|
| 1260 | + $options[$key]['name'] = $key; |
|
| 1261 | 1261 | } |
| 1262 | 1262 | } |
| 1263 | 1263 | |
@@ -1270,8 +1270,8 @@ discard block |
||
| 1270 | 1270 | * @since 1.0.0 |
| 1271 | 1271 | */ |
| 1272 | 1272 | public function register_shortcode() { |
| 1273 | - add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1274 | - add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) ); |
|
| 1273 | + add_shortcode($this->base_id, array($this, 'shortcode_output')); |
|
| 1274 | + add_action('wp_ajax_super_duper_output_shortcode', array(__CLASS__, 'render_shortcode')); |
|
| 1275 | 1275 | } |
| 1276 | 1276 | |
| 1277 | 1277 | /** |
@@ -1281,33 +1281,33 @@ discard block |
||
| 1281 | 1281 | */ |
| 1282 | 1282 | public static function render_shortcode() { |
| 1283 | 1283 | |
| 1284 | - check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1285 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1284 | + check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true); |
|
| 1285 | + if (!current_user_can('manage_options')) { |
|
| 1286 | 1286 | wp_die(); |
| 1287 | 1287 | } |
| 1288 | 1288 | |
| 1289 | 1289 | // we might need the $post value here so lets set it. |
| 1290 | - if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1291 | - $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1292 | - if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1290 | + if (isset($_POST['post_id']) && $_POST['post_id']) { |
|
| 1291 | + $post_obj = get_post(absint($_POST['post_id'])); |
|
| 1292 | + if (!empty($post_obj) && empty($post)) { |
|
| 1293 | 1293 | global $post; |
| 1294 | 1294 | $post = $post_obj; |
| 1295 | 1295 | } |
| 1296 | 1296 | } |
| 1297 | 1297 | |
| 1298 | - if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1299 | - $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1300 | - $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1298 | + if (isset($_POST['shortcode']) && $_POST['shortcode']) { |
|
| 1299 | + $shortcode_name = sanitize_title_with_dashes($_POST['shortcode']); |
|
| 1300 | + $attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1301 | 1301 | $attributes = ''; |
| 1302 | - if ( ! empty( $attributes_array ) ) { |
|
| 1303 | - foreach ( $attributes_array as $key => $value ) { |
|
| 1304 | - $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' "; |
|
| 1302 | + if (!empty($attributes_array)) { |
|
| 1303 | + foreach ($attributes_array as $key => $value) { |
|
| 1304 | + $attributes .= " " . sanitize_title_with_dashes($key) . "='" . wp_slash($value) . "' "; |
|
| 1305 | 1305 | } |
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | 1308 | $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
| 1309 | 1309 | |
| 1310 | - echo do_shortcode( $shortcode ); |
|
| 1310 | + echo do_shortcode($shortcode); |
|
| 1311 | 1311 | |
| 1312 | 1312 | } |
| 1313 | 1313 | wp_die(); |
@@ -1321,45 +1321,45 @@ discard block |
||
| 1321 | 1321 | * |
| 1322 | 1322 | * @return string |
| 1323 | 1323 | */ |
| 1324 | - public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1325 | - $args = $this->argument_values( $args ); |
|
| 1324 | + public function shortcode_output($args = array(), $content = '') { |
|
| 1325 | + $args = $this->argument_values($args); |
|
| 1326 | 1326 | |
| 1327 | 1327 | // add extra argument so we know its a output to gutenberg |
| 1328 | 1328 | //$args |
| 1329 | - $args = $this->string_to_bool( $args ); |
|
| 1329 | + $args = $this->string_to_bool($args); |
|
| 1330 | 1330 | |
| 1331 | 1331 | // if we have a enclosed shortcode we add it to the special `html` argument |
| 1332 | - if ( ! empty( $content ) ) { |
|
| 1332 | + if (!empty($content)) { |
|
| 1333 | 1333 | $args['html'] = $content; |
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | - $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1337 | - $class .= " sdel-".$this->get_instance_hash(); |
|
| 1336 | + $class = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : ''; |
|
| 1337 | + $class .= " sdel-" . $this->get_instance_hash(); |
|
| 1338 | 1338 | |
| 1339 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1340 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1339 | + $class = apply_filters('wp_super_duper_div_classname', $class, $args, $this); |
|
| 1340 | + $class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this); |
|
| 1341 | 1341 | |
| 1342 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1343 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); //@todo this does not seem right @kiran? |
|
| 1342 | + $attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this); |
|
| 1343 | + $attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this); //@todo this does not seem right @kiran? |
|
| 1344 | 1344 | |
| 1345 | 1345 | $shortcode_args = array(); |
| 1346 | 1346 | $output = ''; |
| 1347 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1348 | - if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1347 | + $no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false; |
|
| 1348 | + if (isset($args['no_wrap']) && $args['no_wrap']) { |
|
| 1349 | 1349 | $no_wrap = true; |
| 1350 | 1350 | } |
| 1351 | - $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1352 | - if ( $main_content && ! $no_wrap ) { |
|
| 1351 | + $main_content = $this->output($args, $shortcode_args, $content); |
|
| 1352 | + if ($main_content && !$no_wrap) { |
|
| 1353 | 1353 | // wrap the shortcode in a div with the same class as the widget |
| 1354 | 1354 | $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
| 1355 | - if ( ! empty( $args['title'] ) ) { |
|
| 1355 | + if (!empty($args['title'])) { |
|
| 1356 | 1356 | // if its a shortcode and there is a title try to grab the title wrappers |
| 1357 | - $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1358 | - if ( empty( $instance ) ) { |
|
| 1357 | + $shortcode_args = array('before_title' => '', 'after_title' => ''); |
|
| 1358 | + if (empty($instance)) { |
|
| 1359 | 1359 | global $wp_registered_sidebars; |
| 1360 | - if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1361 | - foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1362 | - if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1360 | + if (!empty($wp_registered_sidebars)) { |
|
| 1361 | + foreach ($wp_registered_sidebars as $sidebar) { |
|
| 1362 | + if (!empty($sidebar['before_title'])) { |
|
| 1363 | 1363 | $shortcode_args['before_title'] = $sidebar['before_title']; |
| 1364 | 1364 | $shortcode_args['after_title'] = $sidebar['after_title']; |
| 1365 | 1365 | break; |
@@ -1367,20 +1367,20 @@ discard block |
||
| 1367 | 1367 | } |
| 1368 | 1368 | } |
| 1369 | 1369 | } |
| 1370 | - $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1370 | + $output .= $this->output_title($shortcode_args, $args); |
|
| 1371 | 1371 | } |
| 1372 | 1372 | $output .= $main_content; |
| 1373 | 1373 | $output .= '</div>'; |
| 1374 | - } elseif ( $main_content && $no_wrap ) { |
|
| 1374 | + } elseif ($main_content && $no_wrap) { |
|
| 1375 | 1375 | $output .= $main_content; |
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | 1378 | // if preview show a placeholder if empty |
| 1379 | - if ( $this->is_preview() && $output == '' ) { |
|
| 1380 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1379 | + if ($this->is_preview() && $output == '') { |
|
| 1380 | + $output = $this->preview_placeholder_text("{{" . $this->base_id . "}}"); |
|
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | - return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1383 | + return apply_filters('wp_super_duper_widget_output', $output, $args, $shortcode_args, $this); |
|
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | 1386 | /** |
@@ -1390,8 +1390,8 @@ discard block |
||
| 1390 | 1390 | * |
| 1391 | 1391 | * @return string |
| 1392 | 1392 | */ |
| 1393 | - public function preview_placeholder_text( $name = '' ) { |
|
| 1394 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1393 | + public function preview_placeholder_text($name = '') { |
|
| 1394 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf(__('Placeholder for: %s'), $name) . "</div>"; |
|
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | /** |
@@ -1401,13 +1401,13 @@ discard block |
||
| 1401 | 1401 | * |
| 1402 | 1402 | * @return mixed |
| 1403 | 1403 | */ |
| 1404 | - public function string_to_bool( $options ) { |
|
| 1404 | + public function string_to_bool($options) { |
|
| 1405 | 1405 | // convert bool strings to booleans |
| 1406 | - foreach ( $options as $key => $val ) { |
|
| 1407 | - if ( $val == 'false' ) { |
|
| 1408 | - $options[ $key ] = false; |
|
| 1409 | - } elseif ( $val == 'true' ) { |
|
| 1410 | - $options[ $key ] = true; |
|
| 1406 | + foreach ($options as $key => $val) { |
|
| 1407 | + if ($val == 'false') { |
|
| 1408 | + $options[$key] = false; |
|
| 1409 | + } elseif ($val == 'true') { |
|
| 1410 | + $options[$key] = true; |
|
| 1411 | 1411 | } |
| 1412 | 1412 | } |
| 1413 | 1413 | |
@@ -1423,26 +1423,26 @@ discard block |
||
| 1423 | 1423 | * |
| 1424 | 1424 | * @return array |
| 1425 | 1425 | */ |
| 1426 | - public function argument_values( $instance ) { |
|
| 1426 | + public function argument_values($instance) { |
|
| 1427 | 1427 | $argument_values = array(); |
| 1428 | 1428 | |
| 1429 | 1429 | // set widget instance |
| 1430 | 1430 | $this->instance = $instance; |
| 1431 | 1431 | |
| 1432 | - if ( empty( $this->arguments ) ) { |
|
| 1432 | + if (empty($this->arguments)) { |
|
| 1433 | 1433 | $this->arguments = $this->get_arguments(); |
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | - if ( ! empty( $this->arguments ) ) { |
|
| 1437 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1436 | + if (!empty($this->arguments)) { |
|
| 1437 | + foreach ($this->arguments as $key => $args) { |
|
| 1438 | 1438 | // set the input name from the key |
| 1439 | 1439 | $args['name'] = $key; |
| 1440 | 1440 | // |
| 1441 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1442 | - if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1441 | + $argument_values[$key] = isset($instance[$key]) ? $instance[$key] : ''; |
|
| 1442 | + if ($args['type'] == 'checkbox' && $argument_values[$key] == '') { |
|
| 1443 | 1443 | // don't set default for an empty checkbox |
| 1444 | - } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1445 | - $argument_values[ $key ] = $args['default']; |
|
| 1444 | + } elseif ($argument_values[$key] == '' && isset($args['default'])) { |
|
| 1445 | + $argument_values[$key] = $args['default']; |
|
| 1446 | 1446 | } |
| 1447 | 1447 | } |
| 1448 | 1448 | } |
@@ -1469,12 +1469,12 @@ discard block |
||
| 1469 | 1469 | * @return array Get arguments. |
| 1470 | 1470 | */ |
| 1471 | 1471 | public function get_arguments() { |
| 1472 | - if ( empty( $this->arguments ) ) { |
|
| 1472 | + if (empty($this->arguments)) { |
|
| 1473 | 1473 | $this->arguments = $this->set_arguments(); |
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1477 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1476 | + $this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance); |
|
| 1477 | + $this->arguments = $this->add_name_from_key($this->arguments, true); |
|
| 1478 | 1478 | |
| 1479 | 1479 | return $this->arguments; |
| 1480 | 1480 | } |
@@ -1486,7 +1486,7 @@ discard block |
||
| 1486 | 1486 | * @param array $widget_args |
| 1487 | 1487 | * @param string $content |
| 1488 | 1488 | */ |
| 1489 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1489 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 1490 | 1490 | |
| 1491 | 1491 | } |
| 1492 | 1492 | |
@@ -1494,9 +1494,9 @@ discard block |
||
| 1494 | 1494 | * Add the dynamic block code inline when the wp-block in enqueued. |
| 1495 | 1495 | */ |
| 1496 | 1496 | public function register_block() { |
| 1497 | - wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1498 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1499 | - wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1497 | + wp_add_inline_script('wp-blocks', $this->block()); |
|
| 1498 | + if (class_exists('SiteOrigin_Panels')) { |
|
| 1499 | + wp_add_inline_script('wp-blocks', $this->siteorigin_js()); |
|
| 1500 | 1500 | } |
| 1501 | 1501 | } |
| 1502 | 1502 | |
@@ -1510,13 +1510,13 @@ discard block |
||
| 1510 | 1510 | $show = false; |
| 1511 | 1511 | $arguments = $this->arguments; |
| 1512 | 1512 | |
| 1513 | - if ( empty( $arguments ) ) { |
|
| 1513 | + if (empty($arguments)) { |
|
| 1514 | 1514 | $arguments = $this->get_arguments(); |
| 1515 | 1515 | } |
| 1516 | 1516 | |
| 1517 | - if ( ! empty( $arguments ) ) { |
|
| 1518 | - foreach ( $arguments as $argument ) { |
|
| 1519 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1517 | + if (!empty($arguments)) { |
|
| 1518 | + foreach ($arguments as $argument) { |
|
| 1519 | + if (isset($argument['advanced']) && $argument['advanced']) { |
|
| 1520 | 1520 | $show = true; |
| 1521 | 1521 | break; // no need to continue if we know we have it |
| 1522 | 1522 | } |
@@ -1535,15 +1535,15 @@ discard block |
||
| 1535 | 1535 | |
| 1536 | 1536 | $url = $this->url; |
| 1537 | 1537 | |
| 1538 | - if ( ! $url ) { |
|
| 1538 | + if (!$url) { |
|
| 1539 | 1539 | // check if we are inside a plugin |
| 1540 | - $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1540 | + $file_dir = str_replace("/includes", "", dirname(__FILE__)); |
|
| 1541 | 1541 | |
| 1542 | - $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1543 | - $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1542 | + $dir_parts = explode("/wp-content/", $file_dir); |
|
| 1543 | + $url_parts = explode("/wp-content/", plugins_url()); |
|
| 1544 | 1544 | |
| 1545 | - if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1546 | - $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1545 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
| 1546 | + $url = trailingslashit($url_parts[0] . "/wp-content/" . $dir_parts[1]); |
|
| 1547 | 1547 | $this->url = $url; |
| 1548 | 1548 | } |
| 1549 | 1549 | } |
@@ -1564,46 +1564,46 @@ discard block |
||
| 1564 | 1564 | * @since 1.1.0 |
| 1565 | 1565 | * @return string |
| 1566 | 1566 | */ |
| 1567 | - public function get_block_icon( $icon ) { |
|
| 1567 | + public function get_block_icon($icon) { |
|
| 1568 | 1568 | |
| 1569 | 1569 | // check if we have a Font Awesome icon |
| 1570 | 1570 | $fa_type = ''; |
| 1571 | - if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1571 | + if (substr($icon, 0, 7) === "fas fa-") { |
|
| 1572 | 1572 | $fa_type = 'solid'; |
| 1573 | - } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1573 | + } elseif (substr($icon, 0, 7) === "far fa-") { |
|
| 1574 | 1574 | $fa_type = 'regular'; |
| 1575 | - } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1575 | + } elseif (substr($icon, 0, 7) === "fab fa-") { |
|
| 1576 | 1576 | $fa_type = 'brands'; |
| 1577 | 1577 | } else { |
| 1578 | 1578 | $icon = "'" . $icon . "'"; |
| 1579 | 1579 | } |
| 1580 | 1580 | |
| 1581 | 1581 | // set the icon if we found one |
| 1582 | - if ( $fa_type ) { |
|
| 1583 | - $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1582 | + if ($fa_type) { |
|
| 1583 | + $fa_icon = str_replace(array("fas fa-", "far fa-", "fab fa-"), "", $icon); |
|
| 1584 | 1584 | $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 . "'}))"; |
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | 1587 | return $icon; |
| 1588 | 1588 | } |
| 1589 | 1589 | |
| 1590 | - public function group_arguments( $arguments ) { |
|
| 1590 | + public function group_arguments($arguments) { |
|
| 1591 | 1591 | // echo '###';print_r($arguments); |
| 1592 | - if ( ! empty( $arguments ) ) { |
|
| 1592 | + if (!empty($arguments)) { |
|
| 1593 | 1593 | $temp_arguments = array(); |
| 1594 | - $general = __( "General" ); |
|
| 1594 | + $general = __("General"); |
|
| 1595 | 1595 | $add_sections = false; |
| 1596 | - foreach ( $arguments as $key => $args ) { |
|
| 1597 | - if ( isset( $args['group'] ) ) { |
|
| 1598 | - $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1596 | + foreach ($arguments as $key => $args) { |
|
| 1597 | + if (isset($args['group'])) { |
|
| 1598 | + $temp_arguments[$args['group']][$key] = $args; |
|
| 1599 | 1599 | $add_sections = true; |
| 1600 | 1600 | } else { |
| 1601 | - $temp_arguments[ $general ][ $key ] = $args; |
|
| 1601 | + $temp_arguments[$general][$key] = $args; |
|
| 1602 | 1602 | } |
| 1603 | 1603 | } |
| 1604 | 1604 | |
| 1605 | 1605 | // only add sections if more than one |
| 1606 | - if ( $add_sections ) { |
|
| 1606 | + if ($add_sections) { |
|
| 1607 | 1607 | $arguments = $temp_arguments; |
| 1608 | 1608 | } |
| 1609 | 1609 | } |
@@ -1645,8 +1645,8 @@ discard block |
||
| 1645 | 1645 | var prev_attributes = []; |
| 1646 | 1646 | |
| 1647 | 1647 | var term_query_type = ''; |
| 1648 | - 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 "[]";} ?>; |
|
| 1649 | - const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}]; |
|
| 1648 | + 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 "[]"; } ?>; |
|
| 1649 | + const taxonomies_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}]; |
|
| 1650 | 1650 | |
| 1651 | 1651 | /** |
| 1652 | 1652 | * Register Basic Block. |
@@ -1660,30 +1660,30 @@ discard block |
||
| 1660 | 1660 | * @return {?WPBlock} The block, if it has been successfully |
| 1661 | 1661 | * registered; otherwise `undefined`. |
| 1662 | 1662 | */ |
| 1663 | - 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. |
|
| 1664 | - title: '<?php echo addslashes( $this->options['name'] ); ?>', // Block title. |
|
| 1665 | - description: '<?php echo addslashes( $this->options['widget_ops']['description'] )?>', // Block title. |
|
| 1666 | - 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/. |
|
| 1663 | + 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. |
|
| 1664 | + title: '<?php echo addslashes($this->options['name']); ?>', // Block title. |
|
| 1665 | + description: '<?php echo addslashes($this->options['widget_ops']['description'])?>', // Block title. |
|
| 1666 | + 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/. |
|
| 1667 | 1667 | supports: { |
| 1668 | 1668 | <?php |
| 1669 | - if ( isset( $this->options['block-supports'] ) ) { |
|
| 1670 | - echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 1669 | + if (isset($this->options['block-supports'])) { |
|
| 1670 | + echo $this->array_to_attributes($this->options['block-supports']); |
|
| 1671 | 1671 | } |
| 1672 | 1672 | ?> |
| 1673 | 1673 | }, |
| 1674 | - 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. |
|
| 1675 | - <?php if ( isset( $this->options['block-keywords'] ) ) { |
|
| 1674 | + 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. |
|
| 1675 | + <?php if (isset($this->options['block-keywords'])) { |
|
| 1676 | 1676 | echo "keywords : " . $this->options['block-keywords'] . ","; |
| 1677 | 1677 | }?> |
| 1678 | 1678 | |
| 1679 | 1679 | <?php |
| 1680 | 1680 | |
| 1681 | 1681 | // maybe set no_wrap |
| 1682 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1683 | - if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 1682 | + $no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false; |
|
| 1683 | + if (isset($this->arguments['no_wrap']) && $this->arguments['no_wrap']) { |
|
| 1684 | 1684 | $no_wrap = true; |
| 1685 | 1685 | } |
| 1686 | - if ( $no_wrap ) { |
|
| 1686 | + if ($no_wrap) { |
|
| 1687 | 1687 | $this->options['block-wrap'] = ''; |
| 1688 | 1688 | } |
| 1689 | 1689 | |
@@ -1696,10 +1696,10 @@ discard block |
||
| 1696 | 1696 | echo " html: false"; |
| 1697 | 1697 | echo "},";*/ |
| 1698 | 1698 | |
| 1699 | - if ( ! empty( $this->arguments ) ) { |
|
| 1699 | + if (!empty($this->arguments)) { |
|
| 1700 | 1700 | echo "attributes : {"; |
| 1701 | 1701 | |
| 1702 | - if ( $show_advanced ) { |
|
| 1702 | + if ($show_advanced) { |
|
| 1703 | 1703 | echo "show_advanced: {"; |
| 1704 | 1704 | echo " type: 'boolean',"; |
| 1705 | 1705 | echo " default: false,"; |
@@ -1707,41 +1707,41 @@ discard block |
||
| 1707 | 1707 | } |
| 1708 | 1708 | |
| 1709 | 1709 | // block wrap element |
| 1710 | - if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 1710 | + if (!empty($this->options['block-wrap'])) { //@todo we should validate this? |
|
| 1711 | 1711 | echo "block_wrap: {"; |
| 1712 | 1712 | echo " type: 'string',"; |
| 1713 | - echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 1713 | + echo " default: '" . esc_attr($this->options['block-wrap']) . "',"; |
|
| 1714 | 1714 | echo "},"; |
| 1715 | 1715 | } |
| 1716 | 1716 | |
| 1717 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1717 | + foreach ($this->arguments as $key => $args) { |
|
| 1718 | 1718 | |
| 1719 | 1719 | // set if we should show alignment |
| 1720 | - if ( $key == 'alignment' ) { |
|
| 1720 | + if ($key == 'alignment') { |
|
| 1721 | 1721 | $show_alignment = true; |
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | 1724 | $extra = ''; |
| 1725 | 1725 | |
| 1726 | - if ( $args['type'] == 'checkbox' ) { |
|
| 1726 | + if ($args['type'] == 'checkbox') { |
|
| 1727 | 1727 | $type = 'boolean'; |
| 1728 | - $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 1729 | - } elseif ( $args['type'] == 'number' ) { |
|
| 1728 | + $default = isset($args['default']) && $args['default'] ? 'true' : 'false'; |
|
| 1729 | + } elseif ($args['type'] == 'number') { |
|
| 1730 | 1730 | $type = 'number'; |
| 1731 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1732 | - } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 1731 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 1732 | + } elseif ($args['type'] == 'select' && !empty($args['multiple'])) { |
|
| 1733 | 1733 | $type = 'array'; |
| 1734 | - if ( is_array( $args['default'] ) ) { |
|
| 1735 | - $default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 1734 | + if (is_array($args['default'])) { |
|
| 1735 | + $default = isset($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]"; |
|
| 1736 | 1736 | } else { |
| 1737 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1737 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 1738 | 1738 | } |
| 1739 | - } elseif ( $args['type'] == 'multiselect' ) { |
|
| 1739 | + } elseif ($args['type'] == 'multiselect') { |
|
| 1740 | 1740 | $type = 'array'; |
| 1741 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1741 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 1742 | 1742 | } else { |
| 1743 | 1743 | $type = 'string'; |
| 1744 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1744 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 1745 | 1745 | } |
| 1746 | 1746 | echo $key . " : {"; |
| 1747 | 1747 | echo "type : '$type',"; |
@@ -1765,7 +1765,7 @@ discard block |
||
| 1765 | 1765 | |
| 1766 | 1766 | <?php |
| 1767 | 1767 | // if we have a post_type and a category then link them |
| 1768 | - if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && isset($this->arguments['category']['post_type_linked']) ){ |
|
| 1768 | + if (isset($this->arguments['post_type']) && isset($this->arguments['category']) && isset($this->arguments['category']['post_type_linked'])) { |
|
| 1769 | 1769 | ?> |
| 1770 | 1770 | if(typeof(prev_attributes[props.id]) != 'undefined' ){ |
| 1771 | 1771 | $pt = props.attributes.post_type; |
@@ -1774,13 +1774,13 @@ discard block |
||
| 1774 | 1774 | } |
| 1775 | 1775 | if('post_type' in prev_attributes[props.id] && 'category' in prev_attributes[props.id] && $pt != term_query_type ){ |
| 1776 | 1776 | term_query_type = $pt; |
| 1777 | - 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';} ?>"}).then(terms => { |
|
| 1778 | - while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) { |
|
| 1779 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop(); |
|
| 1777 | + 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'; } ?>"}).then(terms => { |
|
| 1778 | + while (taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.length) { |
|
| 1779 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.pop(); |
|
| 1780 | 1780 | } |
| 1781 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: "All", value: 0}); |
|
| 1781 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: "All", value: 0}); |
|
| 1782 | 1782 | jQuery.each( terms, function( key, val ) { |
| 1783 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: val.name, value: val.id}); |
|
| 1783 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val.name, value: val.id}); |
|
| 1784 | 1784 | }); |
| 1785 | 1785 | |
| 1786 | 1786 | // setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. |
@@ -1788,7 +1788,7 @@ discard block |
||
| 1788 | 1788 | props.setAttributes({category: [0] }); |
| 1789 | 1789 | props.setAttributes({category: $old_cat_value }); |
| 1790 | 1790 | |
| 1791 | - return taxonomies_<?php echo str_replace("-","_", $this->id);?>; |
|
| 1791 | + return taxonomies_<?php echo str_replace("-", "_", $this->id); ?>; |
|
| 1792 | 1792 | }); |
| 1793 | 1793 | } |
| 1794 | 1794 | } |
@@ -1814,12 +1814,12 @@ discard block |
||
| 1814 | 1814 | is_fetching = true; |
| 1815 | 1815 | var data = { |
| 1816 | 1816 | 'action': 'super_duper_output_shortcode', |
| 1817 | - 'shortcode': '<?php echo $this->options['base_id'];?>', |
|
| 1817 | + 'shortcode': '<?php echo $this->options['base_id']; ?>', |
|
| 1818 | 1818 | 'attributes': props.attributes, |
| 1819 | - 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
|
| 1819 | + 'post_id': <?php global $post; if (isset($post->ID)) { |
|
| 1820 | 1820 | echo $post->ID; |
| 1821 | 1821 | }?>, |
| 1822 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
|
| 1822 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>' |
|
| 1823 | 1823 | }; |
| 1824 | 1824 | |
| 1825 | 1825 | jQuery.post(ajaxurl, data, function (response) { |
@@ -1828,7 +1828,7 @@ discard block |
||
| 1828 | 1828 | |
| 1829 | 1829 | // if the content is empty then we place some placeholder text |
| 1830 | 1830 | if (env == '') { |
| 1831 | - env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for: ' );?>" + props.name + "</div>"; |
|
| 1831 | + env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for: '); ?>" + props.name + "</div>"; |
|
| 1832 | 1832 | } |
| 1833 | 1833 | |
| 1834 | 1834 | props.setAttributes({content: env}); |
@@ -1852,7 +1852,7 @@ discard block |
||
| 1852 | 1852 | |
| 1853 | 1853 | el(wp.blockEditor.BlockControls, {key: 'controls'}, |
| 1854 | 1854 | |
| 1855 | - <?php if($show_alignment){?> |
|
| 1855 | + <?php if ($show_alignment) {?> |
|
| 1856 | 1856 | el( |
| 1857 | 1857 | wp.blockEditor.AlignmentToolbar, |
| 1858 | 1858 | { |
@@ -1870,9 +1870,9 @@ discard block |
||
| 1870 | 1870 | |
| 1871 | 1871 | <?php |
| 1872 | 1872 | |
| 1873 | - if(! empty( $this->arguments )){ |
|
| 1873 | + if (!empty($this->arguments)) { |
|
| 1874 | 1874 | |
| 1875 | - if ( $show_advanced ) { |
|
| 1875 | + if ($show_advanced) { |
|
| 1876 | 1876 | ?> |
| 1877 | 1877 | el('div', { |
| 1878 | 1878 | style: {'padding-left': '16px','padding-right': '16px'} |
@@ -1893,19 +1893,19 @@ discard block |
||
| 1893 | 1893 | |
| 1894 | 1894 | } |
| 1895 | 1895 | |
| 1896 | - $arguments = $this->group_arguments( $this->arguments ); |
|
| 1896 | + $arguments = $this->group_arguments($this->arguments); |
|
| 1897 | 1897 | |
| 1898 | 1898 | // Do we have sections? |
| 1899 | 1899 | $has_sections = $arguments == $this->arguments ? false : true; |
| 1900 | 1900 | |
| 1901 | 1901 | |
| 1902 | - if($has_sections){ |
|
| 1902 | + if ($has_sections) { |
|
| 1903 | 1903 | $panel_count = 0; |
| 1904 | - foreach($arguments as $key => $args){ |
|
| 1904 | + foreach ($arguments as $key => $args) { |
|
| 1905 | 1905 | ?> |
| 1906 | 1906 | el(wp.components.PanelBody, { |
| 1907 | - title: '<?php esc_attr_e( $key ); ?>', |
|
| 1908 | - initialOpen: <?php if ( $panel_count ) { |
|
| 1907 | + title: '<?php esc_attr_e($key); ?>', |
|
| 1908 | + initialOpen: <?php if ($panel_count) { |
|
| 1909 | 1909 | echo "false"; |
| 1910 | 1910 | } else { |
| 1911 | 1911 | echo "true"; |
@@ -1913,24 +1913,24 @@ discard block |
||
| 1913 | 1913 | }, |
| 1914 | 1914 | <?php |
| 1915 | 1915 | |
| 1916 | - foreach ( $args as $k => $a ) { |
|
| 1917 | - $this->build_block_arguments( $k, $a ); |
|
| 1916 | + foreach ($args as $k => $a) { |
|
| 1917 | + $this->build_block_arguments($k, $a); |
|
| 1918 | 1918 | } |
| 1919 | 1919 | ?> |
| 1920 | 1920 | ), |
| 1921 | 1921 | <?php |
| 1922 | - $panel_count ++; |
|
| 1922 | + $panel_count++; |
|
| 1923 | 1923 | |
| 1924 | 1924 | } |
| 1925 | - }else { |
|
| 1925 | + } else { |
|
| 1926 | 1926 | ?> |
| 1927 | 1927 | el(wp.components.PanelBody, { |
| 1928 | - title: '<?php esc_attr_e( "Settings" ); ?>', |
|
| 1928 | + title: '<?php esc_attr_e("Settings"); ?>', |
|
| 1929 | 1929 | initialOpen: true |
| 1930 | 1930 | }, |
| 1931 | 1931 | <?php |
| 1932 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1933 | - $this->build_block_arguments( $key, $args ); |
|
| 1932 | + foreach ($this->arguments as $key => $args) { |
|
| 1933 | + $this->build_block_arguments($key, $args); |
|
| 1934 | 1934 | } |
| 1935 | 1935 | ?> |
| 1936 | 1936 | ), |
@@ -1944,9 +1944,9 @@ discard block |
||
| 1944 | 1944 | |
| 1945 | 1945 | <?php |
| 1946 | 1946 | // If the user sets block-output array then build it |
| 1947 | - if ( ! empty( $this->options['block-output'] ) ) { |
|
| 1948 | - $this->block_element( $this->options['block-output'] ); |
|
| 1949 | - }else{ |
|
| 1947 | + if (!empty($this->options['block-output'])) { |
|
| 1948 | + $this->block_element($this->options['block-output']); |
|
| 1949 | + } else { |
|
| 1950 | 1950 | // if no block-output is set then we try and get the shortcode html output via ajax. |
| 1951 | 1951 | ?> |
| 1952 | 1952 | el('div', { |
@@ -1970,19 +1970,19 @@ discard block |
||
| 1970 | 1970 | var align = ''; |
| 1971 | 1971 | |
| 1972 | 1972 | // build the shortcode. |
| 1973 | - var content = "[<?php echo $this->options['base_id'];?>"; |
|
| 1973 | + var content = "[<?php echo $this->options['base_id']; ?>"; |
|
| 1974 | 1974 | $html = ''; |
| 1975 | 1975 | <?php |
| 1976 | 1976 | |
| 1977 | - if(! empty( $this->arguments )){ |
|
| 1977 | + if (!empty($this->arguments)) { |
|
| 1978 | 1978 | |
| 1979 | - foreach($this->arguments as $key => $args){ |
|
| 1979 | + foreach ($this->arguments as $key => $args) { |
|
| 1980 | 1980 | ?> |
| 1981 | - if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
|
| 1982 | - if ('<?php echo esc_attr( $key );?>' == 'html') { |
|
| 1983 | - $html = attr.<?php echo esc_attr( $key );?>; |
|
| 1981 | + if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) { |
|
| 1982 | + if ('<?php echo esc_attr($key); ?>' == 'html') { |
|
| 1983 | + $html = attr.<?php echo esc_attr($key); ?>; |
|
| 1984 | 1984 | } else { |
| 1985 | - content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' "; |
|
| 1985 | + content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>+ "' "; |
|
| 1986 | 1986 | } |
| 1987 | 1987 | } |
| 1988 | 1988 | <?php |
@@ -1994,7 +1994,7 @@ discard block |
||
| 1994 | 1994 | |
| 1995 | 1995 | // if has html element |
| 1996 | 1996 | if ($html) { |
| 1997 | - content += $html + "[/<?php echo $this->options['base_id'];?>]"; |
|
| 1997 | + content += $html + "[/<?php echo $this->options['base_id']; ?>]"; |
|
| 1998 | 1998 | } |
| 1999 | 1999 | |
| 2000 | 2000 | |
@@ -2012,11 +2012,11 @@ discard block |
||
| 2012 | 2012 | } |
| 2013 | 2013 | |
| 2014 | 2014 | <?php |
| 2015 | - if(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 2015 | + if (isset($this->options['block-wrap']) && $this->options['block-wrap'] == '') { |
|
| 2016 | 2016 | ?> |
| 2017 | 2017 | return content; |
| 2018 | 2018 | <?php |
| 2019 | - }else{ |
|
| 2019 | + } else { |
|
| 2020 | 2020 | ?> |
| 2021 | 2021 | var block_wrap = 'div'; |
| 2022 | 2022 | if (attr.hasOwnProperty("block_wrap")) { |
@@ -2039,38 +2039,38 @@ discard block |
||
| 2039 | 2039 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 2040 | 2040 | */ |
| 2041 | 2041 | |
| 2042 | - return str_replace( array( |
|
| 2042 | + return str_replace(array( |
|
| 2043 | 2043 | '<script>', |
| 2044 | 2044 | '</script>' |
| 2045 | - ), '', $output ); |
|
| 2045 | + ), '', $output); |
|
| 2046 | 2046 | } |
| 2047 | 2047 | |
| 2048 | - public function build_block_arguments( $key, $args ) { |
|
| 2049 | - $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 2048 | + public function build_block_arguments($key, $args) { |
|
| 2049 | + $custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : ''; |
|
| 2050 | 2050 | $options = ''; |
| 2051 | 2051 | $extra = ''; |
| 2052 | 2052 | $require = ''; |
| 2053 | 2053 | |
| 2054 | 2054 | // `content` is a protected and special argument |
| 2055 | - if ( $key == 'content' ) { |
|
| 2055 | + if ($key == 'content') { |
|
| 2056 | 2056 | return; |
| 2057 | 2057 | } |
| 2058 | 2058 | |
| 2059 | 2059 | // require advanced |
| 2060 | - $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; |
|
| 2060 | + $require_advanced = !empty($args['advanced']) ? "props.attributes.show_advanced && " : ""; |
|
| 2061 | 2061 | |
| 2062 | 2062 | // element require |
| 2063 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 2063 | + $element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : ""; |
|
| 2064 | 2064 | |
| 2065 | 2065 | |
| 2066 | 2066 | $onchange = "props.setAttributes({ $key: $key } )"; |
| 2067 | - $onchangecomplete = ""; |
|
| 2067 | + $onchangecomplete = ""; |
|
| 2068 | 2068 | $value = "props.attributes.$key"; |
| 2069 | - $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx' ); |
|
| 2070 | - if ( in_array( $args['type'], $text_type ) ) { |
|
| 2069 | + $text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'colorx'); |
|
| 2070 | + if (in_array($args['type'], $text_type)) { |
|
| 2071 | 2071 | $type = 'TextControl'; |
| 2072 | 2072 | // Save numbers as numbers and not strings |
| 2073 | - if ( $args['type'] == 'number' ) { |
|
| 2073 | + if ($args['type'] == 'number') { |
|
| 2074 | 2074 | $onchange = "props.setAttributes({ $key: Number($key) } )"; |
| 2075 | 2075 | } |
| 2076 | 2076 | } |
@@ -2108,11 +2108,11 @@ discard block |
||
| 2108 | 2108 | return; |
| 2109 | 2109 | } |
| 2110 | 2110 | */ |
| 2111 | - elseif ( $args['type'] == 'color' ) { |
|
| 2111 | + elseif ($args['type'] == 'color') { |
|
| 2112 | 2112 | $type = 'ColorPicker'; |
| 2113 | 2113 | $onchange = ""; |
| 2114 | 2114 | $extra = "color: $value,"; |
| 2115 | - if(!empty($args['disable_alpha'])){ |
|
| 2115 | + if (!empty($args['disable_alpha'])) { |
|
| 2116 | 2116 | $extra .= "disableAlpha: true,"; |
| 2117 | 2117 | } |
| 2118 | 2118 | $onchangecomplete = "onChangeComplete: function($key) { |
@@ -2122,45 +2122,45 @@ discard block |
||
| 2122 | 2122 | }); |
| 2123 | 2123 | },"; |
| 2124 | 2124 | } |
| 2125 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 2125 | + elseif ($args['type'] == 'checkbox') { |
|
| 2126 | 2126 | $type = 'CheckboxControl'; |
| 2127 | 2127 | $extra .= "checked: props.attributes.$key,"; |
| 2128 | 2128 | $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
| 2129 | - } elseif ( $args['type'] == 'textarea' ) { |
|
| 2129 | + } elseif ($args['type'] == 'textarea') { |
|
| 2130 | 2130 | $type = 'TextareaControl'; |
| 2131 | - } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 2131 | + } elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') { |
|
| 2132 | 2132 | $type = 'SelectControl'; |
| 2133 | 2133 | |
| 2134 | - if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
|
| 2135 | - $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
|
| 2136 | - }else { |
|
| 2134 | + if ($args['name'] == 'category' && !empty($args['post_type_linked'])) { |
|
| 2135 | + $options .= "options: taxonomies_" . str_replace("-", "_", $this->id) . ","; |
|
| 2136 | + } else { |
|
| 2137 | 2137 | |
| 2138 | - if ( ! empty( $args['options'] ) ) { |
|
| 2138 | + if (!empty($args['options'])) { |
|
| 2139 | 2139 | $options .= "options: ["; |
| 2140 | - foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 2141 | - $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },"; |
|
| 2140 | + foreach ($args['options'] as $option_val => $option_label) { |
|
| 2141 | + $options .= "{ value: '" . esc_attr($option_val) . "', label: '" . addslashes($option_label) . "' },"; |
|
| 2142 | 2142 | } |
| 2143 | 2143 | $options .= "],"; |
| 2144 | 2144 | } |
| 2145 | 2145 | } |
| 2146 | - if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 2146 | + if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 2147 | 2147 | $extra .= ' multiple: true, '; |
| 2148 | 2148 | } |
| 2149 | - } elseif ( $args['type'] == 'alignment' ) { |
|
| 2149 | + } elseif ($args['type'] == 'alignment') { |
|
| 2150 | 2150 | $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
| 2151 | 2151 | } else { |
| 2152 | - return;// if we have not implemented the control then don't break the JS. |
|
| 2152 | + return; // if we have not implemented the control then don't break the JS. |
|
| 2153 | 2153 | } |
| 2154 | 2154 | |
| 2155 | 2155 | |
| 2156 | 2156 | |
| 2157 | 2157 | // color input does not show the labels so we add them |
| 2158 | - if($args['type']=='color'){ |
|
| 2158 | + if ($args['type'] == 'color') { |
|
| 2159 | 2159 | // add show only if advanced |
| 2160 | 2160 | echo $require_advanced; |
| 2161 | 2161 | // add setting require if defined |
| 2162 | 2162 | echo $element_require; |
| 2163 | - echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; |
|
| 2163 | + echo "el('div', {style: {'marginBottom': '8px'}}, '" . addslashes($args['title']) . "'),"; |
|
| 2164 | 2164 | } |
| 2165 | 2165 | |
| 2166 | 2166 | // add show only if advanced |
@@ -2169,21 +2169,21 @@ discard block |
||
| 2169 | 2169 | echo $element_require; |
| 2170 | 2170 | ?> |
| 2171 | 2171 | el( wp.components.<?php echo $type; ?>, { |
| 2172 | - label: '<?php echo addslashes( $args['title'] ); ?>', |
|
| 2173 | - help: '<?php if ( isset( $args['desc'] ) ) { |
|
| 2174 | - echo addslashes( $args['desc'] ); |
|
| 2172 | + label: '<?php echo addslashes($args['title']); ?>', |
|
| 2173 | + help: '<?php if (isset($args['desc'])) { |
|
| 2174 | + echo addslashes($args['desc']); |
|
| 2175 | 2175 | } ?>', |
| 2176 | 2176 | value: <?php echo $value; ?>, |
| 2177 | - <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
|
| 2178 | - echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 2177 | + <?php if ($type == 'TextControl' && $args['type'] != 'text') { |
|
| 2178 | + echo "type: '" . addslashes($args['type']) . "',"; |
|
| 2179 | 2179 | } ?> |
| 2180 | - <?php if ( ! empty( $args['placeholder'] ) ) { |
|
| 2181 | - echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',"; |
|
| 2180 | + <?php if (!empty($args['placeholder'])) { |
|
| 2181 | + echo "placeholder: '" . addslashes($args['placeholder']) . "',"; |
|
| 2182 | 2182 | } ?> |
| 2183 | 2183 | <?php echo $options; ?> |
| 2184 | 2184 | <?php echo $extra; ?> |
| 2185 | 2185 | <?php echo $custom_attributes; ?> |
| 2186 | - <?php echo $onchangecomplete;?> |
|
| 2186 | + <?php echo $onchangecomplete; ?> |
|
| 2187 | 2187 | onChange: function ( <?php echo $key; ?> ) { |
| 2188 | 2188 | <?php echo $onchange; ?> |
| 2189 | 2189 | } |
@@ -2201,16 +2201,16 @@ discard block |
||
| 2201 | 2201 | * |
| 2202 | 2202 | * @return string |
| 2203 | 2203 | */ |
| 2204 | - public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 2204 | + public function array_to_attributes($custom_attributes, $html = false) { |
|
| 2205 | 2205 | $attributes = ''; |
| 2206 | - if ( ! empty( $custom_attributes ) ) { |
|
| 2206 | + if (!empty($custom_attributes)) { |
|
| 2207 | 2207 | |
| 2208 | - if ( $html ) { |
|
| 2209 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 2208 | + if ($html) { |
|
| 2209 | + foreach ($custom_attributes as $key => $val) { |
|
| 2210 | 2210 | $attributes .= " $key='$val' "; |
| 2211 | 2211 | } |
| 2212 | 2212 | } else { |
| 2213 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 2213 | + foreach ($custom_attributes as $key => $val) { |
|
| 2214 | 2214 | $attributes .= "'$key': '$val',"; |
| 2215 | 2215 | } |
| 2216 | 2216 | } |
@@ -2226,86 +2226,86 @@ discard block |
||
| 2226 | 2226 | * |
| 2227 | 2227 | * @param $args |
| 2228 | 2228 | */ |
| 2229 | - public function block_element( $args ) { |
|
| 2229 | + public function block_element($args) { |
|
| 2230 | 2230 | |
| 2231 | 2231 | |
| 2232 | - if ( ! empty( $args ) ) { |
|
| 2233 | - foreach ( $args as $element => $new_args ) { |
|
| 2232 | + if (!empty($args)) { |
|
| 2233 | + foreach ($args as $element => $new_args) { |
|
| 2234 | 2234 | |
| 2235 | - if ( is_array( $new_args ) ) { // its an element |
|
| 2235 | + if (is_array($new_args)) { // its an element |
|
| 2236 | 2236 | |
| 2237 | 2237 | |
| 2238 | - if ( isset( $new_args['element'] ) ) { |
|
| 2238 | + if (isset($new_args['element'])) { |
|
| 2239 | 2239 | |
| 2240 | - if ( isset( $new_args['element_require'] ) ) { |
|
| 2241 | - echo str_replace( array( |
|
| 2240 | + if (isset($new_args['element_require'])) { |
|
| 2241 | + echo str_replace(array( |
|
| 2242 | 2242 | "'+", |
| 2243 | 2243 | "+'" |
| 2244 | - ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 2245 | - unset( $new_args['element_require'] ); |
|
| 2244 | + ), '', $this->block_props_replace($new_args['element_require'])) . " && "; |
|
| 2245 | + unset($new_args['element_require']); |
|
| 2246 | 2246 | } |
| 2247 | 2247 | |
| 2248 | 2248 | echo "\n el( '" . $new_args['element'] . "', {"; |
| 2249 | 2249 | |
| 2250 | 2250 | // get the attributes |
| 2251 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 2251 | + foreach ($new_args as $new_key => $new_value) { |
|
| 2252 | 2252 | |
| 2253 | 2253 | |
| 2254 | - if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 2254 | + if ($new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) { |
|
| 2255 | 2255 | // do nothing |
| 2256 | 2256 | } else { |
| 2257 | - echo $this->block_element( array( $new_key => $new_value ) ); |
|
| 2257 | + echo $this->block_element(array($new_key => $new_value)); |
|
| 2258 | 2258 | } |
| 2259 | 2259 | } |
| 2260 | 2260 | |
| 2261 | - echo "},";// end attributes |
|
| 2261 | + echo "},"; // end attributes |
|
| 2262 | 2262 | |
| 2263 | 2263 | // get the content |
| 2264 | 2264 | $first_item = 0; |
| 2265 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 2266 | - if ( $new_key === 'content' || is_array( $new_value ) ) { |
|
| 2265 | + foreach ($new_args as $new_key => $new_value) { |
|
| 2266 | + if ($new_key === 'content' || is_array($new_value)) { |
|
| 2267 | 2267 | |
| 2268 | - if ( $new_key === 'content' ) { |
|
| 2269 | - echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 2268 | + if ($new_key === 'content') { |
|
| 2269 | + echo "'" . $this->block_props_replace(wp_slash($new_value)) . "'"; |
|
| 2270 | 2270 | } |
| 2271 | 2271 | |
| 2272 | - if ( is_array( $new_value ) ) { |
|
| 2272 | + if (is_array($new_value)) { |
|
| 2273 | 2273 | |
| 2274 | - if ( isset( $new_value['element_require'] ) ) { |
|
| 2275 | - echo str_replace( array( |
|
| 2274 | + if (isset($new_value['element_require'])) { |
|
| 2275 | + echo str_replace(array( |
|
| 2276 | 2276 | "'+", |
| 2277 | 2277 | "+'" |
| 2278 | - ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 2279 | - unset( $new_value['element_require'] ); |
|
| 2278 | + ), '', $this->block_props_replace($new_value['element_require'])) . " && "; |
|
| 2279 | + unset($new_value['element_require']); |
|
| 2280 | 2280 | } |
| 2281 | 2281 | |
| 2282 | - if ( isset( $new_value['element_repeat'] ) ) { |
|
| 2282 | + if (isset($new_value['element_repeat'])) { |
|
| 2283 | 2283 | $x = 1; |
| 2284 | - while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 2285 | - $this->block_element( array( '' => $new_value ) ); |
|
| 2286 | - $x ++; |
|
| 2284 | + while ($x <= absint($new_value['element_repeat'])) { |
|
| 2285 | + $this->block_element(array('' => $new_value)); |
|
| 2286 | + $x++; |
|
| 2287 | 2287 | } |
| 2288 | 2288 | } else { |
| 2289 | - $this->block_element( array( '' => $new_value ) ); |
|
| 2289 | + $this->block_element(array('' => $new_value)); |
|
| 2290 | 2290 | } |
| 2291 | 2291 | } |
| 2292 | - $first_item ++; |
|
| 2292 | + $first_item++; |
|
| 2293 | 2293 | } |
| 2294 | 2294 | } |
| 2295 | 2295 | |
| 2296 | - echo ")";// end content |
|
| 2296 | + echo ")"; // end content |
|
| 2297 | 2297 | |
| 2298 | 2298 | echo ", \n"; |
| 2299 | 2299 | |
| 2300 | 2300 | } |
| 2301 | 2301 | } else { |
| 2302 | 2302 | |
| 2303 | - if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 2304 | - echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 2305 | - } elseif ( $element == 'style' ) { |
|
| 2306 | - echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 2303 | + if (substr($element, 0, 3) === "if_") { |
|
| 2304 | + echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ","; |
|
| 2305 | + } elseif ($element == 'style') { |
|
| 2306 | + echo $element . ": " . $this->block_props_replace($new_args) . ","; |
|
| 2307 | 2307 | } else { |
| 2308 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 2308 | + echo $element . ": '" . $this->block_props_replace($new_args) . "',"; |
|
| 2309 | 2309 | } |
| 2310 | 2310 | |
| 2311 | 2311 | } |
@@ -2320,12 +2320,12 @@ discard block |
||
| 2320 | 2320 | * |
| 2321 | 2321 | * @return mixed |
| 2322 | 2322 | */ |
| 2323 | - public function block_props_replace( $string, $no_wrap = false ) { |
|
| 2323 | + public function block_props_replace($string, $no_wrap = false) { |
|
| 2324 | 2324 | |
| 2325 | - if ( $no_wrap ) { |
|
| 2326 | - $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 2325 | + if ($no_wrap) { |
|
| 2326 | + $string = str_replace(array("[%", "%]"), array("props.attributes.", ""), $string); |
|
| 2327 | 2327 | } else { |
| 2328 | - $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 2328 | + $string = str_replace(array("[%", "%]"), array("'+props.attributes.", "+'"), $string); |
|
| 2329 | 2329 | } |
| 2330 | 2330 | |
| 2331 | 2331 | return $string; |
@@ -2337,55 +2337,55 @@ discard block |
||
| 2337 | 2337 | * @param array $args |
| 2338 | 2338 | * @param array $instance |
| 2339 | 2339 | */ |
| 2340 | - public function widget( $args, $instance ) { |
|
| 2340 | + public function widget($args, $instance) { |
|
| 2341 | 2341 | |
| 2342 | 2342 | // get the filtered values |
| 2343 | - $argument_values = $this->argument_values( $instance ); |
|
| 2344 | - $argument_values = $this->string_to_bool( $argument_values ); |
|
| 2345 | - $output = $this->output( $argument_values, $args ); |
|
| 2343 | + $argument_values = $this->argument_values($instance); |
|
| 2344 | + $argument_values = $this->string_to_bool($argument_values); |
|
| 2345 | + $output = $this->output($argument_values, $args); |
|
| 2346 | 2346 | |
| 2347 | 2347 | $no_wrap = false; |
| 2348 | - if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 2348 | + if (isset($argument_values['no_wrap']) && $argument_values['no_wrap']) { |
|
| 2349 | 2349 | $no_wrap = true; |
| 2350 | 2350 | } |
| 2351 | 2351 | |
| 2352 | 2352 | ob_start(); |
| 2353 | - if ( $output && ! $no_wrap ) { |
|
| 2353 | + if ($output && !$no_wrap) { |
|
| 2354 | 2354 | |
| 2355 | 2355 | $class_original = $this->options['widget_ops']['classname']; |
| 2356 | - $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); |
|
| 2356 | + $class = $this->options['widget_ops']['classname'] . " sdel-" . $this->get_instance_hash(); |
|
| 2357 | 2357 | |
| 2358 | 2358 | // Before widget |
| 2359 | 2359 | $before_widget = $args['before_widget']; |
| 2360 | - $before_widget = str_replace($class_original,$class,$before_widget); |
|
| 2361 | - $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 2362 | - $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 2360 | + $before_widget = str_replace($class_original, $class, $before_widget); |
|
| 2361 | + $before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this); |
|
| 2362 | + $before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this); |
|
| 2363 | 2363 | |
| 2364 | 2364 | // After widget |
| 2365 | 2365 | $after_widget = $args['after_widget']; |
| 2366 | - $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 2367 | - $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 2366 | + $after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this); |
|
| 2367 | + $after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this); |
|
| 2368 | 2368 | |
| 2369 | 2369 | echo $before_widget; |
| 2370 | 2370 | // elementor strips the widget wrapping div so we check for and add it back if needed |
| 2371 | - if ( $this->is_elementor_widget_output() ) { |
|
| 2372 | - echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $class ) . "'>" : ''; |
|
| 2371 | + if ($this->is_elementor_widget_output()) { |
|
| 2372 | + echo !empty($this->options['widget_ops']['classname']) ? "<span class='" . esc_attr($class) . "'>" : ''; |
|
| 2373 | 2373 | } |
| 2374 | - echo $this->output_title( $args, $instance ); |
|
| 2374 | + echo $this->output_title($args, $instance); |
|
| 2375 | 2375 | echo $output; |
| 2376 | - if ( $this->is_elementor_widget_output() ) { |
|
| 2377 | - echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : ''; |
|
| 2376 | + if ($this->is_elementor_widget_output()) { |
|
| 2377 | + echo !empty($this->options['widget_ops']['classname']) ? "</span>" : ''; |
|
| 2378 | 2378 | } |
| 2379 | 2379 | echo $after_widget; |
| 2380 | - } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 2381 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 2380 | + } elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty |
|
| 2381 | + $output = $this->preview_placeholder_text("{{" . $this->base_id . "}}"); |
|
| 2382 | 2382 | echo $output; |
| 2383 | - } elseif ( $output && $no_wrap ) { |
|
| 2383 | + } elseif ($output && $no_wrap) { |
|
| 2384 | 2384 | echo $output; |
| 2385 | 2385 | } |
| 2386 | 2386 | $output = ob_get_clean(); |
| 2387 | 2387 | |
| 2388 | - $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 2388 | + $output = apply_filters('wp_super_duper_widget_output', $output, $instance, $args, $this); |
|
| 2389 | 2389 | |
| 2390 | 2390 | echo $output; |
| 2391 | 2391 | } |
@@ -2398,7 +2398,7 @@ discard block |
||
| 2398 | 2398 | */ |
| 2399 | 2399 | public function is_elementor_widget_output() { |
| 2400 | 2400 | $result = false; |
| 2401 | - if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 2401 | + if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') { |
|
| 2402 | 2402 | $result = true; |
| 2403 | 2403 | } |
| 2404 | 2404 | |
@@ -2413,7 +2413,7 @@ discard block |
||
| 2413 | 2413 | */ |
| 2414 | 2414 | public function is_elementor_preview() { |
| 2415 | 2415 | $result = false; |
| 2416 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 2416 | + if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) { |
|
| 2417 | 2417 | $result = true; |
| 2418 | 2418 | } |
| 2419 | 2419 | |
@@ -2428,7 +2428,7 @@ discard block |
||
| 2428 | 2428 | */ |
| 2429 | 2429 | public function is_divi_preview() { |
| 2430 | 2430 | $result = false; |
| 2431 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 2431 | + if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) { |
|
| 2432 | 2432 | $result = true; |
| 2433 | 2433 | } |
| 2434 | 2434 | |
@@ -2443,7 +2443,7 @@ discard block |
||
| 2443 | 2443 | */ |
| 2444 | 2444 | public function is_beaver_preview() { |
| 2445 | 2445 | $result = false; |
| 2446 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 2446 | + if (isset($_REQUEST['fl_builder'])) { |
|
| 2447 | 2447 | $result = true; |
| 2448 | 2448 | } |
| 2449 | 2449 | |
@@ -2458,7 +2458,7 @@ discard block |
||
| 2458 | 2458 | */ |
| 2459 | 2459 | public function is_siteorigin_preview() { |
| 2460 | 2460 | $result = false; |
| 2461 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 2461 | + if (!empty($_REQUEST['siteorigin_panels_live_editor'])) { |
|
| 2462 | 2462 | $result = true; |
| 2463 | 2463 | } |
| 2464 | 2464 | |
@@ -2473,7 +2473,7 @@ discard block |
||
| 2473 | 2473 | */ |
| 2474 | 2474 | public function is_cornerstone_preview() { |
| 2475 | 2475 | $result = false; |
| 2476 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 2476 | + if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') { |
|
| 2477 | 2477 | $result = true; |
| 2478 | 2478 | } |
| 2479 | 2479 | |
@@ -2488,7 +2488,7 @@ discard block |
||
| 2488 | 2488 | */ |
| 2489 | 2489 | public function is_fusion_preview() { |
| 2490 | 2490 | $result = false; |
| 2491 | - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 2491 | + if (!empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce'])) { |
|
| 2492 | 2492 | $result = true; |
| 2493 | 2493 | } |
| 2494 | 2494 | |
@@ -2503,7 +2503,7 @@ discard block |
||
| 2503 | 2503 | */ |
| 2504 | 2504 | public function is_oxygen_preview() { |
| 2505 | 2505 | $result = false; |
| 2506 | - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 2506 | + if (!empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_"))) { |
|
| 2507 | 2507 | $result = true; |
| 2508 | 2508 | } |
| 2509 | 2509 | |
@@ -2518,21 +2518,21 @@ discard block |
||
| 2518 | 2518 | */ |
| 2519 | 2519 | public function is_preview() { |
| 2520 | 2520 | $preview = false; |
| 2521 | - if ( $this->is_divi_preview() ) { |
|
| 2521 | + if ($this->is_divi_preview()) { |
|
| 2522 | 2522 | $preview = true; |
| 2523 | - } elseif ( $this->is_elementor_preview() ) { |
|
| 2523 | + } elseif ($this->is_elementor_preview()) { |
|
| 2524 | 2524 | $preview = true; |
| 2525 | - } elseif ( $this->is_beaver_preview() ) { |
|
| 2525 | + } elseif ($this->is_beaver_preview()) { |
|
| 2526 | 2526 | $preview = true; |
| 2527 | - } elseif ( $this->is_siteorigin_preview() ) { |
|
| 2527 | + } elseif ($this->is_siteorigin_preview()) { |
|
| 2528 | 2528 | $preview = true; |
| 2529 | - } elseif ( $this->is_cornerstone_preview() ) { |
|
| 2529 | + } elseif ($this->is_cornerstone_preview()) { |
|
| 2530 | 2530 | $preview = true; |
| 2531 | - } elseif ( $this->is_fusion_preview() ) { |
|
| 2531 | + } elseif ($this->is_fusion_preview()) { |
|
| 2532 | 2532 | $preview = true; |
| 2533 | - } elseif ( $this->is_oxygen_preview() ) { |
|
| 2533 | + } elseif ($this->is_oxygen_preview()) { |
|
| 2534 | 2534 | $preview = true; |
| 2535 | - } elseif( $this->is_block_content_call() ) { |
|
| 2535 | + } elseif ($this->is_block_content_call()) { |
|
| 2536 | 2536 | $preview = true; |
| 2537 | 2537 | } |
| 2538 | 2538 | |
@@ -2547,11 +2547,11 @@ discard block |
||
| 2547 | 2547 | * |
| 2548 | 2548 | * @return string |
| 2549 | 2549 | */ |
| 2550 | - public function output_title( $args, $instance = array() ) { |
|
| 2550 | + public function output_title($args, $instance = array()) { |
|
| 2551 | 2551 | $output = ''; |
| 2552 | - if ( ! empty( $instance['title'] ) ) { |
|
| 2552 | + if (!empty($instance['title'])) { |
|
| 2553 | 2553 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
| 2554 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 2554 | + $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); |
|
| 2555 | 2555 | $output = $args['before_title'] . $title . $args['after_title']; |
| 2556 | 2556 | } |
| 2557 | 2557 | |
@@ -2563,7 +2563,7 @@ discard block |
||
| 2563 | 2563 | * |
| 2564 | 2564 | * @param array $instance The widget options. |
| 2565 | 2565 | */ |
| 2566 | - public function form( $instance ) { |
|
| 2566 | + public function form($instance) { |
|
| 2567 | 2567 | |
| 2568 | 2568 | // set widget instance |
| 2569 | 2569 | $this->instance = $instance; |
@@ -2571,20 +2571,20 @@ discard block |
||
| 2571 | 2571 | // set it as a SD widget |
| 2572 | 2572 | echo $this->widget_advanced_toggle(); |
| 2573 | 2573 | |
| 2574 | - echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 2574 | + echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>"; |
|
| 2575 | 2575 | $arguments_raw = $this->get_arguments(); |
| 2576 | 2576 | |
| 2577 | - if ( is_array( $arguments_raw ) ) { |
|
| 2577 | + if (is_array($arguments_raw)) { |
|
| 2578 | 2578 | |
| 2579 | - $arguments = $this->group_arguments( $arguments_raw ); |
|
| 2579 | + $arguments = $this->group_arguments($arguments_raw); |
|
| 2580 | 2580 | |
| 2581 | 2581 | // Do we have sections? |
| 2582 | 2582 | $has_sections = $arguments == $arguments_raw ? false : true; |
| 2583 | 2583 | |
| 2584 | 2584 | |
| 2585 | - if ( $has_sections ) { |
|
| 2585 | + if ($has_sections) { |
|
| 2586 | 2586 | $panel_count = 0; |
| 2587 | - foreach ( $arguments as $key => $args ) { |
|
| 2587 | + foreach ($arguments as $key => $args) { |
|
| 2588 | 2588 | |
| 2589 | 2589 | ?> |
| 2590 | 2590 | <script> |
@@ -2594,21 +2594,21 @@ discard block |
||
| 2594 | 2594 | |
| 2595 | 2595 | $hide = $panel_count ? ' style="display:none;" ' : ''; |
| 2596 | 2596 | $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
| 2597 | - 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>"; |
|
| 2598 | - echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 2597 | + 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>"; |
|
| 2598 | + echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes($key) . "' $hide>"; |
|
| 2599 | 2599 | |
| 2600 | - foreach ( $args as $k => $a ) { |
|
| 2601 | - $this->widget_inputs( $a, $instance ); |
|
| 2600 | + foreach ($args as $k => $a) { |
|
| 2601 | + $this->widget_inputs($a, $instance); |
|
| 2602 | 2602 | } |
| 2603 | 2603 | |
| 2604 | 2604 | echo "</div>"; |
| 2605 | 2605 | |
| 2606 | - $panel_count ++; |
|
| 2606 | + $panel_count++; |
|
| 2607 | 2607 | |
| 2608 | 2608 | } |
| 2609 | 2609 | } else { |
| 2610 | - foreach ( $arguments as $key => $args ) { |
|
| 2611 | - $this->widget_inputs( $args, $instance ); |
|
| 2610 | + foreach ($arguments as $key => $args) { |
|
| 2611 | + $this->widget_inputs($args, $instance); |
|
| 2612 | 2612 | } |
| 2613 | 2613 | } |
| 2614 | 2614 | |
@@ -2623,7 +2623,7 @@ discard block |
||
| 2623 | 2623 | public function widget_advanced_toggle() { |
| 2624 | 2624 | |
| 2625 | 2625 | $output = ''; |
| 2626 | - if ( $this->block_show_advanced() ) { |
|
| 2626 | + if ($this->block_show_advanced()) { |
|
| 2627 | 2627 | $val = 1; |
| 2628 | 2628 | } else { |
| 2629 | 2629 | $val = 0; |
@@ -2643,14 +2643,14 @@ discard block |
||
| 2643 | 2643 | * |
| 2644 | 2644 | * @return string $output |
| 2645 | 2645 | */ |
| 2646 | - public function convert_element_require( $input ) { |
|
| 2646 | + public function convert_element_require($input) { |
|
| 2647 | 2647 | |
| 2648 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 2648 | + $input = str_replace("'", '"', $input); // we only want double quotes |
|
| 2649 | 2649 | |
| 2650 | - $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 2650 | + $output = esc_attr(str_replace(array("[%", "%]"), array( |
|
| 2651 | 2651 | "jQuery(form).find('[data-argument=\"", |
| 2652 | 2652 | "\"]').find('input,select,textarea').val()" |
| 2653 | - ), $input ) ); |
|
| 2653 | + ), $input)); |
|
| 2654 | 2654 | |
| 2655 | 2655 | return $output; |
| 2656 | 2656 | } |
@@ -2661,54 +2661,54 @@ discard block |
||
| 2661 | 2661 | * @param $args |
| 2662 | 2662 | * @param $instance |
| 2663 | 2663 | */ |
| 2664 | - public function widget_inputs( $args, $instance ) { |
|
| 2664 | + public function widget_inputs($args, $instance) { |
|
| 2665 | 2665 | |
| 2666 | 2666 | $class = ""; |
| 2667 | 2667 | $element_require = ""; |
| 2668 | 2668 | $custom_attributes = ""; |
| 2669 | 2669 | |
| 2670 | 2670 | // get value |
| 2671 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 2672 | - $value = $instance[ $args['name'] ]; |
|
| 2673 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 2674 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 2671 | + if (isset($instance[$args['name']])) { |
|
| 2672 | + $value = $instance[$args['name']]; |
|
| 2673 | + } elseif (!isset($instance[$args['name']]) && !empty($args['default'])) { |
|
| 2674 | + $value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']); |
|
| 2675 | 2675 | } else { |
| 2676 | 2676 | $value = ''; |
| 2677 | 2677 | } |
| 2678 | 2678 | |
| 2679 | 2679 | // get placeholder |
| 2680 | - if ( ! empty( $args['placeholder'] ) ) { |
|
| 2681 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 2680 | + if (!empty($args['placeholder'])) { |
|
| 2681 | + $placeholder = "placeholder='" . esc_html($args['placeholder']) . "'"; |
|
| 2682 | 2682 | } else { |
| 2683 | 2683 | $placeholder = ''; |
| 2684 | 2684 | } |
| 2685 | 2685 | |
| 2686 | 2686 | // get if advanced |
| 2687 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 2687 | + if (isset($args['advanced']) && $args['advanced']) { |
|
| 2688 | 2688 | $class .= " sd-advanced-setting "; |
| 2689 | 2689 | } |
| 2690 | 2690 | |
| 2691 | 2691 | // element_require |
| 2692 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 2692 | + if (isset($args['element_require']) && $args['element_require']) { |
|
| 2693 | 2693 | $element_require = $args['element_require']; |
| 2694 | 2694 | } |
| 2695 | 2695 | |
| 2696 | 2696 | // custom_attributes |
| 2697 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 2698 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 2697 | + if (isset($args['custom_attributes']) && $args['custom_attributes']) { |
|
| 2698 | + $custom_attributes = $this->array_to_attributes($args['custom_attributes'], true); |
|
| 2699 | 2699 | } |
| 2700 | 2700 | |
| 2701 | 2701 | // before wrapper |
| 2702 | 2702 | ?> |
| 2703 | - <p class="sd-argument <?php echo esc_attr( $class ); ?>" |
|
| 2704 | - data-argument='<?php echo esc_attr( $args['name'] ); ?>' |
|
| 2705 | - data-element_require='<?php if ( $element_require ) { |
|
| 2706 | - echo $this->convert_element_require( $element_require ); |
|
| 2703 | + <p class="sd-argument <?php echo esc_attr($class); ?>" |
|
| 2704 | + data-argument='<?php echo esc_attr($args['name']); ?>' |
|
| 2705 | + data-element_require='<?php if ($element_require) { |
|
| 2706 | + echo $this->convert_element_require($element_require); |
|
| 2707 | 2707 | } ?>' |
| 2708 | 2708 | > |
| 2709 | 2709 | <?php |
| 2710 | 2710 | |
| 2711 | - switch ( $args['type'] ) { |
|
| 2711 | + switch ($args['type']) { |
|
| 2712 | 2712 | //array('text','password','number','email','tel','url','color') |
| 2713 | 2713 | case "text": |
| 2714 | 2714 | case "password": |
@@ -2719,46 +2719,46 @@ discard block |
||
| 2719 | 2719 | case "color": |
| 2720 | 2720 | ?> |
| 2721 | 2721 | <label |
| 2722 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 2722 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 2723 | 2723 | <input <?php echo $placeholder; ?> class="widefat" |
| 2724 | 2724 | <?php echo $custom_attributes; ?> |
| 2725 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2726 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" |
|
| 2727 | - type="<?php echo esc_attr( $args['type'] ); ?>" |
|
| 2728 | - value="<?php echo esc_attr( $value ); ?>"> |
|
| 2725 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2726 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" |
|
| 2727 | + type="<?php echo esc_attr($args['type']); ?>" |
|
| 2728 | + value="<?php echo esc_attr($value); ?>"> |
|
| 2729 | 2729 | <?php |
| 2730 | 2730 | |
| 2731 | 2731 | break; |
| 2732 | 2732 | case "select": |
| 2733 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 2734 | - if ( $multiple ) { |
|
| 2735 | - if ( empty( $value ) ) { |
|
| 2733 | + $multiple = isset($args['multiple']) && $args['multiple'] ? true : false; |
|
| 2734 | + if ($multiple) { |
|
| 2735 | + if (empty($value)) { |
|
| 2736 | 2736 | $value = array(); |
| 2737 | 2737 | } |
| 2738 | 2738 | } |
| 2739 | 2739 | ?> |
| 2740 | 2740 | <label |
| 2741 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 2741 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 2742 | 2742 | <select <?php echo $placeholder; ?> class="widefat" |
| 2743 | 2743 | <?php echo $custom_attributes; ?> |
| 2744 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2745 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); |
|
| 2746 | - if ( $multiple ) { |
|
| 2744 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2745 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); |
|
| 2746 | + if ($multiple) { |
|
| 2747 | 2747 | echo "[]"; |
| 2748 | 2748 | } ?>" |
| 2749 | - <?php if ( $multiple ) { |
|
| 2749 | + <?php if ($multiple) { |
|
| 2750 | 2750 | echo "multiple"; |
| 2751 | 2751 | } //@todo not implemented yet due to gutenberg not supporting it |
| 2752 | 2752 | ?> |
| 2753 | 2753 | > |
| 2754 | 2754 | <?php |
| 2755 | 2755 | |
| 2756 | - if ( ! empty( $args['options'] ) ) { |
|
| 2757 | - foreach ( $args['options'] as $val => $label ) { |
|
| 2758 | - if ( $multiple ) { |
|
| 2759 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 2756 | + if (!empty($args['options'])) { |
|
| 2757 | + foreach ($args['options'] as $val => $label) { |
|
| 2758 | + if ($multiple) { |
|
| 2759 | + $selected = in_array($val, $value) ? 'selected="selected"' : ''; |
|
| 2760 | 2760 | } else { |
| 2761 | - $selected = selected( $value, $val, false ); |
|
| 2761 | + $selected = selected($value, $val, false); |
|
| 2762 | 2762 | } |
| 2763 | 2763 | echo "<option value='$val' " . $selected . ">$label</option>"; |
| 2764 | 2764 | } |
@@ -2770,32 +2770,32 @@ discard block |
||
| 2770 | 2770 | case "checkbox": |
| 2771 | 2771 | ?> |
| 2772 | 2772 | <input <?php echo $placeholder; ?> |
| 2773 | - <?php checked( 1, $value, true ) ?> |
|
| 2773 | + <?php checked(1, $value, true) ?> |
|
| 2774 | 2774 | <?php echo $custom_attributes; ?> |
| 2775 | - class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2776 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox" |
|
| 2775 | + class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2776 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox" |
|
| 2777 | 2777 | value="1"> |
| 2778 | 2778 | <label |
| 2779 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 2779 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 2780 | 2780 | <?php |
| 2781 | 2781 | break; |
| 2782 | 2782 | case "textarea": |
| 2783 | 2783 | ?> |
| 2784 | 2784 | <label |
| 2785 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 2785 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 2786 | 2786 | <textarea <?php echo $placeholder; ?> class="widefat" |
| 2787 | 2787 | <?php echo $custom_attributes; ?> |
| 2788 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2789 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" |
|
| 2790 | - ><?php echo esc_attr( $value ); ?></textarea> |
|
| 2788 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2789 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" |
|
| 2790 | + ><?php echo esc_attr($value); ?></textarea> |
|
| 2791 | 2791 | <?php |
| 2792 | 2792 | |
| 2793 | 2793 | break; |
| 2794 | 2794 | case "hidden": |
| 2795 | 2795 | ?> |
| 2796 | - <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2797 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" |
|
| 2798 | - value="<?php echo esc_attr( $value ); ?>"> |
|
| 2796 | + <input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2797 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden" |
|
| 2798 | + value="<?php echo esc_attr($value); ?>"> |
|
| 2799 | 2799 | <?php |
| 2800 | 2800 | break; |
| 2801 | 2801 | default: |
@@ -2817,14 +2817,14 @@ discard block |
||
| 2817 | 2817 | * @return string |
| 2818 | 2818 | * @todo, need to make its own tooltip script |
| 2819 | 2819 | */ |
| 2820 | - public function widget_field_desc( $args ) { |
|
| 2820 | + public function widget_field_desc($args) { |
|
| 2821 | 2821 | |
| 2822 | 2822 | $description = ''; |
| 2823 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 2824 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 2825 | - $description = $this->desc_tip( $args['desc'] ); |
|
| 2823 | + if (isset($args['desc']) && $args['desc']) { |
|
| 2824 | + if (isset($args['desc_tip']) && $args['desc_tip']) { |
|
| 2825 | + $description = $this->desc_tip($args['desc']); |
|
| 2826 | 2826 | } else { |
| 2827 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 2827 | + $description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>'; |
|
| 2828 | 2828 | } |
| 2829 | 2829 | } |
| 2830 | 2830 | |
@@ -2839,11 +2839,11 @@ discard block |
||
| 2839 | 2839 | * |
| 2840 | 2840 | * @return string |
| 2841 | 2841 | */ |
| 2842 | - function desc_tip( $tip, $allow_html = false ) { |
|
| 2843 | - if ( $allow_html ) { |
|
| 2844 | - $tip = $this->sanitize_tooltip( $tip ); |
|
| 2842 | + function desc_tip($tip, $allow_html = false) { |
|
| 2843 | + if ($allow_html) { |
|
| 2844 | + $tip = $this->sanitize_tooltip($tip); |
|
| 2845 | 2845 | } else { |
| 2846 | - $tip = esc_attr( $tip ); |
|
| 2846 | + $tip = esc_attr($tip); |
|
| 2847 | 2847 | } |
| 2848 | 2848 | |
| 2849 | 2849 | return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -2856,8 +2856,8 @@ discard block |
||
| 2856 | 2856 | * |
| 2857 | 2857 | * @return string |
| 2858 | 2858 | */ |
| 2859 | - public function sanitize_tooltip( $var ) { |
|
| 2860 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 2859 | + public function sanitize_tooltip($var) { |
|
| 2860 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
| 2861 | 2861 | 'br' => array(), |
| 2862 | 2862 | 'em' => array(), |
| 2863 | 2863 | 'strong' => array(), |
@@ -2867,7 +2867,7 @@ discard block |
||
| 2867 | 2867 | 'li' => array(), |
| 2868 | 2868 | 'ol' => array(), |
| 2869 | 2869 | 'p' => array(), |
| 2870 | - ) ) ); |
|
| 2870 | + ))); |
|
| 2871 | 2871 | } |
| 2872 | 2872 | |
| 2873 | 2873 | /** |
@@ -2879,23 +2879,23 @@ discard block |
||
| 2879 | 2879 | * @return array |
| 2880 | 2880 | * @todo we should add some sanitation here. |
| 2881 | 2881 | */ |
| 2882 | - public function update( $new_instance, $old_instance ) { |
|
| 2882 | + public function update($new_instance, $old_instance) { |
|
| 2883 | 2883 | |
| 2884 | 2884 | //save the widget |
| 2885 | - $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 2885 | + $instance = array_merge((array) $old_instance, (array) $new_instance); |
|
| 2886 | 2886 | |
| 2887 | 2887 | // set widget instance |
| 2888 | 2888 | $this->instance = $instance; |
| 2889 | 2889 | |
| 2890 | - if ( empty( $this->arguments ) ) { |
|
| 2890 | + if (empty($this->arguments)) { |
|
| 2891 | 2891 | $this->get_arguments(); |
| 2892 | 2892 | } |
| 2893 | 2893 | |
| 2894 | 2894 | // check for checkboxes |
| 2895 | - if ( ! empty( $this->arguments ) ) { |
|
| 2896 | - foreach ( $this->arguments as $argument ) { |
|
| 2897 | - if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 2898 | - $instance[ $argument['name'] ] = '0'; |
|
| 2895 | + if (!empty($this->arguments)) { |
|
| 2896 | + foreach ($this->arguments as $argument) { |
|
| 2897 | + if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) { |
|
| 2898 | + $instance[$argument['name']] = '0'; |
|
| 2899 | 2899 | } |
| 2900 | 2900 | } |
| 2901 | 2901 | } |
@@ -2913,7 +2913,7 @@ discard block |
||
| 2913 | 2913 | */ |
| 2914 | 2914 | public function is_block_content_call() { |
| 2915 | 2915 | $result = false; |
| 2916 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 2916 | + if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') { |
|
| 2917 | 2917 | $result = true; |
| 2918 | 2918 | } |
| 2919 | 2919 | |
@@ -2926,9 +2926,9 @@ discard block |
||
| 2926 | 2926 | * @since 1.0.20 |
| 2927 | 2927 | * @return string |
| 2928 | 2928 | */ |
| 2929 | - public function get_instance_hash(){ |
|
| 2930 | - $instance_string = $this->base_id.serialize($this->instance); |
|
| 2931 | - return hash('crc32b',$instance_string); |
|
| 2929 | + public function get_instance_hash() { |
|
| 2930 | + $instance_string = $this->base_id . serialize($this->instance); |
|
| 2931 | + return hash('crc32b', $instance_string); |
|
| 2932 | 2932 | } |
| 2933 | 2933 | |
| 2934 | 2934 | /** |
@@ -2939,14 +2939,14 @@ discard block |
||
| 2939 | 2939 | * @since 1.0.20 |
| 2940 | 2940 | * @return string |
| 2941 | 2941 | */ |
| 2942 | - public function get_instance_style($rules = array()){ |
|
| 2942 | + public function get_instance_style($rules = array()) { |
|
| 2943 | 2943 | $css = ''; |
| 2944 | 2944 | |
| 2945 | - if(!empty($rules)){ |
|
| 2945 | + if (!empty($rules)) { |
|
| 2946 | 2946 | $rules = array_unique($rules); |
| 2947 | 2947 | $instance_hash = $this->get_instance_hash(); |
| 2948 | 2948 | $css .= "<style>"; |
| 2949 | - foreach($rules as $rule){ |
|
| 2949 | + foreach ($rules as $rule) { |
|
| 2950 | 2950 | $css .= ".sdel-$instance_hash $rule"; |
| 2951 | 2951 | } |
| 2952 | 2952 | $css .= "</style>"; |
@@ -7,22 +7,22 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Totals rows. |
| 13 | -$totals = getpaid_invoice_totals_rows( $invoice ); |
|
| 13 | +$totals = getpaid_invoice_totals_rows($invoice); |
|
| 14 | 14 | |
| 15 | -do_action( 'getpaid_before_email_line_totals', $invoice, $totals ); |
|
| 15 | +do_action('getpaid_before_email_line_totals', $invoice, $totals); |
|
| 16 | 16 | |
| 17 | 17 | ?> |
| 18 | 18 | |
| 19 | 19 | |
| 20 | -<?php if ( has_action( 'wpinv_email_footer_buttons' ) ) : ?> |
|
| 20 | +<?php if (has_action('wpinv_email_footer_buttons')) : ?> |
|
| 21 | 21 | |
| 22 | 22 | <tr class="wpinv_cart_footer_row"> |
| 23 | 23 | |
| 24 | - <td colspan="<?php echo ( (int) $column_count ); ?>"> |
|
| 25 | - <?php do_action( 'wpinv_email_footer_buttons' ); ?> |
|
| 24 | + <td colspan="<?php echo ((int) $column_count); ?>"> |
|
| 25 | + <?php do_action('wpinv_email_footer_buttons'); ?> |
|
| 26 | 26 | </td> |
| 27 | 27 | |
| 28 | 28 | </tr> |
@@ -30,40 +30,40 @@ discard block |
||
| 30 | 30 | <?php endif; ?> |
| 31 | 31 | |
| 32 | 32 | |
| 33 | -<?php foreach ( $totals as $key => $label ) : ?> |
|
| 33 | +<?php foreach ($totals as $key => $label) : ?> |
|
| 34 | 34 | |
| 35 | - <tr class="wpinv_cart_footer_row wpinv_cart_<?php echo sanitize_html_class( $key ); ?>_row"> |
|
| 35 | + <tr class="wpinv_cart_footer_row wpinv_cart_<?php echo sanitize_html_class($key); ?>_row"> |
|
| 36 | 36 | |
| 37 | - <td colspan="<?php echo ( $column_count - 1 ); ?>" class="wpinv_cart_<?php echo sanitize_html_class( $key ); ?>_label text-right"> |
|
| 38 | - <strong><?php echo sanitize_text_field( $label ); ?>:</strong> |
|
| 37 | + <td colspan="<?php echo ($column_count - 1); ?>" class="wpinv_cart_<?php echo sanitize_html_class($key); ?>_label text-right"> |
|
| 38 | + <strong><?php echo sanitize_text_field($label); ?>:</strong> |
|
| 39 | 39 | </td> |
| 40 | 40 | |
| 41 | - <td class="wpinv_cart_<?php echo sanitize_html_class( $key ); ?> text-right"> |
|
| 41 | + <td class="wpinv_cart_<?php echo sanitize_html_class($key); ?> text-right"> |
|
| 42 | 42 | |
| 43 | 43 | <?php |
| 44 | 44 | |
| 45 | 45 | // Total tax. |
| 46 | - if ( 'tax' == $key ) { |
|
| 47 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ); |
|
| 46 | + if ('tax' == $key) { |
|
| 47 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // Total discount. |
| 51 | - if ( 'discount' == $key ) { |
|
| 52 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ); |
|
| 51 | + if ('discount' == $key) { |
|
| 52 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Sub total. |
| 56 | - if ( 'subtotal' == $key ) { |
|
| 57 | - echo wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ); |
|
| 56 | + if ('subtotal' == $key) { |
|
| 57 | + echo wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Total. |
| 61 | - if ( 'total' == $key ) { |
|
| 62 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); |
|
| 61 | + if ('total' == $key) { |
|
| 62 | + echo wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Fires when printing a cart total in an email. |
| 66 | - do_action( "getpaid_email_cart_totals_$key", $invoice ); |
|
| 66 | + do_action("getpaid_email_cart_totals_$key", $invoice); |
|
| 67 | 67 | |
| 68 | 68 | ?> |
| 69 | 69 | |
@@ -75,4 +75,4 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | <?php |
| 77 | 77 | |
| 78 | - do_action( 'getpaid_after_email_line_totals', $invoice, $totals ); |
|
| 78 | + do_action('getpaid_after_email_line_totals', $invoice, $totals); |
|
@@ -7,63 +7,63 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
| 14 | -<?php do_action( 'getpaid_before_email_line_item', $invoice, $item ); ?> |
|
| 14 | +<?php do_action('getpaid_before_email_line_item', $invoice, $item); ?> |
|
| 15 | 15 | |
| 16 | -<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class( $item->get_type() ); ?>"> |
|
| 16 | +<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class($item->get_type()); ?>"> |
|
| 17 | 17 | |
| 18 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
| 18 | + <?php foreach (array_keys($columns) as $column): ?> |
|
| 19 | 19 | |
| 20 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>"> |
|
| 20 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>"> |
|
| 21 | 21 | |
| 22 | 22 | <?php |
| 23 | 23 | |
| 24 | 24 | // Fires before printing a line item column. |
| 25 | - do_action( "getpaid_email_line_item_before_$column", $item, $invoice ); |
|
| 25 | + do_action("getpaid_email_line_item_before_$column", $item, $invoice); |
|
| 26 | 26 | |
| 27 | 27 | // Item name. |
| 28 | - if ( 'name' == $column ) { |
|
| 28 | + if ('name' == $column) { |
|
| 29 | 29 | |
| 30 | 30 | // Display the name. |
| 31 | - echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
| 31 | + echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
| 32 | 32 | |
| 33 | 33 | // And an optional description. |
| 34 | 34 | $description = $item->get_description(); |
| 35 | 35 | |
| 36 | - if ( ! empty( $description ) ) { |
|
| 37 | - $description = wp_kses_post( $description ); |
|
| 36 | + if (!empty($description)) { |
|
| 37 | + $description = wp_kses_post($description); |
|
| 38 | 38 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Item price. |
| 44 | - if ( 'price' == $column ) { |
|
| 44 | + if ('price' == $column) { |
|
| 45 | 45 | |
| 46 | 46 | // Display the item price (or recurring price if this is a renewal invoice) |
| 47 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
| 48 | - echo wpinv_price( wpinv_format_amount( $item->get_price() ), $invoice->get_currency() ); |
|
| 47 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
| 48 | + echo wpinv_price(wpinv_format_amount($item->get_price()), $invoice->get_currency()); |
|
| 49 | 49 | } else { |
| 50 | - echo wpinv_price( wpinv_format_amount( $item->get_initial_price() ), $invoice->get_currency() ); |
|
| 50 | + echo wpinv_price(wpinv_format_amount($item->get_initial_price()), $invoice->get_currency()); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Item quantity. |
| 56 | - if ( 'quantity' == $column ) { |
|
| 56 | + if ('quantity' == $column) { |
|
| 57 | 57 | echo (int) $item->get_qantity(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Item sub total. |
| 61 | - if ( 'subtotal' == $column ) { |
|
| 62 | - echo wpinv_price( wpinv_format_amount( $item->get_sub_total() ), $invoice->get_currency() ); |
|
| 61 | + if ('subtotal' == $column) { |
|
| 62 | + echo wpinv_price(wpinv_format_amount($item->get_sub_total()), $invoice->get_currency()); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Fires when printing a line item column. |
| 66 | - do_action( "getpaid_email_line_item_$column", $item, $invoice ); |
|
| 66 | + do_action("getpaid_email_line_item_$column", $item, $invoice); |
|
| 67 | 67 | |
| 68 | 68 | ?> |
| 69 | 69 | |
@@ -73,4 +73,4 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | </tr> |
| 75 | 75 | |
| 76 | -<?php do_action( 'getpaid_after_email_line_item', $invoice, $item ); ?> |
|
| 76 | +<?php do_action('getpaid_after_email_line_item', $invoice, $item); ?> |
|
@@ -2,12 +2,12 @@ discard block |
||
| 2 | 2 | global $wpi_invoice; |
| 3 | 3 | |
| 4 | 4 | // Backwards compatibility. |
| 5 | -if ( empty( $invoice ) ) { |
|
| 5 | +if (empty($invoice)) { |
|
| 6 | 6 | $invoice = $wpi_invoice; |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $success_page_uri = wpinv_get_success_page_uri(); |
| 10 | -if ( !empty( $wpi_invoice ) ) { |
|
| 10 | +if (!empty($wpi_invoice)) { |
|
| 11 | 11 | $success_page_uri = $invoice->get_receipt_url(); |
| 12 | 12 | } |
| 13 | 13 | ?> |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | <?php |
| 18 | 18 | echo |
| 19 | 19 | wp_sprintf( |
| 20 | - __( 'Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing' ), |
|
| 20 | + __('Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing'), |
|
| 21 | 21 | $success_page_uri |
| 22 | 22 | ); |
| 23 | 23 | ?> |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | <script type="text/javascript"> |
| 28 | 28 | setTimeout( |
| 29 | 29 | function(){ |
| 30 | - window.location = '<?php echo esc_url( $success_page_uri ); ?>'; |
|
| 30 | + window.location = '<?php echo esc_url($success_page_uri); ?>'; |
|
| 31 | 31 | }, |
| 32 | 32 | 10000 |
| 33 | 33 | ); |