@@ -3,27 +3,27 @@ discard block |
||
3 | 3 | * Admin View: Page - Addons |
4 | 4 | * |
5 | 5 | */ |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | add_ThickBox(); |
10 | 10 | ?> |
11 | 11 | <div class="wrap wpi_addons_wrap"> |
12 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
12 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
13 | 13 | |
14 | - <?php if ( $tabs ) { ?> |
|
14 | + <?php if ($tabs) { ?> |
|
15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
16 | 16 | <?php |
17 | - foreach ( $tabs as $name => $label ) { |
|
18 | - echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
17 | + foreach ($tabs as $name => $label) { |
|
18 | + echo '<a href="' . esc_url(admin_url('admin.php?page=wpi-addons&tab=' . $name)) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . esc_html($label) . '</a>'; |
|
19 | 19 | } |
20 | - do_action( 'wpi_addons_tabs' ); |
|
20 | + do_action('wpi_addons_tabs'); |
|
21 | 21 | ?> |
22 | 22 | </nav> |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | |
26 | - if ( $current_tab == 'membership' ) { |
|
26 | + if ($current_tab == 'membership') { |
|
27 | 27 | |
28 | 28 | ?> |
29 | 29 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | <!-- |
33 | 33 | <h2>With our WPInvoicing Membership you get access to all our products!</h2> |
34 | 34 | <p><a class="button button-primary" href="https://wpgetpaid.com/downloads/membership/">View Memberships</a></p>--> |
35 | - <?php if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { ?> |
|
36 | - <h2><?php esc_html_e( 'Have a membership key?', 'invoicing' ); ?></h2> |
|
35 | + <?php if (defined('WP_EASY_UPDATES_ACTIVE')) { ?> |
|
36 | + <h2><?php esc_html_e('Have a membership key?', 'invoicing'); ?></h2> |
|
37 | 37 | <p> |
38 | 38 | <?php |
39 | - $wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' ); |
|
40 | - echo $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ); |
|
39 | + $wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1'); |
|
40 | + echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108, 12351)); |
|
41 | 41 | ?> |
42 | 42 | </p> |
43 | 43 | <?php } ?> |
44 | 44 | |
45 | 45 | <div class="membership-cta-contet"> |
46 | 46 | <div class="main-cta"> |
47 | - <h2><?php esc_html_e( 'Membership benefits Include:', 'invoicing' ); ?></h2> |
|
47 | + <h2><?php esc_html_e('Membership benefits Include:', 'invoicing'); ?></h2> |
|
48 | 48 | <div class="feature-list"> |
49 | 49 | <ul> |
50 | 50 | <?php |
51 | 51 | $addon_obj = new WPInv_Admin_Addons(); |
52 | - if ( $addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | - foreach ( $addons as $addon ) { |
|
54 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
52 | + if ($addons = $addon_obj->get_section_data('addons')) { |
|
53 | + foreach ($addons as $addon) { |
|
54 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | ?> |
58 | 58 | </ul> |
59 | 59 | |
60 | 60 | <div class="feature-cta"> |
61 | - <h3><?php esc_html_e( 'Membership Starts from', 'invoicing' ); ?></h3> |
|
61 | + <h3><?php esc_html_e('Membership Starts from', 'invoicing'); ?></h3> |
|
62 | 62 | <h4>$99</h4> |
63 | - <a href="https://wpgetpaid.com/downloads/membership/" target="_blank"><?php esc_attr_e( 'Buy Membership', 'invoicing' ); ?></a> |
|
63 | + <a href="https://wpgetpaid.com/downloads/membership/" target="_blank"><?php esc_attr_e('Buy Membership', 'invoicing'); ?></a> |
|
64 | 64 | </div> |
65 | - <h3><?php esc_html_e( 'Included Gateways:', 'invoicing' ); ?></h3> |
|
65 | + <h3><?php esc_html_e('Included Gateways:', 'invoicing'); ?></h3> |
|
66 | 66 | <ul> |
67 | 67 | <?php |
68 | - if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | - foreach ( $addons as $addon ) { |
|
70 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
68 | + if ($addons = $addon_obj->get_section_data('gateways')) { |
|
69 | + foreach ($addons as $addon) { |
|
70 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | ?> |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | <div class="testimonial-content"> |
82 | 82 | <div class="t-image"> |
83 | 83 | <?php |
84 | - echo '<img src="' . esc_url( plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) ) . '" > '; |
|
84 | + echo '<img src="' . esc_url(plugins_url('images/t-image2.png', dirname(__FILE__))) . '" > '; |
|
85 | 85 | ?> |
86 | 86 | </div> |
87 | 87 | <div class="t-content"> |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | <div class="testimonial-content"> |
102 | 102 | <div class="t-image"> |
103 | 103 | <?php |
104 | - echo '<img src="' . esc_url( plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) ) . '" > '; |
|
104 | + echo '<img src="' . esc_url(plugins_url('images/t-image1.png', dirname(__FILE__))) . '" > '; |
|
105 | 105 | ?> |
106 | 106 | </div> |
107 | 107 | <div class="t-content"> |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | </div> |
118 | 118 | </div> |
119 | 119 | <div class="member-footer"> |
120 | - <a class="footer-btn" href="https://wpgetpaid.com/downloads/membership/" target="_blank"><?php esc_html_e( 'Buy Membership', 'invoicing' ); ?></a> |
|
121 | - <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php esc_html_e( 'Create Invoice', 'invoicing' ); ?></a> |
|
120 | + <a class="footer-btn" href="https://wpgetpaid.com/downloads/membership/" target="_blank"><?php esc_html_e('Buy Membership', 'invoicing'); ?></a> |
|
121 | + <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php esc_html_e('Create Invoice', 'invoicing'); ?></a> |
|
122 | 122 | </div> |
123 | 123 | </div> |
124 | 124 | |
@@ -129,63 +129,63 @@ discard block |
||
129 | 129 | } else { |
130 | 130 | $installed_plugins = get_plugins(); |
131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
132 | - if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
132 | + if ($addons = $addon_obj->get_section_data($current_tab)) : |
|
133 | 133 | //print_r($addons); |
134 | 134 | ?> |
135 | 135 | <ul class="wpi-products"> |
136 | 136 | <?php |
137 | - foreach ( $addons as $addon ) : |
|
138 | - if ( 965 == $addon->info->id ) { |
|
139 | -continue;}// don't show quote add on |
|
137 | + foreach ($addons as $addon) : |
|
138 | + if (965 == $addon->info->id) { |
|
139 | +continue; }// don't show quote add on |
|
140 | 140 | ?> |
141 | 141 | <li class="wpi-product"> |
142 | 142 | <div class="wpi-product-title"> |
143 | 143 | <h3> |
144 | 144 | <?php |
145 | - if ( ! empty( $addon->info->excerpt ) ) { |
|
146 | - wpi_help_tip( $addon->info->excerpt, false, false, true ); |
|
145 | + if (!empty($addon->info->excerpt)) { |
|
146 | + wpi_help_tip($addon->info->excerpt, false, false, true); |
|
147 | 147 | } |
148 | - echo esc_html( $addon->info->title ); |
|
148 | + echo esc_html($addon->info->title); |
|
149 | 149 | ?> |
150 | 150 | </h3> |
151 | 151 | </div> |
152 | 152 | |
153 | 153 | <span class="wpi-product-image"> |
154 | - <?php if ( ! empty( $addon->info->thumbnail ) ) : ?> |
|
155 | - <img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/> |
|
154 | + <?php if (!empty($addon->info->thumbnail)) : ?> |
|
155 | + <img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/> |
|
156 | 156 | <?php |
157 | 157 | endif; |
158 | 158 | |
159 | - if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
159 | + if ('stripe-payment-gateway' == $addon->info->slug) { |
|
160 | 160 | $addon->info->slug = 'getpaid-stripe-payments'; |
161 | 161 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
162 | 162 | } |
163 | - elseif( 'wallet' == $addon->info->slug ){ |
|
163 | + elseif ('wallet' == $addon->info->slug) { |
|
164 | 164 | $addon->info->slug = 'getpaid-wallet'; |
165 | 165 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-wallet/'; |
166 | 166 | } |
167 | - elseif( 'item-inventory' == $addon->info->slug ){ |
|
167 | + elseif ('item-inventory' == $addon->info->slug) { |
|
168 | 168 | $addon->info->slug = 'getpaid-item-inventory'; |
169 | 169 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-item-inventory/'; |
170 | 170 | } |
171 | 171 | |
172 | - if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) { |
|
173 | - echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
174 | - echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
172 | + if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === 'https://wordpress.org') { |
|
173 | + echo '<a href="' . esc_url(admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug)) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
174 | + echo '<span class="wpi-product-info">' . esc_html__('More info', 'invoicing') . '</span>'; |
|
175 | 175 | echo '</a>'; |
176 | - } elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) { |
|
177 | - if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
178 | - $url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' ); |
|
176 | + } elseif (isset($addon->info->link) && (substr($addon->info->link, 0, 23) === 'https://wpinvoicing.com' || substr($addon->info->link, 0, 21) === 'https://wpgetpaid.com')) { |
|
177 | + if (defined('WP_EASY_UPDATES_ACTIVE')) { |
|
178 | + $url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true'); |
|
179 | 179 | } else { |
180 | 180 | // if installed show activation link |
181 | - if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
181 | + if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) { |
|
182 | 182 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
183 | 183 | } else { |
184 | 184 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
185 | 185 | } |
186 | 186 | } |
187 | - echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
188 | - echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
187 | + echo '<a href="' . esc_url($url) . '" class="thickbox">'; |
|
188 | + echo '<span class="wpi-product-info">' . esc_html__('More info', 'invoicing') . '</span>'; |
|
189 | 189 | echo '</a>'; |
190 | 190 | } |
191 | 191 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | <span class="wpi-product-button"> |
198 | 198 | <?php |
199 | - $addon_obj->output_button( $addon ); |
|
199 | + $addon_obj->output_button($addon); |
|
200 | 200 | ?> |
201 | 201 | </span> |
202 | 202 | |
@@ -210,21 +210,21 @@ discard block |
||
210 | 210 | |
211 | 211 | <div class="clearfix" ></div> |
212 | 212 | |
213 | - <?php if ( $current_tab == 'addons' ) { ?> |
|
214 | - <p><?php printf( esc_attr__( 'All of our Addons can be found on wpGetPaid.com here: %sInvoicing Addons%s', 'invoicing' ), '<a href="https://wpgetpaid.com/downloads/category/addons/">','</a>' ); ?></p> |
|
215 | - <?php } if ( $current_tab == 'gateways' ) { ?> |
|
216 | - <p><?php printf( esc_attr__( 'All of our Payment Gateways can be found on wpGetPaid.com here: %sGetPaid Payment Gateways %s', 'invoicing' ), '<a href="https://wpgetpaid.com/downloads/category/gateways/">','</a>' ); ?></p> |
|
213 | + <?php if ($current_tab == 'addons') { ?> |
|
214 | + <p><?php printf(esc_attr__('All of our Addons can be found on wpGetPaid.com here: %sInvoicing Addons%s', 'invoicing'), '<a href="https://wpgetpaid.com/downloads/category/addons/">', '</a>'); ?></p> |
|
215 | + <?php } if ($current_tab == 'gateways') { ?> |
|
216 | + <p><?php printf(esc_attr__('All of our Payment Gateways can be found on wpGetPaid.com here: %sGetPaid Payment Gateways %s', 'invoicing'), '<a href="https://wpgetpaid.com/downloads/category/gateways/">', '</a>'); ?></p> |
|
217 | 217 | <?php } ?> |
218 | 218 | |
219 | - <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post( sprintf( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing' ), wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php' ), 'activate-plugin_wp-easy-updates/external-updates.php' ) ) ); ?></span></div> |
|
220 | - <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post( sprintf( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing' ), admin_url( 'plugin-install.php?tab=upload&wpeu-install=true' ) ) ); ?></span></div> |
|
219 | + <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post(sprintf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing'), wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php'))); ?></span></div> |
|
220 | + <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post(sprintf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing'), admin_url('plugin-install.php?tab=upload&wpeu-install=true'))); ?></span></div> |
|
221 | 221 | <div id="wpeu-licence-popup" style="display:none;"> |
222 | 222 | <span class="wpi-notification noti-white"> |
223 | - <h3 class="wpeu-licence-title"><?php esc_html_e( 'Licence key', 'invoicing' ); ?></h3> |
|
224 | - <input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e( 'Enter your licence key', 'invoicing' ); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e( 'Install', 'invoicing' ); ?></button> |
|
223 | + <h3 class="wpeu-licence-title"><?php esc_html_e('Licence key', 'invoicing'); ?></h3> |
|
224 | + <input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e('Enter your licence key', 'invoicing'); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e('Install', 'invoicing'); ?></button> |
|
225 | 225 | <br> |
226 | 226 | <?php |
227 | - printf( esc_html__( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpgetpaid.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpgetpaid.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
227 | + printf(esc_html__('%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing'), '<a href="https://wpgetpaid.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpgetpaid.com/downloads/category/addons/" target="_blank">', '</a>'); |
|
228 | 228 | ?> |
229 | 229 | </span> |
230 | 230 | </div> |
@@ -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 input( $args = array() ) { |
|
21 | + public static function input($args = array()) { |
|
22 | 22 | global $aui_bs5; |
23 | 23 | |
24 | 24 | $defaults = array( |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | /** |
70 | 70 | * Parse incoming $args into an array and merge it with $defaults |
71 | 71 | */ |
72 | - $args = wp_parse_args( $args, $defaults ); |
|
72 | + $args = wp_parse_args($args, $defaults); |
|
73 | 73 | $output = ''; |
74 | - if ( ! empty( $args['type'] ) ) { |
|
74 | + if (!empty($args['type'])) { |
|
75 | 75 | // hidden label option needs to be empty |
76 | 76 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
77 | 77 | |
78 | - $type = sanitize_html_class( $args['type'] ); |
|
78 | + $type = sanitize_html_class($args['type']); |
|
79 | 79 | |
80 | 80 | $help_text = ''; |
81 | 81 | $label = ''; |
@@ -89,17 +89,17 @@ discard block |
||
89 | 89 | ); |
90 | 90 | |
91 | 91 | // floating labels need label after |
92 | - if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) { |
|
92 | + if ($args['label_type'] == 'floating' && $type != 'checkbox') { |
|
93 | 93 | $label_after = true; |
94 | 94 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
95 | 95 | } |
96 | 96 | |
97 | 97 | // size |
98 | 98 | $size = ''; |
99 | - if ( $args['size'] == 'lg' || $args['size'] == 'large' ) { |
|
99 | + if ($args['size'] == 'lg' || $args['size'] == 'large') { |
|
100 | 100 | $size = 'lg'; |
101 | 101 | $args['class'] .= ' form-control-lg'; |
102 | - }elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) { |
|
102 | + }elseif ($args['size'] == 'sm' || $args['size'] == 'small') { |
|
103 | 103 | $size = 'sm'; |
104 | 104 | $args['class'] .= ' form-control-sm'; |
105 | 105 | } |
@@ -108,28 +108,28 @@ discard block |
||
108 | 108 | $clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');'; |
109 | 109 | |
110 | 110 | // Some special sauce for files |
111 | - if ( $type == 'file' ) { |
|
111 | + if ($type == 'file') { |
|
112 | 112 | $label_after = true; // if type file we need the label after |
113 | 113 | $args['class'] .= ' custom-file-input '; |
114 | - } elseif ( $type == 'checkbox' ) { |
|
114 | + } elseif ($type == 'checkbox') { |
|
115 | 115 | $label_after = true; // if type file we need the label after |
116 | 116 | $args['class'] .= $aui_bs5 ? ' form-check-input c-pointer ' : ' custom-control-input c-pointer '; |
117 | - } elseif ( $type == 'datepicker' || $type == 'timepicker' ) { |
|
117 | + } elseif ($type == 'datepicker' || $type == 'timepicker') { |
|
118 | 118 | $orig_type = $type; |
119 | 119 | $type = 'text'; |
120 | 120 | $args['class'] .= ' bg-initial '; // @todo not sure why we have this? |
121 | - $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr( $args['name'] ) . "\']').trigger('change');"; |
|
121 | + $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr($args['name']) . "\']').trigger('change');"; |
|
122 | 122 | |
123 | 123 | $args['extra_attributes']['data-aui-init'] = 'flatpickr'; |
124 | 124 | |
125 | 125 | // Disable native datetime inputs. |
126 | - $disable_mobile_attr = isset( $args['extra_attributes']['data-disable-mobile'] ) ? $args['extra_attributes']['data-disable-mobile'] : 'true'; |
|
127 | - $disable_mobile_attr = apply_filters( 'aui_flatpickr_disable_disable_mobile_attr', $disable_mobile_attr, $args ); |
|
126 | + $disable_mobile_attr = isset($args['extra_attributes']['data-disable-mobile']) ? $args['extra_attributes']['data-disable-mobile'] : 'true'; |
|
127 | + $disable_mobile_attr = apply_filters('aui_flatpickr_disable_disable_mobile_attr', $disable_mobile_attr, $args); |
|
128 | 128 | |
129 | 129 | $args['extra_attributes']['data-disable-mobile'] = $disable_mobile_attr; |
130 | 130 | |
131 | 131 | // set a way to clear field if empty |
132 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) { |
|
132 | + if ($args['input_group_right'] === '' && $args['clear_icon'] !== false) { |
|
133 | 133 | $args['input_group_right_inside'] = true; |
134 | 134 | $args['clear_icon'] = true; |
135 | 135 | } |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | // enqueue the script |
138 | 138 | $aui_settings = AyeCode_UI_Settings::instance(); |
139 | 139 | $aui_settings->enqueue_flatpickr(); |
140 | - } else if ( $type == 'iconpicker' ) { |
|
140 | + } else if ($type == 'iconpicker') { |
|
141 | 141 | $type = 'text'; |
142 | 142 | |
143 | 143 | // Validate FA icon. |
144 | - $args['value'] = AUI_Component_Helper::sanitize_fa_icon( $args['value'], $args ); |
|
144 | + $args['value'] = AUI_Component_Helper::sanitize_fa_icon($args['value'], $args); |
|
145 | 145 | |
146 | 146 | $args['extra_attributes']['data-aui-init'] = 'iconpicker'; |
147 | 147 | $args['extra_attributes']['data-placement'] = 'bottomRight'; |
@@ -153,104 +153,104 @@ discard block |
||
153 | 153 | $aui_settings->enqueue_iconpicker(); |
154 | 154 | } |
155 | 155 | |
156 | - if ( $type == 'checkbox' && ( ( ! empty( $args['name'] ) && strpos( $args['name'], '[' ) === false ) || ! empty( $args['with_hidden'] ) ) ) { |
|
157 | - $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />'; |
|
156 | + if ($type == 'checkbox' && ((!empty($args['name']) && strpos($args['name'], '[') === false) || !empty($args['with_hidden']))) { |
|
157 | + $output .= '<input type="hidden" name="' . esc_attr($args['name']) . '" value="0" />'; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | // allow clear icon |
161 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] ) { |
|
162 | - $font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' ); |
|
161 | + if ($args['input_group_right'] === '' && $args['clear_icon']) { |
|
162 | + $font_size = $size == 'sm' ? '1.3' : ($size == 'lg' ? '1.65' : '1.5'); |
|
163 | 163 | $args['input_group_right_inside'] = true; |
164 | 164 | $align_class = $aui_bs5 ? ' h-100 py-0' : ''; |
165 | - $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none ' . $align_class . '" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="' . ( $aui_bs5 ? 'btn-close' : 'close' ) . '">' . ( $aui_bs5 ? '' : '×' ) . '</span></span>'; |
|
165 | + $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none ' . $align_class . '" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="' . ($aui_bs5 ? 'btn-close' : 'close') . '">' . ($aui_bs5 ? '' : '×') . '</span></span>'; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | // open/type |
169 | 169 | $output .= '<input type="' . $type . '" '; |
170 | 170 | |
171 | 171 | // name |
172 | - if ( ! empty( $args['name'] ) ) { |
|
173 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
172 | + if (!empty($args['name'])) { |
|
173 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | // id |
177 | - if ( ! empty( $args['id'] ) ) { |
|
178 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
177 | + if (!empty($args['id'])) { |
|
178 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | // placeholder |
182 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
183 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
182 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
183 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | // title |
187 | - if ( ! empty( $args['title'] ) ) { |
|
188 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
187 | + if (!empty($args['title'])) { |
|
188 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | // value |
192 | - if ( ! empty( $args['value'] ) ) { |
|
193 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
192 | + if (!empty($args['value'])) { |
|
193 | + $output .= AUI_Component_Helper::value($args['value']); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | // checked, for radio and checkboxes |
197 | - if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) { |
|
197 | + if (($type == 'checkbox' || $type == 'radio') && $args['checked']) { |
|
198 | 198 | $output .= ' checked '; |
199 | 199 | } |
200 | 200 | |
201 | 201 | // validation text |
202 | - if ( ! empty( $args['validation_text'] ) ) { |
|
203 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" '; |
|
202 | + if (!empty($args['validation_text'])) { |
|
203 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr(addslashes($args['validation_text'])) . '\')" '; |
|
204 | 204 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
205 | 205 | } |
206 | 206 | |
207 | 207 | // validation_pattern |
208 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
209 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
208 | + if (!empty($args['validation_pattern'])) { |
|
209 | + $output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" '; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | // step (for numbers) |
213 | - if ( ! empty( $args['step'] ) ) { |
|
213 | + if (!empty($args['step'])) { |
|
214 | 214 | $output .= ' step="' . $args['step'] . '" '; |
215 | 215 | } |
216 | 216 | |
217 | 217 | // required |
218 | - if ( ! empty( $args['required'] ) ) { |
|
218 | + if (!empty($args['required'])) { |
|
219 | 219 | $output .= ' required '; |
220 | 220 | } |
221 | 221 | |
222 | 222 | // class |
223 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
224 | - $output .= $aui_bs5 && $type == 'checkbox' ? ' class="' . $class . '" ' : ' class="form-control ' . $class . '" '; |
|
223 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
224 | + $output .= $aui_bs5 && $type == 'checkbox' ? ' class="' . $class . '" ' : ' class="form-control ' . $class . '" '; |
|
225 | 225 | |
226 | 226 | // data-attributes |
227 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
227 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
228 | 228 | |
229 | 229 | // extra attributes |
230 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
231 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
230 | + if (!empty($args['extra_attributes'])) { |
|
231 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | // close |
235 | 235 | $output .= '>'; |
236 | 236 | |
237 | 237 | // help text |
238 | - if ( ! empty( $args['help_text'] ) ) { |
|
239 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
238 | + if (!empty($args['help_text'])) { |
|
239 | + $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | // label |
243 | - if ( ! empty( $args['label'] ) ) { |
|
243 | + if (!empty($args['label'])) { |
|
244 | 244 | $label_base_class = ''; |
245 | - if ( $type == 'file' ) { |
|
245 | + if ($type == 'file') { |
|
246 | 246 | $label_base_class = ' custom-file-label'; |
247 | - } elseif ( $type == 'checkbox' ) { |
|
248 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
249 | - $label_args['title'] = wp_kses_post( $args['help_text'] ); |
|
247 | + } elseif ($type == 'checkbox') { |
|
248 | + if (!empty($args['label_force_left'])) { |
|
249 | + $label_args['title'] = wp_kses_post($args['help_text']); |
|
250 | 250 | $help_text = ''; |
251 | 251 | //$label_args['class'] .= ' d-inline '; |
252 | 252 | $args['wrap_class'] .= ' align-items-center '; |
253 | - }else{ |
|
253 | + } else { |
|
254 | 254 | |
255 | 255 | } |
256 | 256 | |
@@ -258,49 +258,49 @@ discard block |
||
258 | 258 | } |
259 | 259 | $label_args['class'] .= $label_base_class; |
260 | 260 | $temp_label_args = $label_args; |
261 | - if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";} |
|
262 | - $label = self::label( $temp_label_args, $type ); |
|
261 | + if (!empty($args['label_force_left'])) {$temp_label_args['class'] = $label_base_class . " text-muted"; } |
|
262 | + $label = self::label($temp_label_args, $type); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | |
266 | 266 | |
267 | 267 | |
268 | 268 | // set help text in the correct position |
269 | - if ( $label_after ) { |
|
269 | + if ($label_after) { |
|
270 | 270 | $output .= $label . $help_text; |
271 | 271 | } |
272 | 272 | |
273 | 273 | // some input types need a separate wrap |
274 | - if ( $type == 'file' ) { |
|
275 | - $output = self::wrap( array( |
|
274 | + if ($type == 'file') { |
|
275 | + $output = self::wrap(array( |
|
276 | 276 | 'content' => $output, |
277 | 277 | 'class' => $aui_bs5 ? 'mb-3 custom-file' : 'form-group custom-file' |
278 | - ) ); |
|
279 | - } elseif ( $type == 'checkbox' ) { |
|
278 | + )); |
|
279 | + } elseif ($type == 'checkbox') { |
|
280 | 280 | |
281 | 281 | $label_args['title'] = $args['label']; |
282 | - $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ); |
|
283 | - $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
284 | - $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : ''; |
|
285 | - if ( $aui_bs5 ) { |
|
282 | + $label_col = AUI_Component_Helper::get_column_class($args['label_col'], 'label'); |
|
283 | + $label = !empty($args['label_force_left']) ? self::label($label_args, 'cb') : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
284 | + $switch_size_class = $args['switch'] && !is_bool($args['switch']) ? ' custom-switch-' . esc_attr($args['switch']) : ''; |
|
285 | + if ($aui_bs5) { |
|
286 | 286 | $wrap_class = $args['switch'] ? 'form-check form-switch' . $switch_size_class : 'form-check'; |
287 | - }else{ |
|
288 | - $wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox' ; |
|
287 | + } else { |
|
288 | + $wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox'; |
|
289 | 289 | } |
290 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
290 | + if (!empty($args['label_force_left'])) { |
|
291 | 291 | $wrap_class .= $aui_bs5 ? '' : ' d-flex align-content-center'; |
292 | - $label = str_replace(array("form-check-label","custom-control-label"),"", self::label( $label_args, 'cb' ) ); |
|
292 | + $label = str_replace(array("form-check-label", "custom-control-label"), "", self::label($label_args, 'cb')); |
|
293 | 293 | } |
294 | - $output = self::wrap( array( |
|
294 | + $output = self::wrap(array( |
|
295 | 295 | 'content' => $output, |
296 | 296 | 'class' => $aui_bs5 ? $wrap_class : 'custom-control ' . $wrap_class |
297 | - ) ); |
|
297 | + )); |
|
298 | 298 | |
299 | - if ( $args['label_type'] == 'horizontal' ) { |
|
300 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
299 | + if ($args['label_type'] == 'horizontal') { |
|
300 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
301 | 301 | $output = $label . '<div class="' . $input_col . '">' . $output . '</div>'; |
302 | 302 | } |
303 | - } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) { |
|
303 | + } elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) { |
|
304 | 304 | |
305 | 305 | |
306 | 306 | // allow password field to toggle view |
@@ -314,70 +314,70 @@ discard block |
||
314 | 314 | } |
315 | 315 | |
316 | 316 | // input group wraps |
317 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
318 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
317 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
318 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
319 | 319 | $group_size = $size == 'lg' ? ' input-group-lg' : ''; |
320 | 320 | $group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size; |
321 | 321 | |
322 | - if ( $args['input_group_left'] ) { |
|
323 | - $output = self::wrap( array( |
|
322 | + if ($args['input_group_left']) { |
|
323 | + $output = self::wrap(array( |
|
324 | 324 | 'content' => $output, |
325 | 325 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
326 | 326 | 'input_group_left' => $args['input_group_left'], |
327 | 327 | 'input_group_left_inside' => $args['input_group_left_inside'] |
328 | - ) ); |
|
328 | + )); |
|
329 | 329 | } |
330 | - if ( $args['input_group_right'] ) { |
|
331 | - $output = self::wrap( array( |
|
330 | + if ($args['input_group_right']) { |
|
331 | + $output = self::wrap(array( |
|
332 | 332 | 'content' => $output, |
333 | 333 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
334 | 334 | 'input_group_right' => $args['input_group_right'], |
335 | 335 | 'input_group_right_inside' => $args['input_group_right_inside'] |
336 | - ) ); |
|
336 | + )); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | } |
340 | 340 | |
341 | - if ( ! $label_after ) { |
|
341 | + if (!$label_after) { |
|
342 | 342 | $output .= $help_text; |
343 | 343 | } |
344 | 344 | |
345 | 345 | |
346 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
347 | - $output = self::wrap( array( |
|
346 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
347 | + $output = self::wrap(array( |
|
348 | 348 | 'content' => $output, |
349 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
350 | - ) ); |
|
349 | + 'class' => AUI_Component_Helper::get_column_class($args['label_col'], 'input') |
|
350 | + )); |
|
351 | 351 | } |
352 | 352 | |
353 | - if ( ! $label_after ) { |
|
353 | + if (!$label_after) { |
|
354 | 354 | $output = $label . $output; |
355 | 355 | } |
356 | 356 | |
357 | 357 | // wrap |
358 | - if ( ! $args['no_wrap'] ) { |
|
359 | - if ( ! empty( $args['form_group_class'] ) ) { |
|
360 | - $fg_class = esc_attr( $args['form_group_class'] ); |
|
361 | - }else{ |
|
358 | + if (!$args['no_wrap']) { |
|
359 | + if (!empty($args['form_group_class'])) { |
|
360 | + $fg_class = esc_attr($args['form_group_class']); |
|
361 | + } else { |
|
362 | 362 | $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
363 | 363 | } |
364 | 364 | $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : $fg_class; |
365 | 365 | $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
366 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
367 | - $output = self::wrap( array( |
|
366 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
367 | + $output = self::wrap(array( |
|
368 | 368 | 'content' => $output, |
369 | 369 | 'class' => $wrap_class, |
370 | 370 | 'element_require' => $args['element_require'], |
371 | 371 | 'argument_id' => $args['id'], |
372 | 372 | 'wrap_attributes' => $args['wrap_attributes'], |
373 | - ) ); |
|
373 | + )); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
377 | 377 | return $output; |
378 | 378 | } |
379 | 379 | |
380 | - public static function label( $args = array(), $type = '' ) { |
|
380 | + public static function label($args = array(), $type = '') { |
|
381 | 381 | global $aui_bs5; |
382 | 382 | |
383 | 383 | $defaults = array( |
@@ -391,23 +391,23 @@ discard block |
||
391 | 391 | /** |
392 | 392 | * Parse incoming $args into an array and merge it with $defaults |
393 | 393 | */ |
394 | - $args = wp_parse_args( $args, $defaults ); |
|
394 | + $args = wp_parse_args($args, $defaults); |
|
395 | 395 | $output = ''; |
396 | 396 | |
397 | - if ( $args['title'] ) { |
|
397 | + if ($args['title']) { |
|
398 | 398 | // maybe hide labels //@todo set a global option for visibility class |
399 | - if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) { |
|
399 | + if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) { |
|
400 | 400 | $class = $args['class']; |
401 | 401 | } else { |
402 | - $class = 'sr-only ' . ( $aui_bs5 ? 'visually-hidden ' : '' ) . $args['class']; |
|
402 | + $class = 'sr-only ' . ($aui_bs5 ? 'visually-hidden ' : '') . $args['class']; |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | // maybe horizontal |
406 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
407 | - $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label ' . $type; |
|
406 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
407 | + $class .= ' ' . AUI_Component_Helper::get_column_class($args['label_col'], 'label') . ' col-form-label ' . $type; |
|
408 | 408 | } |
409 | 409 | |
410 | - if ( $aui_bs5 ) { |
|
410 | + if ($aui_bs5) { |
|
411 | 411 | $class .= ' form-label'; |
412 | 412 | } |
413 | 413 | |
@@ -415,20 +415,20 @@ discard block |
||
415 | 415 | $output .= '<label'; |
416 | 416 | |
417 | 417 | // for |
418 | - if ( ! empty( $args['for'] ) ) { |
|
419 | - $output .= ' for="' . esc_attr( $args['for'] ) . '"'; |
|
418 | + if (!empty($args['for'])) { |
|
419 | + $output .= ' for="' . esc_attr($args['for']) . '"'; |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | // class |
423 | - $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
423 | + $class = $class ? AUI_Component_Helper::esc_classes($class) : ''; |
|
424 | 424 | $output .= $class != "" ? ' class="' . $class . '"' : ''; |
425 | 425 | |
426 | 426 | // close |
427 | 427 | $output .= '>'; |
428 | 428 | |
429 | 429 | // title, don't escape fully as can contain html |
430 | - if ( ! empty( $args['title'] ) ) { |
|
431 | - $output .= wp_kses_post( $args['title'] ); |
|
430 | + if (!empty($args['title'])) { |
|
431 | + $output .= wp_kses_post($args['title']); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | // close wrap |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @return string |
447 | 447 | */ |
448 | - public static function wrap( $args = array() ) { |
|
448 | + public static function wrap($args = array()) { |
|
449 | 449 | global $aui_bs5; |
450 | 450 | $defaults = array( |
451 | 451 | 'type' => 'div', |
@@ -463,31 +463,31 @@ discard block |
||
463 | 463 | /** |
464 | 464 | * Parse incoming $args into an array and merge it with $defaults |
465 | 465 | */ |
466 | - $args = wp_parse_args( $args, $defaults ); |
|
466 | + $args = wp_parse_args($args, $defaults); |
|
467 | 467 | $output = ''; |
468 | - if ( $args['type'] ) { |
|
468 | + if ($args['type']) { |
|
469 | 469 | |
470 | 470 | // open |
471 | - $output .= '<' . sanitize_html_class( $args['type'] ); |
|
471 | + $output .= '<' . sanitize_html_class($args['type']); |
|
472 | 472 | |
473 | 473 | // element require |
474 | - if ( ! empty( $args['element_require'] ) ) { |
|
475 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
474 | + if (!empty($args['element_require'])) { |
|
475 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
476 | 476 | $args['class'] .= " aui-conditional-field"; |
477 | 477 | } |
478 | 478 | |
479 | 479 | // argument_id |
480 | - if ( ! empty( $args['argument_id'] ) ) { |
|
481 | - $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"'; |
|
480 | + if (!empty($args['argument_id'])) { |
|
481 | + $output .= ' data-argument="' . esc_attr($args['argument_id']) . '"'; |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | // class |
485 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
485 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
486 | 486 | $output .= ' class="' . $class . '" '; |
487 | 487 | |
488 | 488 | // Attributes |
489 | - if ( ! empty( $args['wrap_attributes'] ) ) { |
|
490 | - $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] ); |
|
489 | + if (!empty($args['wrap_attributes'])) { |
|
490 | + $output .= AUI_Component_Helper::extra_attributes($args['wrap_attributes']); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | // close wrap |
@@ -495,9 +495,9 @@ discard block |
||
495 | 495 | |
496 | 496 | |
497 | 497 | // Input group left |
498 | - if ( ! empty( $args['input_group_left'] ) ) { |
|
499 | - $position_class = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : ''; |
|
500 | - $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
498 | + if (!empty($args['input_group_left'])) { |
|
499 | + $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
|
500 | + $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
501 | 501 | $output .= $aui_bs5 ? $input_group_left : '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
502 | 502 | // $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
503 | 503 | } |
@@ -506,16 +506,16 @@ discard block |
||
506 | 506 | $output .= $args['content']; |
507 | 507 | |
508 | 508 | // Input group right |
509 | - if ( ! empty( $args['input_group_right'] ) ) { |
|
510 | - $position_class = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : ''; |
|
511 | - $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
512 | - $output .= $aui_bs5 ? str_replace( 'input-group-text','input-group-text top-0 end-0', $input_group_right ) : '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
|
509 | + if (!empty($args['input_group_right'])) { |
|
510 | + $position_class = !empty($args['input_group_right_inside']) ? 'position-absolute h-100' : ''; |
|
511 | + $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
512 | + $output .= $aui_bs5 ? str_replace('input-group-text', 'input-group-text top-0 end-0', $input_group_right) : '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
|
513 | 513 | // $output .= '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
514 | 514 | } |
515 | 515 | |
516 | 516 | |
517 | 517 | // close wrap |
518 | - $output .= '</' . sanitize_html_class( $args['type'] ) . '>'; |
|
518 | + $output .= '</' . sanitize_html_class($args['type']) . '>'; |
|
519 | 519 | |
520 | 520 | |
521 | 521 | } else { |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return string The rendered component. |
534 | 534 | */ |
535 | - public static function textarea( $args = array() ) { |
|
535 | + public static function textarea($args = array()) { |
|
536 | 536 | global $aui_bs5; |
537 | 537 | |
538 | 538 | $defaults = array( |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | /** |
573 | 573 | * Parse incoming $args into an array and merge it with $defaults |
574 | 574 | */ |
575 | - $args = wp_parse_args( $args, $defaults ); |
|
575 | + $args = wp_parse_args($args, $defaults); |
|
576 | 576 | $output = ''; |
577 | 577 | $label = ''; |
578 | 578 | |
@@ -580,21 +580,21 @@ discard block |
||
580 | 580 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
581 | 581 | |
582 | 582 | // floating labels don't work with wysiwyg so set it as top |
583 | - if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) { |
|
583 | + if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) { |
|
584 | 584 | $args['label_type'] = 'top'; |
585 | 585 | } |
586 | 586 | |
587 | 587 | $label_after = $args['label_after']; |
588 | 588 | |
589 | 589 | // floating labels need label after |
590 | - if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) { |
|
590 | + if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) { |
|
591 | 591 | $label_after = true; |
592 | 592 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
593 | 593 | } |
594 | 594 | |
595 | 595 | // label |
596 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
597 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
596 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
597 | + } elseif (!empty($args['label']) && !$label_after) { |
|
598 | 598 | $label_args = array( |
599 | 599 | 'title' => $args['label'], |
600 | 600 | 'for' => $args['id'], |
@@ -602,34 +602,34 @@ discard block |
||
602 | 602 | 'label_type' => $args['label_type'], |
603 | 603 | 'label_col' => $args['label_col'] |
604 | 604 | ); |
605 | - $label .= self::label( $label_args ); |
|
605 | + $label .= self::label($label_args); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | // maybe horizontal label |
609 | - if ( $args['label_type'] == 'horizontal' ) { |
|
610 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
609 | + if ($args['label_type'] == 'horizontal') { |
|
610 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
611 | 611 | $label .= '<div class="' . $input_col . '">'; |
612 | 612 | } |
613 | 613 | |
614 | - if ( ! empty( $args['wysiwyg'] ) ) { |
|
614 | + if (!empty($args['wysiwyg'])) { |
|
615 | 615 | ob_start(); |
616 | 616 | $content = $args['value']; |
617 | - $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor'; |
|
617 | + $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor'; |
|
618 | 618 | $settings = array( |
619 | - 'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4, |
|
619 | + 'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4, |
|
620 | 620 | 'quicktags' => false, |
621 | 621 | 'media_buttons' => false, |
622 | 622 | 'editor_class' => 'form-control', |
623 | - 'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ), |
|
623 | + 'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']), |
|
624 | 624 | 'teeny' => true, |
625 | 625 | ); |
626 | 626 | |
627 | 627 | // maybe set settings if array |
628 | - if ( is_array( $args['wysiwyg'] ) ) { |
|
629 | - $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
628 | + if (is_array($args['wysiwyg'])) { |
|
629 | + $settings = wp_parse_args($args['wysiwyg'], $settings); |
|
630 | 630 | } |
631 | 631 | |
632 | - wp_editor( $content, $editor_id, $settings ); |
|
632 | + wp_editor($content, $editor_id, $settings); |
|
633 | 633 | $output .= ob_get_clean(); |
634 | 634 | } else { |
635 | 635 | |
@@ -637,65 +637,65 @@ discard block |
||
637 | 637 | $output .= '<textarea '; |
638 | 638 | |
639 | 639 | // name |
640 | - if ( ! empty( $args['name'] ) ) { |
|
641 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
640 | + if (!empty($args['name'])) { |
|
641 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | // id |
645 | - if ( ! empty( $args['id'] ) ) { |
|
646 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
645 | + if (!empty($args['id'])) { |
|
646 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | // placeholder |
650 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
651 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
650 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
651 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | // title |
655 | - if ( ! empty( $args['title'] ) ) { |
|
656 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
655 | + if (!empty($args['title'])) { |
|
656 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | // validation text |
660 | - if ( ! empty( $args['validation_text'] ) ) { |
|
661 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" '; |
|
660 | + if (!empty($args['validation_text'])) { |
|
661 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr(addslashes($args['validation_text'])) . '\')" '; |
|
662 | 662 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
663 | 663 | } |
664 | 664 | |
665 | 665 | // validation_pattern |
666 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
667 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
666 | + if (!empty($args['validation_pattern'])) { |
|
667 | + $output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" '; |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | // required |
671 | - if ( ! empty( $args['required'] ) ) { |
|
671 | + if (!empty($args['required'])) { |
|
672 | 672 | $output .= ' required '; |
673 | 673 | } |
674 | 674 | |
675 | 675 | // rows |
676 | - if ( ! empty( $args['rows'] ) ) { |
|
677 | - $output .= ' rows="' . absint( $args['rows'] ) . '" '; |
|
676 | + if (!empty($args['rows'])) { |
|
677 | + $output .= ' rows="' . absint($args['rows']) . '" '; |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | |
681 | 681 | // class |
682 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
682 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
683 | 683 | $output .= ' class="form-control ' . $class . '" '; |
684 | 684 | |
685 | 685 | // extra attributes |
686 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
687 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
686 | + if (!empty($args['extra_attributes'])) { |
|
687 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | // close tag |
691 | 691 | $output .= '>'; |
692 | 692 | |
693 | 693 | // value |
694 | - if ( ! empty( $args['value'] ) ) { |
|
695 | - if ( ! empty( $args['allow_tags'] ) ) { |
|
696 | - $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
694 | + if (!empty($args['value'])) { |
|
695 | + if (!empty($args['allow_tags'])) { |
|
696 | + $output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML. |
|
697 | 697 | } else { |
698 | - $output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] ); |
|
698 | + $output .= AUI_Component_Helper::sanitize_textarea_field($args['value']); |
|
699 | 699 | } |
700 | 700 | } |
701 | 701 | |
@@ -704,23 +704,23 @@ discard block |
||
704 | 704 | |
705 | 705 | |
706 | 706 | // input group wraps |
707 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
708 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
709 | - if ( $args['input_group_left'] ) { |
|
710 | - $output = self::wrap( array( |
|
707 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
708 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
709 | + if ($args['input_group_left']) { |
|
710 | + $output = self::wrap(array( |
|
711 | 711 | 'content' => $output, |
712 | 712 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
713 | 713 | 'input_group_left' => $args['input_group_left'], |
714 | 714 | 'input_group_left_inside' => $args['input_group_left_inside'] |
715 | - ) ); |
|
715 | + )); |
|
716 | 716 | } |
717 | - if ( $args['input_group_right'] ) { |
|
718 | - $output = self::wrap( array( |
|
717 | + if ($args['input_group_right']) { |
|
718 | + $output = self::wrap(array( |
|
719 | 719 | 'content' => $output, |
720 | 720 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
721 | 721 | 'input_group_right' => $args['input_group_right'], |
722 | 722 | 'input_group_right_inside' => $args['input_group_right_inside'] |
723 | - ) ); |
|
723 | + )); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | } |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | |
729 | 729 | } |
730 | 730 | |
731 | - if ( ! empty( $args['label'] ) && $label_after ) { |
|
731 | + if (!empty($args['label']) && $label_after) { |
|
732 | 732 | $label_args = array( |
733 | 733 | 'title' => $args['label'], |
734 | 734 | 'for' => $args['id'], |
@@ -736,41 +736,41 @@ discard block |
||
736 | 736 | 'label_type' => $args['label_type'], |
737 | 737 | 'label_col' => $args['label_col'] |
738 | 738 | ); |
739 | - $output .= self::label( $label_args ); |
|
739 | + $output .= self::label($label_args); |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | // help text |
743 | - if ( ! empty( $args['help_text'] ) ) { |
|
744 | - $output .= AUI_Component_Helper::help_text( $args['help_text'] ); |
|
743 | + if (!empty($args['help_text'])) { |
|
744 | + $output .= AUI_Component_Helper::help_text($args['help_text']); |
|
745 | 745 | } |
746 | 746 | |
747 | - if ( ! $label_after ) { |
|
747 | + if (!$label_after) { |
|
748 | 748 | $output = $label . $output; |
749 | 749 | } |
750 | 750 | |
751 | 751 | // maybe horizontal label |
752 | - if ( $args['label_type'] == 'horizontal' ) { |
|
752 | + if ($args['label_type'] == 'horizontal') { |
|
753 | 753 | $output .= '</div>'; |
754 | 754 | } |
755 | 755 | |
756 | 756 | |
757 | 757 | // wrap |
758 | - if ( ! $args['no_wrap'] ) { |
|
759 | - if ( ! empty( $args['form_group_class'] ) ) { |
|
760 | - $fg_class = esc_attr( $args['form_group_class'] ); |
|
761 | - }else{ |
|
758 | + if (!$args['no_wrap']) { |
|
759 | + if (!empty($args['form_group_class'])) { |
|
760 | + $fg_class = esc_attr($args['form_group_class']); |
|
761 | + } else { |
|
762 | 762 | $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
763 | 763 | } |
764 | 764 | $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : $fg_class; |
765 | 765 | $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
766 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
767 | - $output = self::wrap( array( |
|
766 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
767 | + $output = self::wrap(array( |
|
768 | 768 | 'content' => $output, |
769 | 769 | 'class' => $wrap_class, |
770 | 770 | 'element_require' => $args['element_require'], |
771 | 771 | 'argument_id' => $args['id'], |
772 | 772 | 'wrap_attributes' => $args['wrap_attributes'], |
773 | - ) ); |
|
773 | + )); |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | * |
785 | 785 | * @return string The rendered component. |
786 | 786 | */ |
787 | - public static function select( $args = array() ) { |
|
787 | + public static function select($args = array()) { |
|
788 | 788 | global $aui_bs5, $aui_has_select2, $aui_select2_enqueued; |
789 | 789 | |
790 | 790 | $defaults = array( |
@@ -824,11 +824,11 @@ discard block |
||
824 | 824 | /** |
825 | 825 | * Parse incoming $args into an array and merge it with $defaults |
826 | 826 | */ |
827 | - $args = wp_parse_args( $args, $defaults ); |
|
827 | + $args = wp_parse_args($args, $defaults); |
|
828 | 828 | $output = ''; |
829 | 829 | |
830 | 830 | // for now lets hide floating labels |
831 | - if ( $args['label_type'] == 'floating' ) { |
|
831 | + if ($args['label_type'] == 'floating') { |
|
832 | 832 | $args['label_type'] = 'hidden'; |
833 | 833 | } |
834 | 834 | |
@@ -839,26 +839,26 @@ discard block |
||
839 | 839 | $label_after = $args['label_after']; |
840 | 840 | |
841 | 841 | // floating labels need label after |
842 | - if ( $args['label_type'] == 'floating' ) { |
|
842 | + if ($args['label_type'] == 'floating') { |
|
843 | 843 | $label_after = true; |
844 | 844 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
845 | 845 | } |
846 | 846 | |
847 | 847 | // Maybe setup select2 |
848 | 848 | $is_select2 = false; |
849 | - if ( ! empty( $args['select2'] ) ) { |
|
849 | + if (!empty($args['select2'])) { |
|
850 | 850 | $args['class'] .= ' aui-select2'; |
851 | 851 | $is_select2 = true; |
852 | - } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) { |
|
852 | + } elseif (strpos($args['class'], 'aui-select2') !== false) { |
|
853 | 853 | $is_select2 = true; |
854 | 854 | } |
855 | 855 | |
856 | - if ( $is_select2 && ! $aui_has_select2 ) { |
|
856 | + if ($is_select2 && !$aui_has_select2) { |
|
857 | 857 | $aui_has_select2 = true; |
858 | - $conditional_select2 = apply_filters( 'aui_is_conditional_select2', true ); |
|
858 | + $conditional_select2 = apply_filters('aui_is_conditional_select2', true); |
|
859 | 859 | |
860 | 860 | // Enqueue the script, |
861 | - if ( empty( $aui_select2_enqueued ) && $conditional_select2 === true ) { |
|
861 | + if (empty($aui_select2_enqueued) && $conditional_select2 === true) { |
|
862 | 862 | $aui_select2_enqueued = true; |
863 | 863 | |
864 | 864 | $aui_settings = AyeCode_UI_Settings::instance(); |
@@ -867,75 +867,75 @@ discard block |
||
867 | 867 | } |
868 | 868 | |
869 | 869 | // select2 tags |
870 | - if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason |
|
870 | + if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason |
|
871 | 871 | $args['data-tags'] = 'true'; |
872 | 872 | $args['data-token-separators'] = "[',']"; |
873 | 873 | $args['multiple'] = true; |
874 | 874 | } |
875 | 875 | |
876 | 876 | // select2 placeholder |
877 | - if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) { |
|
878 | - $args['data-placeholder'] = esc_attr( $args['placeholder'] ); |
|
879 | - $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true; |
|
877 | + if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) { |
|
878 | + $args['data-placeholder'] = esc_attr($args['placeholder']); |
|
879 | + $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true; |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | // Set hidden input to save empty value for multiselect. |
883 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) { |
|
884 | - $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value="" data-ignore-rule/>'; |
|
883 | + if (!empty($args['multiple']) && !empty($args['name'])) { |
|
884 | + $output .= '<input type="hidden" ' . AUI_Component_Helper::name($args['name']) . ' value="" data-ignore-rule/>'; |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | // open/type |
888 | 888 | $output .= '<select '; |
889 | 889 | |
890 | 890 | // style |
891 | - if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
891 | + if ($is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
892 | 892 | $output .= " style='width:100%;' "; |
893 | 893 | } |
894 | 894 | |
895 | 895 | // element require |
896 | - if ( ! empty( $args['element_require'] ) ) { |
|
897 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
896 | + if (!empty($args['element_require'])) { |
|
897 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
898 | 898 | $args['class'] .= " aui-conditional-field"; |
899 | 899 | } |
900 | 900 | |
901 | 901 | // class |
902 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
902 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
903 | 903 | $select_class = $aui_bs5 ? 'form-select ' : 'custom-select '; |
904 | - $output .= AUI_Component_Helper::class_attr( $select_class . $class ); |
|
904 | + $output .= AUI_Component_Helper::class_attr($select_class . $class); |
|
905 | 905 | |
906 | 906 | // name |
907 | - if ( ! empty( $args['name'] ) ) { |
|
908 | - $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] ); |
|
907 | + if (!empty($args['name'])) { |
|
908 | + $output .= AUI_Component_Helper::name($args['name'], $args['multiple']); |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | // id |
912 | - if ( ! empty( $args['id'] ) ) { |
|
913 | - $output .= AUI_Component_Helper::id( $args['id'] ); |
|
912 | + if (!empty($args['id'])) { |
|
913 | + $output .= AUI_Component_Helper::id($args['id']); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | // title |
917 | - if ( ! empty( $args['title'] ) ) { |
|
918 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
917 | + if (!empty($args['title'])) { |
|
918 | + $output .= AUI_Component_Helper::title($args['title']); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | // data-attributes |
922 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
922 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
923 | 923 | |
924 | 924 | // aria-attributes |
925 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
925 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
926 | 926 | |
927 | 927 | // extra attributes |
928 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
929 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
928 | + if (!empty($args['extra_attributes'])) { |
|
929 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | // required |
933 | - if ( ! empty( $args['required'] ) ) { |
|
933 | + if (!empty($args['required'])) { |
|
934 | 934 | $output .= ' required'; |
935 | 935 | } |
936 | 936 | |
937 | 937 | // multiple |
938 | - if ( ! empty( $args['multiple'] ) ) { |
|
938 | + if (!empty($args['multiple'])) { |
|
939 | 939 | $output .= ' multiple'; |
940 | 940 | } |
941 | 941 | |
@@ -943,50 +943,50 @@ discard block |
||
943 | 943 | $output .= '>'; |
944 | 944 | |
945 | 945 | // placeholder |
946 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) { |
|
947 | - $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>'; |
|
948 | - } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) { |
|
946 | + if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) { |
|
947 | + $output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>'; |
|
948 | + } elseif ($is_select2 && !empty($args['placeholder'])) { |
|
949 | 949 | $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
950 | 950 | } |
951 | 951 | |
952 | 952 | // Options |
953 | - if ( ! empty( $args['options'] ) ) { |
|
953 | + if (!empty($args['options'])) { |
|
954 | 954 | |
955 | - if ( ! is_array( $args['options'] ) ) { |
|
955 | + if (!is_array($args['options'])) { |
|
956 | 956 | $output .= $args['options']; // not the preferred way but an option |
957 | 957 | } else { |
958 | - foreach ( $args['options'] as $val => $name ) { |
|
958 | + foreach ($args['options'] as $val => $name) { |
|
959 | 959 | $selected = ''; |
960 | - if ( is_array( $name ) ) { |
|
961 | - if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) { |
|
962 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
960 | + if (is_array($name)) { |
|
961 | + if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) { |
|
962 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
963 | 963 | |
964 | - $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>'; |
|
964 | + $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; |
|
965 | 965 | } else { |
966 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
967 | - $option_value = isset( $name['value'] ) ? $name['value'] : ''; |
|
968 | - $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : ''; |
|
969 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) { |
|
970 | - $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : ""; |
|
971 | - } elseif ( ! empty( $args['value'] ) ) { |
|
972 | - $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false ); |
|
973 | - } elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) { |
|
974 | - $selected = selected( $option_value, $args['value'], false ); |
|
966 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
967 | + $option_value = isset($name['value']) ? $name['value'] : ''; |
|
968 | + $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes($name['extra_attributes']) : ''; |
|
969 | + if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) { |
|
970 | + $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : ""; |
|
971 | + } elseif (!empty($args['value'])) { |
|
972 | + $selected = selected($option_value, stripslashes_deep($args['value']), false); |
|
973 | + } elseif (empty($args['value']) && $args['value'] === $option_value) { |
|
974 | + $selected = selected($option_value, $args['value'], false); |
|
975 | 975 | } |
976 | 976 | |
977 | - $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>'; |
|
977 | + $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . ' ' . $extra_attributes . '>' . $option_label . '</option>'; |
|
978 | 978 | } |
979 | 979 | } else { |
980 | - if ( ! empty( $args['value'] ) ) { |
|
981 | - if ( is_array( $args['value'] ) ) { |
|
982 | - $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : ''; |
|
983 | - } elseif ( ! empty( $args['value'] ) ) { |
|
984 | - $selected = selected( $args['value'], $val, false ); |
|
980 | + if (!empty($args['value'])) { |
|
981 | + if (is_array($args['value'])) { |
|
982 | + $selected = in_array($val, $args['value']) ? 'selected="selected"' : ''; |
|
983 | + } elseif (!empty($args['value'])) { |
|
984 | + $selected = selected($args['value'], $val, false); |
|
985 | 985 | } |
986 | - } elseif ( $args['value'] === $val ) { |
|
987 | - $selected = selected( $args['value'], $val, false ); |
|
986 | + } elseif ($args['value'] === $val) { |
|
987 | + $selected = selected($args['value'], $val, false); |
|
988 | 988 | } |
989 | - $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>'; |
|
989 | + $output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>'; |
|
990 | 990 | } |
991 | 991 | } |
992 | 992 | } |
@@ -999,8 +999,8 @@ discard block |
||
999 | 999 | $label = ''; |
1000 | 1000 | $help_text = ''; |
1001 | 1001 | // label |
1002 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
1003 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
1002 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
1003 | + } elseif (!empty($args['label']) && !$label_after) { |
|
1004 | 1004 | $label_args = array( |
1005 | 1005 | 'title' => $args['label'], |
1006 | 1006 | 'for' => $args['id'], |
@@ -1008,49 +1008,49 @@ discard block |
||
1008 | 1008 | 'label_type' => $args['label_type'], |
1009 | 1009 | 'label_col' => $args['label_col'] |
1010 | 1010 | ); |
1011 | - $label = self::label( $label_args ); |
|
1011 | + $label = self::label($label_args); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | // help text |
1015 | - if ( ! empty( $args['help_text'] ) ) { |
|
1016 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
1015 | + if (!empty($args['help_text'])) { |
|
1016 | + $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | // input group wraps |
1020 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
1021 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
1022 | - if ( $args['input_group_left'] ) { |
|
1023 | - $output = self::wrap( array( |
|
1020 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
1021 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
1022 | + if ($args['input_group_left']) { |
|
1023 | + $output = self::wrap(array( |
|
1024 | 1024 | 'content' => $output, |
1025 | 1025 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
1026 | 1026 | 'input_group_left' => $args['input_group_left'], |
1027 | 1027 | 'input_group_left_inside' => $args['input_group_left_inside'] |
1028 | - ) ); |
|
1028 | + )); |
|
1029 | 1029 | } |
1030 | - if ( $args['input_group_right'] ) { |
|
1031 | - $output = self::wrap( array( |
|
1030 | + if ($args['input_group_right']) { |
|
1031 | + $output = self::wrap(array( |
|
1032 | 1032 | 'content' => $output, |
1033 | 1033 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
1034 | 1034 | 'input_group_right' => $args['input_group_right'], |
1035 | 1035 | 'input_group_right_inside' => $args['input_group_right_inside'] |
1036 | - ) ); |
|
1036 | + )); |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | } |
1040 | 1040 | |
1041 | - if ( ! $label_after ) { |
|
1041 | + if (!$label_after) { |
|
1042 | 1042 | $output .= $help_text; |
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | |
1046 | - if ( $args['label_type'] == 'horizontal' ) { |
|
1047 | - $output = self::wrap( array( |
|
1046 | + if ($args['label_type'] == 'horizontal') { |
|
1047 | + $output = self::wrap(array( |
|
1048 | 1048 | 'content' => $output, |
1049 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
1050 | - ) ); |
|
1049 | + 'class' => AUI_Component_Helper::get_column_class($args['label_col'], 'input') |
|
1050 | + )); |
|
1051 | 1051 | } |
1052 | 1052 | |
1053 | - if ( ! $label_after ) { |
|
1053 | + if (!$label_after) { |
|
1054 | 1054 | $output = $label . $output; |
1055 | 1055 | } |
1056 | 1056 | |
@@ -1061,21 +1061,21 @@ discard block |
||
1061 | 1061 | |
1062 | 1062 | |
1063 | 1063 | // wrap |
1064 | - if ( ! $args['no_wrap'] ) { |
|
1065 | - if ( ! empty( $args['form_group_class'] ) ) { |
|
1066 | - $fg_class = esc_attr( $args['form_group_class'] ); |
|
1067 | - }else{ |
|
1064 | + if (!$args['no_wrap']) { |
|
1065 | + if (!empty($args['form_group_class'])) { |
|
1066 | + $fg_class = esc_attr($args['form_group_class']); |
|
1067 | + } else { |
|
1068 | 1068 | $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
1069 | 1069 | } |
1070 | 1070 | $wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class; |
1071 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
1072 | - $output = self::wrap( array( |
|
1071 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
1072 | + $output = self::wrap(array( |
|
1073 | 1073 | 'content' => $output, |
1074 | 1074 | 'class' => $wrap_class, |
1075 | 1075 | 'element_require' => $args['element_require'], |
1076 | 1076 | 'argument_id' => $args['id'], |
1077 | 1077 | 'wrap_attributes' => $args['wrap_attributes'], |
1078 | - ) ); |
|
1078 | + )); |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | * |
1090 | 1090 | * @return string The rendered component. |
1091 | 1091 | */ |
1092 | - public static function radio( $args = array() ) { |
|
1092 | + public static function radio($args = array()) { |
|
1093 | 1093 | global $aui_bs5; |
1094 | 1094 | |
1095 | 1095 | $defaults = array( |
@@ -1121,10 +1121,10 @@ discard block |
||
1121 | 1121 | /** |
1122 | 1122 | * Parse incoming $args into an array and merge it with $defaults |
1123 | 1123 | */ |
1124 | - $args = wp_parse_args( $args, $defaults ); |
|
1124 | + $args = wp_parse_args($args, $defaults); |
|
1125 | 1125 | |
1126 | 1126 | // for now lets use horizontal for floating |
1127 | - if ( $args['label_type'] == 'floating' ) { |
|
1127 | + if ($args['label_type'] == 'floating') { |
|
1128 | 1128 | $args['label_type'] = 'horizontal'; |
1129 | 1129 | } |
1130 | 1130 | |
@@ -1135,59 +1135,59 @@ discard block |
||
1135 | 1135 | 'label_col' => $args['label_col'] |
1136 | 1136 | ); |
1137 | 1137 | |
1138 | - if ( $args['label_type'] == 'top' || $args['label_type'] == 'hidden' ) { |
|
1138 | + if ($args['label_type'] == 'top' || $args['label_type'] == 'hidden') { |
|
1139 | 1139 | $label_args['class'] .= 'd-block '; |
1140 | 1140 | |
1141 | - if ( $args['label_type'] == 'hidden' ) { |
|
1142 | - $label_args['class'] .= 'sr-only ' . ( $aui_bs5 ? 'visually-hidden ' : '' ); |
|
1141 | + if ($args['label_type'] == 'hidden') { |
|
1142 | + $label_args['class'] .= 'sr-only ' . ($aui_bs5 ? 'visually-hidden ' : ''); |
|
1143 | 1143 | } |
1144 | 1144 | } |
1145 | 1145 | |
1146 | 1146 | $output = ''; |
1147 | 1147 | |
1148 | 1148 | // label before |
1149 | - if ( ! empty( $args['label'] ) ) { |
|
1150 | - $output .= self::label( $label_args, 'radio' ); |
|
1149 | + if (!empty($args['label'])) { |
|
1150 | + $output .= self::label($label_args, 'radio'); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | // maybe horizontal label |
1154 | - if ( $args['label_type'] == 'horizontal' ) { |
|
1155 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
1154 | + if ($args['label_type'] == 'horizontal') { |
|
1155 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
1156 | 1156 | $output .= '<div class="' . $input_col . '">'; |
1157 | 1157 | } |
1158 | 1158 | |
1159 | - if ( ! empty( $args['options'] ) ) { |
|
1159 | + if (!empty($args['options'])) { |
|
1160 | 1160 | $count = 0; |
1161 | - foreach ( $args['options'] as $value => $label ) { |
|
1161 | + foreach ($args['options'] as $value => $label) { |
|
1162 | 1162 | $option_args = $args; |
1163 | 1163 | $option_args['value'] = $value; |
1164 | 1164 | $option_args['label'] = $label; |
1165 | 1165 | $option_args['checked'] = $value == $args['value'] ? true : false; |
1166 | - $output .= self::radio_option( $option_args, $count ); |
|
1167 | - $count ++; |
|
1166 | + $output .= self::radio_option($option_args, $count); |
|
1167 | + $count++; |
|
1168 | 1168 | } |
1169 | 1169 | } |
1170 | 1170 | |
1171 | 1171 | // help text |
1172 | - $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
1172 | + $help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : ''; |
|
1173 | 1173 | $output .= $help_text; |
1174 | 1174 | |
1175 | 1175 | // maybe horizontal label |
1176 | - if ( $args['label_type'] == 'horizontal' ) { |
|
1176 | + if ($args['label_type'] == 'horizontal') { |
|
1177 | 1177 | $output .= '</div>'; |
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | // wrap |
1181 | 1181 | $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
1182 | 1182 | $wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class; |
1183 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
1184 | - $output = self::wrap( array( |
|
1183 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
1184 | + $output = self::wrap(array( |
|
1185 | 1185 | 'content' => $output, |
1186 | 1186 | 'class' => $wrap_class, |
1187 | 1187 | 'element_require' => $args['element_require'], |
1188 | 1188 | 'argument_id' => $args['id'], |
1189 | 1189 | 'wrap_attributes' => $args['wrap_attributes'], |
1190 | - ) ); |
|
1190 | + )); |
|
1191 | 1191 | |
1192 | 1192 | |
1193 | 1193 | return $output; |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | * |
1201 | 1201 | * @return string The rendered component. |
1202 | 1202 | */ |
1203 | - public static function radio_option( $args = array(), $count = '' ) { |
|
1203 | + public static function radio_option($args = array(), $count = '') { |
|
1204 | 1204 | $defaults = array( |
1205 | 1205 | 'class' => '', |
1206 | 1206 | 'id' => '', |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | /** |
1219 | 1219 | * Parse incoming $args into an array and merge it with $defaults |
1220 | 1220 | */ |
1221 | - $args = wp_parse_args( $args, $defaults ); |
|
1221 | + $args = wp_parse_args($args, $defaults); |
|
1222 | 1222 | |
1223 | 1223 | $output = ''; |
1224 | 1224 | |
@@ -1229,43 +1229,43 @@ discard block |
||
1229 | 1229 | $output .= ' class="form-check-input" '; |
1230 | 1230 | |
1231 | 1231 | // name |
1232 | - if ( ! empty( $args['name'] ) ) { |
|
1233 | - $output .= AUI_Component_Helper::name( $args['name'] ); |
|
1232 | + if (!empty($args['name'])) { |
|
1233 | + $output .= AUI_Component_Helper::name($args['name']); |
|
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | // id |
1237 | - if ( ! empty( $args['id'] ) ) { |
|
1238 | - $output .= AUI_Component_Helper::id( $args['id'] . $count ); |
|
1237 | + if (!empty($args['id'])) { |
|
1238 | + $output .= AUI_Component_Helper::id($args['id'] . $count); |
|
1239 | 1239 | } |
1240 | 1240 | |
1241 | 1241 | // title |
1242 | - if ( ! empty( $args['title'] ) ) { |
|
1243 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
1242 | + if (!empty($args['title'])) { |
|
1243 | + $output .= AUI_Component_Helper::title($args['title']); |
|
1244 | 1244 | } |
1245 | 1245 | |
1246 | 1246 | // value |
1247 | - if ( isset( $args['value'] ) ) { |
|
1248 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
1247 | + if (isset($args['value'])) { |
|
1248 | + $output .= AUI_Component_Helper::value($args['value']); |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | // checked, for radio and checkboxes |
1252 | - if ( $args['checked'] ) { |
|
1252 | + if ($args['checked']) { |
|
1253 | 1253 | $output .= ' checked '; |
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | // data-attributes |
1257 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
1257 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
1258 | 1258 | |
1259 | 1259 | // aria-attributes |
1260 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
1260 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
1261 | 1261 | |
1262 | 1262 | // extra attributes |
1263 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
1264 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
1263 | + if (!empty($args['extra_attributes'])) { |
|
1264 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | // required |
1268 | - if ( ! empty( $args['required'] ) ) { |
|
1268 | + if (!empty($args['required'])) { |
|
1269 | 1269 | $output .= ' required'; |
1270 | 1270 | } |
1271 | 1271 | |
@@ -1273,38 +1273,38 @@ discard block |
||
1273 | 1273 | $output .= '>'; |
1274 | 1274 | |
1275 | 1275 | // label |
1276 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
1277 | - } elseif ( ! empty( $args['label'] ) ) { |
|
1278 | - $output .= self::label( array( |
|
1276 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
1277 | + } elseif (!empty($args['label'])) { |
|
1278 | + $output .= self::label(array( |
|
1279 | 1279 | 'title' => $args['label'], |
1280 | 1280 | 'for' => $args['id'] . $count, |
1281 | 1281 | 'class' => 'form-check-label' |
1282 | - ), 'radio' ); |
|
1282 | + ), 'radio'); |
|
1283 | 1283 | } |
1284 | 1284 | |
1285 | 1285 | // wrap |
1286 | - if ( ! $args['no_wrap'] ) { |
|
1286 | + if (!$args['no_wrap']) { |
|
1287 | 1287 | $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
1288 | 1288 | |
1289 | 1289 | // Unique wrap class |
1290 | 1290 | $uniq_class = 'fwrap'; |
1291 | - if ( ! empty( $args['name'] ) ) { |
|
1291 | + if (!empty($args['name'])) { |
|
1292 | 1292 | $uniq_class .= '-' . $args['name']; |
1293 | - } else if ( ! empty( $args['id'] ) ) { |
|
1293 | + } else if (!empty($args['id'])) { |
|
1294 | 1294 | $uniq_class .= '-' . $args['id']; |
1295 | 1295 | } |
1296 | 1296 | |
1297 | - if ( isset( $args['value'] ) || $args['value'] !== "" ) { |
|
1297 | + if (isset($args['value']) || $args['value'] !== "") { |
|
1298 | 1298 | $uniq_class .= '-' . $args['value']; |
1299 | 1299 | } else { |
1300 | 1300 | $uniq_class .= '-' . $count; |
1301 | 1301 | } |
1302 | - $wrap_class .= ' ' . sanitize_html_class( $uniq_class ); |
|
1302 | + $wrap_class .= ' ' . sanitize_html_class($uniq_class); |
|
1303 | 1303 | |
1304 | - $output = self::wrap( array( |
|
1304 | + $output = self::wrap(array( |
|
1305 | 1305 | 'content' => $output, |
1306 | 1306 | 'class' => $wrap_class |
1307 | - ) ); |
|
1307 | + )); |
|
1308 | 1308 | } |
1309 | 1309 | |
1310 | 1310 | return $output; |
@@ -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 | global $wp_query, $aui_bs5; |
23 | 23 | |
24 | 24 | $defaults = array( |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | 'mid_size' => 2, |
27 | 27 | 'prev_text' => '<i class="fas fa-chevron-left"></i>', |
28 | 28 | 'next_text' => '<i class="fas fa-chevron-right"></i>', |
29 | - 'screen_reader_text' => __( 'Posts navigation', 'ayecode-connect' ), |
|
29 | + 'screen_reader_text' => __('Posts navigation', 'ayecode-connect'), |
|
30 | 30 | 'before_paging' => '', |
31 | 31 | 'after_paging' => '', |
32 | 32 | 'type' => 'array', |
33 | - 'total' => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1, |
|
33 | + 'total' => isset($wp_query->max_num_pages) ? $wp_query->max_num_pages : 1, |
|
34 | 34 | 'links' => array(), // an array of links if using custom links, this includes the a tag. |
35 | 35 | 'rounded_style' => false, |
36 | 36 | 'custom_next_text' => '', // Custom next page text |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * Parse incoming $args into an array and merge it with $defaults |
42 | 42 | */ |
43 | - $args = wp_parse_args( $args, $defaults ); |
|
43 | + $args = wp_parse_args($args, $defaults); |
|
44 | 44 | |
45 | 45 | $output = ''; |
46 | 46 | |
47 | 47 | // Don't print empty markup if there's only one page. |
48 | - if ( $args['total'] > 1 ) { |
|
48 | + if ($args['total'] > 1) { |
|
49 | 49 | // Set up paginated links. |
50 | - $links = !empty( $args['links'] ) ? $args['links'] : paginate_links( $args ); |
|
50 | + $links = !empty($args['links']) ? $args['links'] : paginate_links($args); |
|
51 | 51 | |
52 | 52 | $class = !empty($args['class']) ? $args['class'] : ''; |
53 | 53 | |
@@ -56,62 +56,62 @@ discard block |
||
56 | 56 | |
57 | 57 | // make the output bootstrap ready |
58 | 58 | $links_html = "<ul class='pagination m-0 p-0 $class'>"; |
59 | - if ( ! empty( $links ) ) { |
|
60 | - foreach ( $links as $link ) { |
|
59 | + if (!empty($links)) { |
|
60 | + foreach ($links as $link) { |
|
61 | 61 | $_link = $link; |
62 | 62 | |
63 | - if ( $aui_bs5 ) { |
|
63 | + if ($aui_bs5) { |
|
64 | 64 | $link_class = $args['rounded_style'] ? 'page-link badge rounded-pill border-0 mx-1 fs-base text-dark link-primary' : 'page-link'; |
65 | 65 | $link_class_active = $args['rounded_style'] ? ' current active fw-bold badge rounded-pill' : ' current active'; |
66 | 66 | $links_html .= "<li class='page-item mx-0'>"; |
67 | - $link = str_replace( array( "page-numbers", " current" ), array( $link_class, $link_class_active ), $link ); |
|
68 | - $link = str_replace( 'text-dark link-primary current', 'current', $link ); |
|
69 | - $links_html .= $link; |
|
67 | + $link = str_replace(array("page-numbers", " current"), array($link_class, $link_class_active), $link); |
|
68 | + $link = str_replace('text-dark link-primary current', 'current', $link); |
|
69 | + $links_html .= $link; |
|
70 | 70 | $links_html .= "</li>"; |
71 | 71 | } else { |
72 | - $active = strpos( $link, 'current' ) !== false ? 'active' : ''; |
|
72 | + $active = strpos($link, 'current') !== false ? 'active' : ''; |
|
73 | 73 | $links_html .= "<li class='page-item $active'>"; |
74 | - $links_html .= str_replace( "page-numbers", "page-link", $link ); |
|
74 | + $links_html .= str_replace("page-numbers", "page-link", $link); |
|
75 | 75 | $links_html .= "</li>"; |
76 | 76 | } |
77 | 77 | |
78 | - if ( strpos( $_link, 'next page-numbers' ) || strpos( $_link, 'prev page-numbers' ) ) { |
|
79 | - $link = str_replace( array( "page-numbers", " current" ), array( 'btn btn-outline-primary rounded' . ( $args['rounded_style'] ? '-pill' : '' ) . ' mx-1 fs-base text-dark link-primary', ' current active fw-bold badge rounded-pill' ), $_link ); |
|
80 | - $link = str_replace( 'text-dark link-primary current', 'current', $link ); |
|
78 | + if (strpos($_link, 'next page-numbers') || strpos($_link, 'prev page-numbers')) { |
|
79 | + $link = str_replace(array("page-numbers", " current"), array('btn btn-outline-primary rounded' . ($args['rounded_style'] ? '-pill' : '') . ' mx-1 fs-base text-dark link-primary', ' current active fw-bold badge rounded-pill'), $_link); |
|
80 | + $link = str_replace('text-dark link-primary current', 'current', $link); |
|
81 | 81 | |
82 | - if ( strpos( $_link, 'next page-numbers' ) && ! empty( $args['custom_next_text'] ) ) { |
|
83 | - $custom_next_link = str_replace( $args['next_text'], $args['custom_next_text'], $link ); |
|
84 | - } else if ( strpos( $_link, 'prev page-numbers' ) && ! empty( $args['custom_prev_text'] ) ) { |
|
85 | - $custom_prev_link = str_replace( $args['prev_text'], $args['custom_prev_text'], $link ); |
|
82 | + if (strpos($_link, 'next page-numbers') && !empty($args['custom_next_text'])) { |
|
83 | + $custom_next_link = str_replace($args['next_text'], $args['custom_next_text'], $link); |
|
84 | + } else if (strpos($_link, 'prev page-numbers') && !empty($args['custom_prev_text'])) { |
|
85 | + $custom_prev_link = str_replace($args['prev_text'], $args['custom_prev_text'], $link); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | } |
89 | 89 | } |
90 | 90 | $links_html .= "</ul>"; |
91 | 91 | |
92 | - if ( $links ) { |
|
92 | + if ($links) { |
|
93 | 93 | $output .= '<section class="px-0 py-2 w-100">'; |
94 | - $output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] ); |
|
94 | + $output .= _navigation_markup($links_html, 'aui-pagination', $args['screen_reader_text']); |
|
95 | 95 | $output .= '</section>'; |
96 | 96 | } |
97 | 97 | |
98 | - $output = str_replace( "screen-reader-text", "screen-reader-text sr-only" . ( $aui_bs5 ? ' visually-hidden' : '' ), $output ); |
|
99 | - $output = str_replace( "nav-links", "aui-nav-links", $output ); |
|
98 | + $output = str_replace("screen-reader-text", "screen-reader-text sr-only" . ($aui_bs5 ? ' visually-hidden' : ''), $output); |
|
99 | + $output = str_replace("nav-links", "aui-nav-links", $output); |
|
100 | 100 | } |
101 | 101 | |
102 | - if ( $output ) { |
|
103 | - if ( $custom_next_link || $custom_prev_link ) { |
|
104 | - $total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1; |
|
105 | - $current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1; |
|
102 | + if ($output) { |
|
103 | + if ($custom_next_link || $custom_prev_link) { |
|
104 | + $total = isset($wp_query->max_num_pages) ? $wp_query->max_num_pages : 1; |
|
105 | + $current = get_query_var('paged') ? (int) get_query_var('paged') : 1; |
|
106 | 106 | |
107 | 107 | $output = '<div class="row d-flex align-items-center justify-content-between"><div class="col text-start">' . $custom_prev_link . '</div><div class="col text-center d-none d-md-block">' . $output . '</div><div class="col text-center d-md-none">' . $current . '/' . $args['total'] . '</div><div class="col text-end">' . $custom_next_link . '</div></div>'; |
108 | 108 | } |
109 | 109 | |
110 | - if ( ! empty( $args['before_paging'] ) ) { |
|
110 | + if (!empty($args['before_paging'])) { |
|
111 | 111 | $output = $args['before_paging'] . $output; |
112 | 112 | } |
113 | 113 | |
114 | - if ( ! empty( $args['after_paging'] ) ) { |
|
114 | + if (!empty($args['after_paging'])) { |
|
115 | 115 | $output = $output . $args['after_paging']; |
116 | 116 | } |
117 | 117 | } |
@@ -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 | |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @return string |
21 | 21 | */ |
22 | - public static function name( $text, $multiple = false ) { |
|
22 | + public static function name($text, $multiple = false) { |
|
23 | 23 | $output = ''; |
24 | 24 | |
25 | - if ( $text ) { |
|
26 | - $is_multiple = strpos( $text, '[' ) === false && $multiple ? '[]' : ''; |
|
27 | - $output = ' name="' . esc_attr( $text ) . $is_multiple . '" '; |
|
25 | + if ($text) { |
|
26 | + $is_multiple = strpos($text, '[') === false && $multiple ? '[]' : ''; |
|
27 | + $output = ' name="' . esc_attr($text) . $is_multiple . '" '; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | return $output; |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @return string The sanitized item. |
39 | 39 | */ |
40 | - public static function id( $text ) { |
|
40 | + public static function id($text) { |
|
41 | 41 | $output = ''; |
42 | 42 | |
43 | - if ( $text ) { |
|
44 | - $output = ' id="' . sanitize_html_class( $text ) . '" '; |
|
43 | + if ($text) { |
|
44 | + $output = ' id="' . sanitize_html_class($text) . '" '; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | return $output; |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return string The sanitized item. |
56 | 56 | */ |
57 | - public static function title( $text ) { |
|
57 | + public static function title($text) { |
|
58 | 58 | $output = ''; |
59 | 59 | |
60 | - if ( $text ) { |
|
61 | - $output = ' title="' . esc_attr( $text ) . '" '; |
|
60 | + if ($text) { |
|
61 | + $output = ' title="' . esc_attr($text) . '" '; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | return $output; |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return string The sanitized item. |
73 | 73 | */ |
74 | - public static function value( $text ) { |
|
74 | + public static function value($text) { |
|
75 | 75 | $output = ''; |
76 | 76 | |
77 | - if ( $text !== null && $text !== false ) { |
|
78 | - $output = ' value="' . esc_attr( wp_unslash( $text ) ) . '" '; |
|
77 | + if ($text !== null && $text !== false) { |
|
78 | + $output = ' value="' . esc_attr(wp_unslash($text)) . '" '; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | return $output; |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string The sanitized item. |
90 | 90 | */ |
91 | - public static function class_attr( $text ) { |
|
91 | + public static function class_attr($text) { |
|
92 | 92 | $output = ''; |
93 | 93 | |
94 | - if ( $text ) { |
|
95 | - $classes = self::esc_classes( $text ); |
|
96 | - if ( ! empty( $classes ) ) { |
|
94 | + if ($text) { |
|
95 | + $classes = self::esc_classes($text); |
|
96 | + if (!empty($classes)) { |
|
97 | 97 | $output = ' class="' . $classes . '" '; |
98 | 98 | } |
99 | 99 | } |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return string |
110 | 110 | */ |
111 | - public static function esc_classes( $text ) { |
|
111 | + public static function esc_classes($text) { |
|
112 | 112 | $output = ''; |
113 | 113 | |
114 | - if ( $text ) { |
|
115 | - $classes = explode( " ", $text ); |
|
116 | - $classes = array_map( "trim", $classes ); |
|
117 | - $classes = array_map( "sanitize_html_class", $classes ); |
|
118 | - if ( ! empty( $classes ) ) { |
|
119 | - $output = implode( " ", array_filter( $classes ) ); |
|
114 | + if ($text) { |
|
115 | + $classes = explode(" ", $text); |
|
116 | + $classes = array_map("trim", $classes); |
|
117 | + $classes = array_map("sanitize_html_class", $classes); |
|
118 | + if (!empty($classes)) { |
|
119 | + $output = implode(" ", array_filter($classes)); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return string |
131 | 131 | */ |
132 | - public static function data_attributes( $args ) { |
|
132 | + public static function data_attributes($args) { |
|
133 | 133 | $output = ''; |
134 | 134 | |
135 | - if ( ! empty( $args ) ) { |
|
135 | + if (!empty($args)) { |
|
136 | 136 | |
137 | - foreach ( $args as $key => $val ) { |
|
138 | - if ( substr( $key, 0, 5 ) === "data-" ) { |
|
139 | - $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" '; |
|
137 | + foreach ($args as $key => $val) { |
|
138 | + if (substr($key, 0, 5) === "data-") { |
|
139 | + $output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" '; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | } |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @return string |
151 | 151 | */ |
152 | - public static function aria_attributes( $args ) { |
|
152 | + public static function aria_attributes($args) { |
|
153 | 153 | $output = ''; |
154 | 154 | |
155 | - if ( ! empty( $args ) ) { |
|
155 | + if (!empty($args)) { |
|
156 | 156 | |
157 | - foreach ( $args as $key => $val ) { |
|
158 | - if ( substr( $key, 0, 5 ) === "aria-" ) { |
|
159 | - $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" '; |
|
157 | + foreach ($args as $key => $val) { |
|
158 | + if (substr($key, 0, 5) === "aria-") { |
|
159 | + $output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" '; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | } |
@@ -173,19 +173,19 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return string |
175 | 175 | */ |
176 | - public static function icon( $class, $space_after = false, $extra_attributes = array() ) { |
|
176 | + public static function icon($class, $space_after = false, $extra_attributes = array()) { |
|
177 | 177 | $output = ''; |
178 | 178 | |
179 | - if ( $class ) { |
|
180 | - $classes = self::esc_classes( $class ); |
|
181 | - if ( ! empty( $classes ) ) { |
|
179 | + if ($class) { |
|
180 | + $classes = self::esc_classes($class); |
|
181 | + if (!empty($classes)) { |
|
182 | 182 | $output = '<i class="' . $classes . '" '; |
183 | 183 | // extra attributes |
184 | - if ( ! empty( $extra_attributes ) ) { |
|
185 | - $output .= AUI_Component_Helper::extra_attributes( $extra_attributes ); |
|
184 | + if (!empty($extra_attributes)) { |
|
185 | + $output .= AUI_Component_Helper::extra_attributes($extra_attributes); |
|
186 | 186 | } |
187 | 187 | $output .= '></i>'; |
188 | - if ( $space_after ) { |
|
188 | + if ($space_after) { |
|
189 | 189 | $output .= " "; |
190 | 190 | } |
191 | 191 | } |
@@ -199,14 +199,14 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public static function extra_attributes( $args ) { |
|
202 | + public static function extra_attributes($args) { |
|
203 | 203 | $output = ''; |
204 | 204 | |
205 | - if ( ! empty( $args ) ) { |
|
205 | + if (!empty($args)) { |
|
206 | 206 | |
207 | - if ( is_array( $args ) ) { |
|
208 | - foreach ( $args as $key => $val ) { |
|
209 | - $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" '; |
|
207 | + if (is_array($args)) { |
|
208 | + foreach ($args as $key => $val) { |
|
209 | + $output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" '; |
|
210 | 210 | } |
211 | 211 | } else { |
212 | 212 | $output .= ' ' . $args . ' '; |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return string |
224 | 224 | */ |
225 | - public static function help_text( $text ) { |
|
225 | + public static function help_text($text) { |
|
226 | 226 | $output = ''; |
227 | 227 | |
228 | - if ( $text ) { |
|
229 | - $output .= '<small class="form-text text-muted d-block">' . wp_kses_post( $text ) . '</small>'; |
|
228 | + if ($text) { |
|
229 | + $output .= '<small class="form-text text-muted d-block">' . wp_kses_post($text) . '</small>'; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
@@ -240,17 +240,17 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return string|void |
242 | 242 | */ |
243 | - public static function element_require( $input ) { |
|
243 | + public static function element_require($input) { |
|
244 | 244 | |
245 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
245 | + $input = str_replace("'", '"', $input); // we only want double quotes |
|
246 | 246 | |
247 | - $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array( |
|
247 | + $output = esc_attr(str_replace(array("[%", "%]", "%:checked]"), array( |
|
248 | 248 | "jQuery(form).find('[data-argument=\"", |
249 | 249 | "\"]').find('input,select,textarea').val()", |
250 | 250 | "\"]').find('input:checked').val()", |
251 | - ), $input ) ); |
|
251 | + ), $input)); |
|
252 | 252 | |
253 | - if ( $output ) { |
|
253 | + if ($output) { |
|
254 | 254 | $output = ' data-element-require="' . $output . '" '; |
255 | 255 | } |
256 | 256 | |
@@ -267,21 +267,21 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @return mixed Stripped value. |
269 | 269 | */ |
270 | - public static function sanitize_html_field( $value, $input = array() ) { |
|
270 | + public static function sanitize_html_field($value, $input = array()) { |
|
271 | 271 | $original = $value; |
272 | 272 | |
273 | - if ( is_array( $value ) ) { |
|
274 | - foreach ( $value as $index => $item ) { |
|
275 | - $value[ $index ] = self::_sanitize_html_field( $value, $input ); |
|
273 | + if (is_array($value)) { |
|
274 | + foreach ($value as $index => $item) { |
|
275 | + $value[$index] = self::_sanitize_html_field($value, $input); |
|
276 | 276 | } |
277 | - } elseif ( is_object( $value ) ) { |
|
278 | - $object_vars = get_object_vars( $value ); |
|
277 | + } elseif (is_object($value)) { |
|
278 | + $object_vars = get_object_vars($value); |
|
279 | 279 | |
280 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
281 | - $value->$property_name = self::_sanitize_html_field( $property_value, $input ); |
|
280 | + foreach ($object_vars as $property_name => $property_value) { |
|
281 | + $value->$property_name = self::_sanitize_html_field($property_value, $input); |
|
282 | 282 | } |
283 | 283 | } else { |
284 | - $value = self::_sanitize_html_field( $value, $input ); |
|
284 | + $value = self::_sanitize_html_field($value, $input); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @param string|array $value Original content without filter. |
294 | 294 | * @param array $input Input Field. |
295 | 295 | */ |
296 | - return apply_filters( 'ayecode_ui_sanitize_html_field', $value, $original, $input ); |
|
296 | + return apply_filters('ayecode_ui_sanitize_html_field', $value, $original, $input); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -316,20 +316,20 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @return string Filtered content with only allowed HTML elements. |
318 | 318 | */ |
319 | - public static function _sanitize_html_field( $value, $input = array() ) { |
|
320 | - if ( $value === '' ) { |
|
319 | + public static function _sanitize_html_field($value, $input = array()) { |
|
320 | + if ($value === '') { |
|
321 | 321 | return $value; |
322 | 322 | } |
323 | 323 | |
324 | - $allowed_html = self::kses_allowed_html( 'post', $input ); |
|
324 | + $allowed_html = self::kses_allowed_html('post', $input); |
|
325 | 325 | |
326 | - if ( ! is_array( $allowed_html ) ) { |
|
327 | - $allowed_html = wp_kses_allowed_html( 'post' ); |
|
326 | + if (!is_array($allowed_html)) { |
|
327 | + $allowed_html = wp_kses_allowed_html('post'); |
|
328 | 328 | } |
329 | 329 | |
330 | - $filtered = trim( wp_unslash( $value ) ); |
|
331 | - $filtered = wp_kses( $filtered, $allowed_html ); |
|
332 | - $filtered = balanceTags( $filtered ); // Balances tags |
|
330 | + $filtered = trim(wp_unslash($value)); |
|
331 | + $filtered = wp_kses($filtered, $allowed_html); |
|
332 | + $filtered = balanceTags($filtered); // Balances tags |
|
333 | 333 | |
334 | 334 | return $filtered; |
335 | 335 | } |
@@ -346,12 +346,12 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @return array Array of allowed HTML tags and their allowed attributes. |
348 | 348 | */ |
349 | - public static function kses_allowed_html( $context = 'post', $input = array() ) { |
|
350 | - $allowed_html = wp_kses_allowed_html( $context ); |
|
349 | + public static function kses_allowed_html($context = 'post', $input = array()) { |
|
350 | + $allowed_html = wp_kses_allowed_html($context); |
|
351 | 351 | |
352 | - if ( is_array( $allowed_html ) ) { |
|
352 | + if (is_array($allowed_html)) { |
|
353 | 353 | // <iframe> |
354 | - if ( ! isset( $allowed_html['iframe'] ) && $context == 'post' ) { |
|
354 | + if (!isset($allowed_html['iframe']) && $context == 'post') { |
|
355 | 355 | $allowed_html['iframe'] = array( |
356 | 356 | 'class' => true, |
357 | 357 | 'id' => true, |
@@ -380,23 +380,23 @@ discard block |
||
380 | 380 | * @param @param string|array $context The context for which to retrieve tags. |
381 | 381 | * @param array $input Input field. |
382 | 382 | */ |
383 | - return apply_filters( 'ayecode_ui_kses_allowed_html', $allowed_html, $context, $input ); |
|
383 | + return apply_filters('ayecode_ui_kses_allowed_html', $allowed_html, $context, $input); |
|
384 | 384 | } |
385 | 385 | |
386 | - public static function get_column_class( $label_number = 2, $type = 'label' ) { |
|
386 | + public static function get_column_class($label_number = 2, $type = 'label') { |
|
387 | 387 | |
388 | 388 | $class = ''; |
389 | 389 | |
390 | 390 | // set default if empty |
391 | - if( $label_number === '' ){ |
|
391 | + if ($label_number === '') { |
|
392 | 392 | $label_number = 2; |
393 | 393 | } |
394 | 394 | |
395 | - if ( $label_number && $label_number < 12 && $label_number > 0 ) { |
|
396 | - if ( $type == 'label' ) { |
|
397 | - $class = 'col-sm-' . absint( $label_number ); |
|
398 | - } elseif ( $type == 'input' ) { |
|
399 | - $class = 'col-sm-' . ( 12 - absint( $label_number ) ); |
|
395 | + if ($label_number && $label_number < 12 && $label_number > 0) { |
|
396 | + if ($type == 'label') { |
|
397 | + $class = 'col-sm-' . absint($label_number); |
|
398 | + } elseif ($type == 'input') { |
|
399 | + $class = 'col-sm-' . (12 - absint($label_number)); |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | * @param string $str String to sanitize. |
416 | 416 | * @return string Sanitized string. |
417 | 417 | */ |
418 | - public static function sanitize_textarea_field( $str ) { |
|
419 | - $filtered = self::_sanitize_text_fields( $str, true ); |
|
418 | + public static function sanitize_textarea_field($str) { |
|
419 | + $filtered = self::_sanitize_text_fields($str, true); |
|
420 | 420 | |
421 | 421 | /** |
422 | 422 | * Filters a sanitized textarea field string. |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @param string $filtered The sanitized string. |
427 | 427 | * @param string $str The string prior to being sanitized. |
428 | 428 | */ |
429 | - return apply_filters( 'sanitize_textarea_field', $filtered, $str ); |
|
429 | + return apply_filters('sanitize_textarea_field', $filtered, $str); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -439,40 +439,40 @@ discard block |
||
439 | 439 | * @param bool $keep_newlines Optional. Whether to keep newlines. Default: false. |
440 | 440 | * @return string Sanitized string. |
441 | 441 | */ |
442 | - public static function _sanitize_text_fields( $str, $keep_newlines = false ) { |
|
443 | - if ( is_object( $str ) || is_array( $str ) ) { |
|
442 | + public static function _sanitize_text_fields($str, $keep_newlines = false) { |
|
443 | + if (is_object($str) || is_array($str)) { |
|
444 | 444 | return ''; |
445 | 445 | } |
446 | 446 | |
447 | 447 | $str = (string) $str; |
448 | 448 | |
449 | - $filtered = wp_check_invalid_utf8( $str ); |
|
449 | + $filtered = wp_check_invalid_utf8($str); |
|
450 | 450 | |
451 | - if ( strpos( $filtered, '<' ) !== false ) { |
|
452 | - $filtered = wp_pre_kses_less_than( $filtered ); |
|
451 | + if (strpos($filtered, '<') !== false) { |
|
452 | + $filtered = wp_pre_kses_less_than($filtered); |
|
453 | 453 | // This will strip extra whitespace for us. |
454 | - $filtered = wp_strip_all_tags( $filtered, false ); |
|
454 | + $filtered = wp_strip_all_tags($filtered, false); |
|
455 | 455 | |
456 | 456 | // Use HTML entities in a special case to make sure no later |
457 | 457 | // newline stripping stage could lead to a functional tag. |
458 | - $filtered = str_replace( "<\n", "<\n", $filtered ); |
|
458 | + $filtered = str_replace("<\n", "<\n", $filtered); |
|
459 | 459 | } |
460 | 460 | |
461 | - if ( ! $keep_newlines ) { |
|
462 | - $filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered ); |
|
461 | + if (!$keep_newlines) { |
|
462 | + $filtered = preg_replace('/[\r\n\t ]+/', ' ', $filtered); |
|
463 | 463 | } |
464 | - $filtered = trim( $filtered ); |
|
464 | + $filtered = trim($filtered); |
|
465 | 465 | |
466 | 466 | $found = false; |
467 | - while ( preg_match( '`[^%](%[a-f0-9]{2})`i', $filtered, $match ) ) { |
|
468 | - $filtered = str_replace( $match[1], '', $filtered ); |
|
467 | + while (preg_match('`[^%](%[a-f0-9]{2})`i', $filtered, $match)) { |
|
468 | + $filtered = str_replace($match[1], '', $filtered); |
|
469 | 469 | $found = true; |
470 | 470 | } |
471 | - unset( $match ); |
|
471 | + unset($match); |
|
472 | 472 | |
473 | - if ( $found ) { |
|
473 | + if ($found) { |
|
474 | 474 | // Strip out the whitespace that may now exist after removing the octets. |
475 | - $filtered = trim( preg_replace( '` +`', ' ', $filtered ) ); |
|
475 | + $filtered = trim(preg_replace('` +`', ' ', $filtered)); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | return $filtered; |
@@ -485,15 +485,15 @@ discard block |
||
485 | 485 | * @param array $args Extra args. |
486 | 486 | * @return string Sanitized icon. |
487 | 487 | */ |
488 | - public static function sanitize_fa_icon( $icon, $args = array() ) { |
|
489 | - if ( ! is_scalar( $icon ) ) { |
|
488 | + public static function sanitize_fa_icon($icon, $args = array()) { |
|
489 | + if (!is_scalar($icon)) { |
|
490 | 490 | return ""; |
491 | 491 | } |
492 | 492 | |
493 | 493 | $pattern = '/[^0-9a-zA-Z\-_ ]/'; |
494 | 494 | |
495 | - $sanitized_icon = preg_replace( $pattern, '', trim( $icon ) ); |
|
495 | + $sanitized_icon = preg_replace($pattern, '', trim($icon)); |
|
496 | 496 | |
497 | - return apply_filters( 'ayecode_ui_sanitize_fa_icon', $sanitized_icon, $icon, $args ); |
|
497 | + return apply_filters('ayecode_ui_sanitize_fa_icon', $sanitized_icon, $icon, $args); |
|
498 | 498 | } |
499 | 499 | } |
500 | 500 | \ No newline at end of file |
@@ -6,39 +6,39 @@ |
||
6 | 6 | /** |
7 | 7 | * Bail if we are not in WP. |
8 | 8 | */ |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Set the version only if its the current newest while loading. |
15 | 15 | */ |
16 | -add_action('after_setup_theme', function () { |
|
17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
16 | +add_action('after_setup_theme', function() { |
|
17 | + global $ayecode_ui_version, $ayecode_ui_file_key; |
|
18 | 18 | $this_version = "0.2.40"; |
19 | - if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | - $ayecode_ui_version = $this_version ; |
|
21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
19 | + if (empty($ayecode_ui_version) || version_compare($this_version, $ayecode_ui_version, '>')) { |
|
20 | + $ayecode_ui_version = $this_version; |
|
21 | + $ayecode_ui_file_key = wp_hash(__FILE__); |
|
22 | 22 | } |
23 | 23 | },0); |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
27 | 27 | */ |
28 | -add_action('after_setup_theme', function () { |
|
28 | +add_action('after_setup_theme', function() { |
|
29 | 29 | global $ayecode_ui_file_key; |
30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
30 | + if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) { |
|
31 | + include_once(dirname(__FILE__) . '/includes/class-aui.php'); |
|
32 | + include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php'); |
|
33 | 33 | } |
34 | 34 | },1); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Add the function that calls the class. |
38 | 38 | */ |
39 | -if(!function_exists('aui')){ |
|
40 | - function aui(){ |
|
41 | - if(!class_exists("AUI",false)){ |
|
39 | +if (!function_exists('aui')) { |
|
40 | + function aui() { |
|
41 | + if (!class_exists("AUI", false)) { |
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 | return AUI::instance(); |
@@ -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( 'WP_Font_Awesome_Settings' ) ) { |
|
22 | +if (!class_exists('WP_Font_Awesome_Settings')) { |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -82,19 +82,19 @@ discard block |
||
82 | 82 | * @return WP_Font_Awesome_Settings - Main instance. |
83 | 83 | */ |
84 | 84 | public static function instance() { |
85 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) { |
|
85 | + if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) { |
|
86 | 86 | self::$instance = new WP_Font_Awesome_Settings; |
87 | 87 | |
88 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
88 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
89 | 89 | |
90 | - if ( is_admin() ) { |
|
91 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
92 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
93 | - add_action( 'admin_init', array( self::$instance, 'constants' ) ); |
|
94 | - add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) ); |
|
90 | + if (is_admin()) { |
|
91 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
92 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
93 | + add_action('admin_init', array(self::$instance, 'constants')); |
|
94 | + add_action('admin_notices', array(self::$instance, 'admin_notices')); |
|
95 | 95 | } |
96 | 96 | |
97 | - do_action( 'wp_font_awesome_settings_loaded' ); |
|
97 | + do_action('wp_font_awesome_settings_loaded'); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | return self::$instance; |
@@ -105,26 +105,26 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return void |
107 | 107 | */ |
108 | - public function constants(){ |
|
108 | + public function constants() { |
|
109 | 109 | |
110 | 110 | // register iconpicker constant |
111 | - if ( ! defined( 'FAS_ICONPICKER_JS_URL' ) ) { |
|
111 | + if (!defined('FAS_ICONPICKER_JS_URL')) { |
|
112 | 112 | $url = $this->get_path_url(); |
113 | 113 | $version = $this->settings['version']; |
114 | 114 | |
115 | - if( !$version || version_compare($version,'5.999','>')){ |
|
115 | + if (!$version || version_compare($version, '5.999', '>')) { |
|
116 | 116 | $url .= 'assets/js/fa-iconpicker-v6.min.js'; |
117 | - }else{ |
|
117 | + } else { |
|
118 | 118 | $url .= 'assets/js/fa-iconpicker-v5.min.js'; |
119 | 119 | } |
120 | 120 | |
121 | - define( 'FAS_ICONPICKER_JS_URL', $url ); |
|
121 | + define('FAS_ICONPICKER_JS_URL', $url); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | |
125 | 125 | // Set a constant if pro enabled |
126 | - if ( ! defined( 'FAS_PRO' ) && $this->settings['pro'] ) { |
|
127 | - define( 'FAS_PRO', true ); |
|
126 | + if (!defined('FAS_PRO') && $this->settings['pro']) { |
|
127 | + define('FAS_PRO', true); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -134,19 +134,19 @@ discard block |
||
134 | 134 | * @return string |
135 | 135 | */ |
136 | 136 | public function get_path_url() { |
137 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
138 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
137 | + $content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR)); |
|
138 | + $content_url = untrailingslashit(WP_CONTENT_URL); |
|
139 | 139 | |
140 | 140 | // Replace http:// to https://. |
141 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
142 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
141 | + if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) { |
|
142 | + $content_url = str_replace('http://', 'https://', $content_url); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // Check if we are inside a plugin |
146 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
147 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
146 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
147 | + $url = str_replace($content_dir, $content_url, $file_dir); |
|
148 | 148 | |
149 | - return trailingslashit( $url ); |
|
149 | + return trailingslashit($url); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -156,53 +156,53 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function init() { |
158 | 158 | // Download fontawesome locally. |
159 | - add_action( 'add_option_wp-font-awesome-settings', array( $this, 'add_option_wp_font_awesome_settings' ), 10, 2 ); |
|
160 | - add_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 ); |
|
159 | + add_action('add_option_wp-font-awesome-settings', array($this, 'add_option_wp_font_awesome_settings'), 10, 2); |
|
160 | + add_action('update_option_wp-font-awesome-settings', array($this, 'update_option_wp_font_awesome_settings'), 10, 2); |
|
161 | 161 | |
162 | 162 | $this->settings = $this->get_settings(); |
163 | 163 | |
164 | 164 | // Check if the official plugin is active and use that instead if so. |
165 | - if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) { |
|
166 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
167 | - add_action( 'admin_head', array( $this, 'add_generator' ), 99 ); |
|
165 | + if (!defined('FONTAWESOME_PLUGIN_FILE')) { |
|
166 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') { |
|
167 | + add_action('admin_head', array($this, 'add_generator'), 99); |
|
168 | 168 | } |
169 | 169 | |
170 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
171 | - add_action( 'wp_head', array( $this, 'add_generator' ), 99 ); |
|
170 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') { |
|
171 | + add_action('wp_head', array($this, 'add_generator'), 99); |
|
172 | 172 | } |
173 | 173 | |
174 | - if ( $this->settings['type'] == 'CSS' ) { |
|
175 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
176 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
174 | + if ($this->settings['type'] == 'CSS') { |
|
175 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') { |
|
176 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000); |
|
177 | 177 | //add_action( 'wp_footer', array( $this, 'enqueue_style' ), 5000 ); // not sure why this was added, seems to break frontend |
178 | 178 | } |
179 | 179 | |
180 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
181 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
182 | - add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_styles' ), 10, 2 ); |
|
180 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') { |
|
181 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000); |
|
182 | + add_filter('block_editor_settings_all', array($this, 'enqueue_editor_styles'), 10, 2); |
|
183 | 183 | } |
184 | 184 | } else { |
185 | 185 | $enqueue = false; |
186 | 186 | |
187 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
187 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') { |
|
188 | 188 | $enqueue = true; |
189 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
189 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); |
|
190 | 190 | } |
191 | 191 | |
192 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
192 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') { |
|
193 | 193 | $enqueue = true; |
194 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
195 | - add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 ); |
|
194 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); |
|
195 | + add_filter('block_editor_settings_all', array($this, 'enqueue_editor_scripts'), 10, 2); |
|
196 | 196 | } |
197 | 197 | |
198 | - if ( $enqueue ) { |
|
199 | - add_filter( 'script_loader_tag', array( $this, 'script_loader_tag' ), 20, 3 ); |
|
198 | + if ($enqueue) { |
|
199 | + add_filter('script_loader_tag', array($this, 'script_loader_tag'), 20, 3); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | 203 | // remove font awesome if set to do so |
204 | - if ( $this->settings['dequeue'] == '1' ) { |
|
205 | - add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 ); |
|
204 | + if ($this->settings['dequeue'] == '1') { |
|
205 | + add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return array |
218 | 218 | */ |
219 | - public function enqueue_editor_styles( $editor_settings, $block_editor_context ){ |
|
219 | + public function enqueue_editor_styles($editor_settings, $block_editor_context) { |
|
220 | 220 | |
221 | - if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) { |
|
221 | + if (!empty($editor_settings['__unstableResolvedAssets']['styles'])) { |
|
222 | 222 | $url = $this->get_url(); |
223 | 223 | $editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css' href='$url' media='all' />"; |
224 | 224 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return array |
236 | 236 | */ |
237 | - public function enqueue_editor_scripts( $editor_settings, $block_editor_context ) { |
|
237 | + public function enqueue_editor_scripts($editor_settings, $block_editor_context) { |
|
238 | 238 | $url = $this->get_url(); |
239 | 239 | |
240 | 240 | $editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js' defer crossorigin='anonymous'></script>"; |
@@ -248,22 +248,22 @@ discard block |
||
248 | 248 | public function enqueue_style() { |
249 | 249 | // build url |
250 | 250 | $url = $this->get_url(); |
251 | - $version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null; |
|
251 | + $version = !empty($this->settings['local']) && empty($this->settings['pro']) ? strip_tags($this->settings['local_version']) : null; |
|
252 | 252 | |
253 | - wp_deregister_style( 'font-awesome' ); // deregister in case its already there |
|
254 | - wp_register_style( 'font-awesome', $url, array(), $version ); |
|
255 | - wp_enqueue_style( 'font-awesome' ); |
|
253 | + wp_deregister_style('font-awesome'); // deregister in case its already there |
|
254 | + wp_register_style('font-awesome', $url, array(), $version); |
|
255 | + wp_enqueue_style('font-awesome'); |
|
256 | 256 | |
257 | 257 | // RTL language support CSS. |
258 | - if ( is_rtl() ) { |
|
259 | - wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() ); |
|
258 | + if (is_rtl()) { |
|
259 | + wp_add_inline_style('font-awesome', $this->rtl_inline_css()); |
|
260 | 260 | } |
261 | 261 | |
262 | - if ( $this->settings['shims'] ) { |
|
263 | - $url = $this->get_url( true ); |
|
264 | - wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there |
|
265 | - wp_register_style( 'font-awesome-shims', $url, array(), $version ); |
|
266 | - wp_enqueue_style( 'font-awesome-shims' ); |
|
262 | + if ($this->settings['shims']) { |
|
263 | + $url = $this->get_url(true); |
|
264 | + wp_deregister_style('font-awesome-shims'); // deregister in case its already there |
|
265 | + wp_register_style('font-awesome-shims', $url, array(), $version); |
|
266 | + wp_enqueue_style('font-awesome-shims'); |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
@@ -275,15 +275,15 @@ discard block |
||
275 | 275 | $url = $this->get_url(); |
276 | 276 | |
277 | 277 | $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script'; |
278 | - call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there |
|
279 | - wp_register_script( 'font-awesome', $url, array(), null ); |
|
280 | - wp_enqueue_script( 'font-awesome' ); |
|
281 | - |
|
282 | - if ( $this->settings['shims'] ) { |
|
283 | - $url = $this->get_url( true ); |
|
284 | - call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there |
|
285 | - wp_register_script( 'font-awesome-shims', $url, array(), null ); |
|
286 | - wp_enqueue_script( 'font-awesome-shims' ); |
|
278 | + call_user_func($deregister_function, 'font-awesome'); // deregister in case its already there |
|
279 | + wp_register_script('font-awesome', $url, array(), null); |
|
280 | + wp_enqueue_script('font-awesome'); |
|
281 | + |
|
282 | + if ($this->settings['shims']) { |
|
283 | + $url = $this->get_url(true); |
|
284 | + call_user_func($deregister_function, 'font-awesome-shims'); // deregister in case its already there |
|
285 | + wp_register_script('font-awesome-shims', $url, array(), null); |
|
286 | + wp_enqueue_script('font-awesome-shims'); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
@@ -295,16 +295,16 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @return string The url to the file. |
297 | 297 | */ |
298 | - public function get_url( $shims = false, $local = true ) { |
|
298 | + public function get_url($shims = false, $local = true) { |
|
299 | 299 | $script = $shims ? 'v4-shims' : 'all'; |
300 | 300 | $sub = $this->settings['pro'] ? 'pro' : 'use'; |
301 | 301 | $type = $this->settings['type']; |
302 | 302 | $version = $this->settings['version']; |
303 | - $kit_url = $this->settings['kit-url'] ? sanitize_text_field( $this->settings['kit-url'] ) : ''; |
|
303 | + $kit_url = $this->settings['kit-url'] ? sanitize_text_field($this->settings['kit-url']) : ''; |
|
304 | 304 | $url = ''; |
305 | 305 | |
306 | - if ( $type == 'KIT' && $kit_url ) { |
|
307 | - if ( $shims ) { |
|
306 | + if ($type == 'KIT' && $kit_url) { |
|
307 | + if ($shims) { |
|
308 | 308 | // if its a kit then we don't add shims here |
309 | 309 | return ''; |
310 | 310 | } |
@@ -313,13 +313,13 @@ discard block |
||
313 | 313 | } else { |
314 | 314 | $v = ''; |
315 | 315 | // Check and load locally. |
316 | - if ( $local && $this->has_local() ) { |
|
316 | + if ($local && $this->has_local()) { |
|
317 | 317 | $script .= ".min"; |
318 | - $v .= '&ver=' . strip_tags( $this->settings['local_version'] ); |
|
318 | + $v .= '&ver=' . strip_tags($this->settings['local_version']); |
|
319 | 319 | $url .= $this->get_fonts_url(); // Local fonts url. |
320 | 320 | } else { |
321 | 321 | $url .= "https://$sub.fontawesome.com/releases/"; // CDN |
322 | - $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
322 | + $url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
323 | 323 | } |
324 | 324 | $url .= $type == 'CSS' ? 'css/' : 'js/'; // type |
325 | 325 | $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type |
@@ -340,16 +340,16 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @return string The filtered url. |
342 | 342 | */ |
343 | - public function remove_font_awesome( $url, $original_url, $_context ) { |
|
343 | + public function remove_font_awesome($url, $original_url, $_context) { |
|
344 | 344 | |
345 | - if ( $_context == 'display' |
|
346 | - && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false ) |
|
347 | - && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false ) |
|
345 | + if ($_context == 'display' |
|
346 | + && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false) |
|
347 | + && (strstr($url, ".js") !== false || strstr($url, ".css") !== false) |
|
348 | 348 | ) {// it's a font-awesome-url (probably) |
349 | 349 | |
350 | - if ( strstr( $url, "wpfas=true" ) !== false ) { |
|
351 | - if ( $this->settings['type'] == 'JS' ) { |
|
352 | - if ( $this->settings['js-pseudo'] ) { |
|
350 | + if (strstr($url, "wpfas=true") !== false) { |
|
351 | + if ($this->settings['type'] == 'JS') { |
|
352 | + if ($this->settings['js-pseudo']) { |
|
353 | 353 | $url .= "' data-search-pseudo-elements defer='defer"; |
354 | 354 | } else { |
355 | 355 | $url .= "' defer='defer"; |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * Register the database settings with WordPress. |
369 | 369 | */ |
370 | 370 | public function register_settings() { |
371 | - register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' ); |
|
371 | + register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings'); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -377,10 +377,10 @@ discard block |
||
377 | 377 | */ |
378 | 378 | public function menu_item() { |
379 | 379 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
380 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
380 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
381 | 381 | $this, |
382 | 382 | 'settings_page' |
383 | - ) ); |
|
383 | + )); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * @return array The array of settings. |
390 | 390 | */ |
391 | 391 | public function get_settings() { |
392 | - $db_settings = get_option( 'wp-font-awesome-settings' ); |
|
392 | + $db_settings = get_option('wp-font-awesome-settings'); |
|
393 | 393 | |
394 | 394 | $defaults = array( |
395 | 395 | 'type' => 'CSS', // type to use, CSS or JS or KIT |
@@ -404,30 +404,30 @@ discard block |
||
404 | 404 | 'kit-url' => '', // the kit url |
405 | 405 | ); |
406 | 406 | |
407 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
407 | + $settings = wp_parse_args($db_settings, $defaults); |
|
408 | 408 | |
409 | 409 | /** |
410 | 410 | * Filter the Font Awesome settings. |
411 | 411 | * |
412 | 412 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
413 | 413 | */ |
414 | - return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults ); |
|
414 | + return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
418 | 418 | * The settings page html output. |
419 | 419 | */ |
420 | 420 | public function settings_page() { |
421 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
422 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) ); |
|
421 | + if (!current_user_can('manage_options')) { |
|
422 | + wp_die(__('You do not have sufficient permissions to access this page.', 'ayecode-connect')); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | // a hidden way to force the update of the version number via api instead of waiting the 48 hours |
426 | - if ( isset( $_REQUEST['force-version-check'] ) ) { |
|
427 | - $this->get_latest_version( $force_api = true ); |
|
426 | + if (isset($_REQUEST['force-version-check'])) { |
|
427 | + $this->get_latest_version($force_api = true); |
|
428 | 428 | } |
429 | 429 | |
430 | - if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) { |
|
430 | + if (!defined('FONTAWESOME_PLUGIN_FILE')) { |
|
431 | 431 | ?> |
432 | 432 | <style> |
433 | 433 | .wpfas-kit-show { |
@@ -454,42 +454,42 @@ discard block |
||
454 | 454 | <h1><?php echo $this->name; ?></h1> |
455 | 455 | <form method="post" action="options.php" class="fas-settings-form"> |
456 | 456 | <?php |
457 | - settings_fields( 'wp-font-awesome-settings' ); |
|
458 | - do_settings_sections( 'wp-font-awesome-settings' ); |
|
457 | + settings_fields('wp-font-awesome-settings'); |
|
458 | + do_settings_sections('wp-font-awesome-settings'); |
|
459 | 459 | $table_class = ''; |
460 | - if ( $this->settings['type'] ) { |
|
461 | - $table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set'; |
|
460 | + if ($this->settings['type']) { |
|
461 | + $table_class .= 'wpfas-' . sanitize_html_class(strtolower($this->settings['type'])) . '-set'; |
|
462 | 462 | } |
463 | - if ( ! empty( $this->settings['pro'] ) ) { |
|
463 | + if (!empty($this->settings['pro'])) { |
|
464 | 464 | $table_class .= ' wpfas-has-pro'; |
465 | 465 | } |
466 | 466 | ?> |
467 | - <?php if ( $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ) { ?> |
|
468 | - <?php if ( $this->has_local() ) { ?> |
|
469 | - <div class="notice notice-info"><p><strong><?php _e( 'Font Awesome fonts are loading locally.', 'ayecode-connect' ); ?></strong></p></div> |
|
467 | + <?php if ($this->settings['type'] != 'KIT' && !empty($this->settings['local']) && empty($this->settings['pro'])) { ?> |
|
468 | + <?php if ($this->has_local()) { ?> |
|
469 | + <div class="notice notice-info"><p><strong><?php _e('Font Awesome fonts are loading locally.', 'ayecode-connect'); ?></strong></p></div> |
|
470 | 470 | <?php } else { ?> |
471 | - <div class="notice notice-error"><p><strong><?php _e( 'Font Awesome fonts are not loading locally!', 'ayecode-connect' ); ?></strong></p></div> |
|
471 | + <div class="notice notice-error"><p><strong><?php _e('Font Awesome fonts are not loading locally!', 'ayecode-connect'); ?></strong></p></div> |
|
472 | 472 | <?php } ?> |
473 | 473 | <?php } ?> |
474 | - <table class="form-table wpfas-table-settings <?php echo esc_attr( $table_class ); ?>"> |
|
474 | + <table class="form-table wpfas-table-settings <?php echo esc_attr($table_class); ?>"> |
|
475 | 475 | <tr valign="top"> |
476 | - <th scope="row"><label for="wpfas-type"><?php _e( 'Type', 'ayecode-connect' ); ?></label></th> |
|
476 | + <th scope="row"><label for="wpfas-type"><?php _e('Type', 'ayecode-connect'); ?></label></th> |
|
477 | 477 | <td> |
478 | 478 | <select name="wp-font-awesome-settings[type]" id="wpfas-type" onchange="if(this.value=='KIT'){jQuery('.wpfas-table-settings').addClass('wpfas-kit-set');}else{jQuery('.wpfas-table-settings').removeClass('wpfas-kit-set');}"> |
479 | - <option value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'ayecode-connect' ); ?></option> |
|
480 | - <option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option> |
|
481 | - <option value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'ayecode-connect' ); ?></option> |
|
479 | + <option value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'ayecode-connect'); ?></option> |
|
480 | + <option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option> |
|
481 | + <option value="KIT" <?php selected($this->settings['type'], 'KIT'); ?>><?php _e('Kits (settings managed on fontawesome.com)', 'ayecode-connect'); ?></option> |
|
482 | 482 | </select> |
483 | 483 | </td> |
484 | 484 | </tr> |
485 | 485 | |
486 | 486 | <tr valign="top" class="wpfas-kit-show"> |
487 | - <th scope="row"><label for="wpfas-kit-url"><?php _e( 'Kit URL', 'ayecode-connect' ); ?></label></th> |
|
487 | + <th scope="row"><label for="wpfas-kit-url"><?php _e('Kit URL', 'ayecode-connect'); ?></label></th> |
|
488 | 488 | <td> |
489 | - <input class="regular-text" id="wpfas-kit-url" type="url" name="wp-font-awesome-settings[kit-url]" value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>" placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/> |
|
489 | + <input class="regular-text" id="wpfas-kit-url" type="url" name="wp-font-awesome-settings[kit-url]" value="<?php echo esc_attr($this->settings['kit-url']); ?>" placeholder="<?php echo 'https://kit.font'; echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/> |
|
490 | 490 | <span><?php |
491 | 491 | echo wp_sprintf( |
492 | - __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect' ), |
|
492 | + __('Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect'), |
|
493 | 493 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i> ', |
494 | 494 | '</a>' |
495 | 495 | ); |
@@ -497,54 +497,54 @@ discard block |
||
497 | 497 | </td> |
498 | 498 | </tr> |
499 | 499 | <tr valign="top" class="wpfas-kit-hide"> |
500 | - <th scope="row"><label for="wpfas-version"><?php _e( 'Version', 'ayecode-connect' ); ?></label></th> |
|
500 | + <th scope="row"><label for="wpfas-version"><?php _e('Version', 'ayecode-connect'); ?></label></th> |
|
501 | 501 | <td> |
502 | 502 | <select name="wp-font-awesome-settings[version]" id="wpfas-version"> |
503 | 503 | <?php /* @todo Remove after FA7 compatibility */ ?> |
504 | - <option value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo wp_sprintf( __( '%s (default)', 'ayecode-connect' ), '6.7.2' ); ?></option> |
|
505 | - <?php $latest_version = $this->get_latest_version( false, true ); if ( $latest_version && version_compare( $latest_version, '7.0.0', '>' ) ) { ?> |
|
506 | - <option value="<?php echo esc_attr( $latest_version ); ?>" <?php selected( $this->settings['version'], $latest_version ); ?>><?php echo esc_html( $latest_version ); ?></option> |
|
504 | + <option value="" <?php selected($this->settings['version'], ''); ?>><?php echo wp_sprintf(__('%s (default)', 'ayecode-connect'), '6.7.2'); ?></option> |
|
505 | + <?php $latest_version = $this->get_latest_version(false, true); if ($latest_version && version_compare($latest_version, '7.0.0', '>')) { ?> |
|
506 | + <option value="<?php echo esc_attr($latest_version); ?>" <?php selected($this->settings['version'], $latest_version); ?>><?php echo esc_html($latest_version); ?></option> |
|
507 | 507 | <?php } ?> |
508 | 508 | <?php /* @todo Remove after after FA7 compatibility */ ?> |
509 | 509 | |
510 | 510 | <?php /* @todo Un-comment after FA7 compatibility */ ?> |
511 | 511 | <?php /* ?><option value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo wp_sprintf( __( 'Latest - %s (default)', 'ayecode-connect' ), $this->get_latest_version() ); ?></option><?php */ ?> |
512 | - <option value="7.0.0" <?php selected( $this->settings['version'], '7.0.0' ); ?>>7.0.0</option> |
|
513 | - <option value="6.4.2" <?php selected( $this->settings['version'], '6.4.2' ); ?>>6.4.2</option> |
|
514 | - <option value="6.1.0" <?php selected( $this->settings['version'], '6.1.0' ); ?>>6.1.0</option> |
|
515 | - <option value="6.0.0" <?php selected( $this->settings['version'], '6.0.0' ); ?>>6.0.0</option> |
|
516 | - <option value="5.15.4" <?php selected( $this->settings['version'], '5.15.4' ); ?>>5.15.4</option> |
|
517 | - <option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>5.6.0</option> |
|
518 | - <option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>5.5.0</option> |
|
519 | - <option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>5.4.0</option> |
|
520 | - <option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>5.3.0</option> |
|
521 | - <option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>5.2.0</option> |
|
522 | - <option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>5.1.0</option> |
|
523 | - <option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>4.7.1 (CSS only)</option> |
|
512 | + <option value="7.0.0" <?php selected($this->settings['version'], '7.0.0'); ?>>7.0.0</option> |
|
513 | + <option value="6.4.2" <?php selected($this->settings['version'], '6.4.2'); ?>>6.4.2</option> |
|
514 | + <option value="6.1.0" <?php selected($this->settings['version'], '6.1.0'); ?>>6.1.0</option> |
|
515 | + <option value="6.0.0" <?php selected($this->settings['version'], '6.0.0'); ?>>6.0.0</option> |
|
516 | + <option value="5.15.4" <?php selected($this->settings['version'], '5.15.4'); ?>>5.15.4</option> |
|
517 | + <option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>>5.6.0</option> |
|
518 | + <option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>5.5.0</option> |
|
519 | + <option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>5.4.0</option> |
|
520 | + <option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>5.3.0</option> |
|
521 | + <option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>5.2.0</option> |
|
522 | + <option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>5.1.0</option> |
|
523 | + <option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>4.7.1 (CSS only)</option> |
|
524 | 524 | </select> |
525 | 525 | </td> |
526 | 526 | </tr> |
527 | 527 | |
528 | 528 | <tr valign="top"> |
529 | - <th scope="row"><label for="wpfas-enqueue"><?php _e( 'Enqueue', 'ayecode-connect' ); ?></label></th> |
|
529 | + <th scope="row"><label for="wpfas-enqueue"><?php _e('Enqueue', 'ayecode-connect'); ?></label></th> |
|
530 | 530 | <td> |
531 | 531 | <select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue"> |
532 | - <option value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'ayecode-connect' ); ?></option> |
|
533 | - <option value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'ayecode-connect' ); ?></option> |
|
534 | - <option value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'ayecode-connect' ); ?></option> |
|
532 | + <option value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'ayecode-connect'); ?></option> |
|
533 | + <option value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'ayecode-connect'); ?></option> |
|
534 | + <option value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'ayecode-connect'); ?></option> |
|
535 | 535 | </select> |
536 | 536 | </td> |
537 | 537 | </tr> |
538 | 538 | |
539 | 539 | <tr valign="top" class="wpfas-kit-hide"> |
540 | 540 | <th scope="row"><label |
541 | - for="wpfas-pro"><?php _e( 'Enable pro', 'ayecode-connect' ); ?></label></th> |
|
541 | + for="wpfas-pro"><?php _e('Enable pro', 'ayecode-connect'); ?></label></th> |
|
542 | 542 | <td> |
543 | 543 | <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/> |
544 | - <input type="checkbox" name="wp-font-awesome-settings[pro]" value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro" onchange="if(jQuery(this).is(':checked')){jQuery('.wpfas-table-settings').addClass('wpfas-has-pro')}else{jQuery('.wpfas-table-settings').removeClass('wpfas-has-pro')}"/> |
|
544 | + <input type="checkbox" name="wp-font-awesome-settings[pro]" value="1" <?php checked($this->settings['pro'], '1'); ?> id="wpfas-pro" onchange="if(jQuery(this).is(':checked')){jQuery('.wpfas-table-settings').addClass('wpfas-has-pro')}else{jQuery('.wpfas-table-settings').removeClass('wpfas-has-pro')}"/> |
|
545 | 545 | <span><?php |
546 | 546 | echo wp_sprintf( |
547 | - __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'ayecode-connect' ), |
|
547 | + __('Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'ayecode-connect'), |
|
548 | 548 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">', |
549 | 549 | ' <i class="fas fa-external-link-alt"></i></a>', |
550 | 550 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">', |
@@ -555,49 +555,49 @@ discard block |
||
555 | 555 | </tr> |
556 | 556 | |
557 | 557 | <tr valign="top" class="wpfas-kit-hide wpfas-hide-pro"> |
558 | - <th scope="row"><label for="wpfas-local"><?php _e( 'Load Fonts Locally', 'ayecode-connect' ); ?></label></th> |
|
558 | + <th scope="row"><label for="wpfas-local"><?php _e('Load Fonts Locally', 'ayecode-connect'); ?></label></th> |
|
559 | 559 | <td> |
560 | 560 | <input type="hidden" name="wp-font-awesome-settings[local]" value="0"/> |
561 | - <input type="hidden" name="wp-font-awesome-settings[local_version]" value="<?php echo esc_attr( $this->settings['local_version'] ); ?>"/> |
|
562 | - <input type="checkbox" name="wp-font-awesome-settings[local]" value="1" <?php checked( $this->settings['local'], '1' ); ?> id="wpfas-local"/> |
|
563 | - <span><?php _e( '(For free version only) Load FontAwesome fonts from locally. This downloads FontAwesome fonts from fontawesome.com & stores at the local site.', 'ayecode-connect' ); ?></span> |
|
561 | + <input type="hidden" name="wp-font-awesome-settings[local_version]" value="<?php echo esc_attr($this->settings['local_version']); ?>"/> |
|
562 | + <input type="checkbox" name="wp-font-awesome-settings[local]" value="1" <?php checked($this->settings['local'], '1'); ?> id="wpfas-local"/> |
|
563 | + <span><?php _e('(For free version only) Load FontAwesome fonts from locally. This downloads FontAwesome fonts from fontawesome.com & stores at the local site.', 'ayecode-connect'); ?></span> |
|
564 | 564 | </td> |
565 | 565 | </tr> |
566 | 566 | |
567 | 567 | <tr valign="top" class="wpfas-kit-hide"> |
568 | 568 | <th scope="row"><label |
569 | - for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'ayecode-connect' ); ?></label> |
|
569 | + for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'ayecode-connect'); ?></label> |
|
570 | 570 | </th> |
571 | 571 | <td> |
572 | 572 | <input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/> |
573 | 573 | <input type="checkbox" name="wp-font-awesome-settings[shims]" |
574 | - value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/> |
|
575 | - <span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'ayecode-connect' ); ?></span> |
|
574 | + value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/> |
|
575 | + <span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'ayecode-connect'); ?></span> |
|
576 | 576 | </td> |
577 | 577 | </tr> |
578 | 578 | |
579 | 579 | <tr valign="top" class="wpfas-kit-hide"> |
580 | 580 | <th scope="row"><label |
581 | - for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'ayecode-connect' ); ?></label> |
|
581 | + for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'ayecode-connect'); ?></label> |
|
582 | 582 | </th> |
583 | 583 | <td> |
584 | 584 | <input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/> |
585 | 585 | <input type="checkbox" name="wp-font-awesome-settings[js-pseudo]" |
586 | - value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?> |
|
586 | + value="1" <?php checked($this->settings['js-pseudo'], '1'); ?> |
|
587 | 587 | id="wpfas-js-pseudo"/> |
588 | - <span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'ayecode-connect' ); ?></span> |
|
588 | + <span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'ayecode-connect'); ?></span> |
|
589 | 589 | </td> |
590 | 590 | </tr> |
591 | 591 | |
592 | 592 | <tr valign="top"> |
593 | 593 | <th scope="row"><label |
594 | - for="wpfas-dequeue"><?php _e( 'Dequeue', 'ayecode-connect' ); ?></label></th> |
|
594 | + for="wpfas-dequeue"><?php _e('Dequeue', 'ayecode-connect'); ?></label></th> |
|
595 | 595 | <td> |
596 | 596 | <input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/> |
597 | 597 | <input type="checkbox" name="wp-font-awesome-settings[dequeue]" |
598 | - value="1" <?php checked( $this->settings['dequeue'], '1' ); ?> |
|
598 | + value="1" <?php checked($this->settings['dequeue'], '1'); ?> |
|
599 | 599 | id="wpfas-dequeue"/> |
600 | - <span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'ayecode-connect' ); ?></span> |
|
600 | + <span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'ayecode-connect'); ?></span> |
|
601 | 601 | </td> |
602 | 602 | </tr> |
603 | 603 | |
@@ -606,12 +606,12 @@ discard block |
||
606 | 606 | <?php |
607 | 607 | submit_button(); |
608 | 608 | ?> |
609 | - <p class="submit"><a href="https://fontawesome.com/referral?a=c9b89e1418" class="button button-secondary"><?php _e('Get 24,000+ more icons with Font Awesome Pro','ayecode-connect'); ?> <i class="fas fa-external-link-alt"></i></a></p> |
|
609 | + <p class="submit"><a href="https://fontawesome.com/referral?a=c9b89e1418" class="button button-secondary"><?php _e('Get 24,000+ more icons with Font Awesome Pro', 'ayecode-connect'); ?> <i class="fas fa-external-link-alt"></i></a></p> |
|
610 | 610 | |
611 | 611 | </div> |
612 | 612 | </form> |
613 | 613 | |
614 | - <div id="wpfas-version"><?php echo wp_sprintf(__( 'Version: %s (affiliate links provided)', 'ayecode-connect' ), $this->version ); ?></div> |
|
614 | + <div id="wpfas-version"><?php echo wp_sprintf(__('Version: %s (affiliate links provided)', 'ayecode-connect'), $this->version); ?></div> |
|
615 | 615 | </div> |
616 | 616 | <?php |
617 | 617 | } |
@@ -626,12 +626,12 @@ discard block |
||
626 | 626 | * |
627 | 627 | * @return string Either a valid version number or an empty string. |
628 | 628 | */ |
629 | - public function validate_version_number( $version ) { |
|
629 | + public function validate_version_number($version) { |
|
630 | 630 | |
631 | - if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) { |
|
631 | + if (version_compare($version, '0.0.1', '>=') >= 0) { |
|
632 | 632 | // valid |
633 | 633 | } else { |
634 | - $version = '';// not validated |
|
634 | + $version = ''; // not validated |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | return $version; |
@@ -646,32 +646,32 @@ discard block |
||
646 | 646 | * @since 1.0.7 |
647 | 647 | * @return mixed|string The latest version number found. |
648 | 648 | */ |
649 | - public function get_latest_version( $force_api = false, $force_latest = false ) { |
|
649 | + public function get_latest_version($force_api = false, $force_latest = false) { |
|
650 | 650 | $latest_version = $this->latest; |
651 | 651 | |
652 | - $cache = get_transient( 'wp-font-awesome-settings-version' ); |
|
652 | + $cache = get_transient('wp-font-awesome-settings-version'); |
|
653 | 653 | |
654 | - if ( $cache === false || $force_api ) { // its not set |
|
654 | + if ($cache === false || $force_api) { // its not set |
|
655 | 655 | $api_ver = $this->get_latest_version_from_api(); |
656 | - if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) { |
|
656 | + if (version_compare($api_ver, $this->latest, '>=') >= 0) { |
|
657 | 657 | $latest_version = $api_ver; |
658 | - set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS ); |
|
658 | + set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS); |
|
659 | 659 | } |
660 | - } elseif ( $this->validate_version_number( $cache ) ) { |
|
661 | - if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) { |
|
660 | + } elseif ($this->validate_version_number($cache)) { |
|
661 | + if (version_compare($cache, $this->latest, '>=') >= 0) { |
|
662 | 662 | $latest_version = $cache; |
663 | 663 | } |
664 | 664 | } |
665 | 665 | |
666 | 666 | // @todo remove after FA7 compatibility |
667 | - if ( ! $force_latest && version_compare( $cache, '7.0.0', '>=' ) >= 0 ) { |
|
667 | + if (!$force_latest && version_compare($cache, '7.0.0', '>=') >= 0) { |
|
668 | 668 | $latest_version = '6.7.2'; |
669 | 669 | } |
670 | 670 | |
671 | 671 | // Check and auto download fonts locally. |
672 | - if ( empty( $this->settings['pro'] ) && empty( $this->settings['version'] ) && $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && ! empty( $this->settings['local_version'] ) && ! empty( $latest_version ) ) { |
|
673 | - if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) { |
|
674 | - $this->download_package( $latest_version ); |
|
672 | + if (empty($this->settings['pro']) && empty($this->settings['version']) && $this->settings['type'] != 'KIT' && !empty($this->settings['local']) && !empty($this->settings['local_version']) && !empty($latest_version)) { |
|
673 | + if (version_compare($latest_version, $this->settings['local_version'], '>') && is_admin() && !wp_doing_ajax()) { |
|
674 | + $this->download_package($latest_version); |
|
675 | 675 | } |
676 | 676 | } |
677 | 677 | |
@@ -686,10 +686,10 @@ discard block |
||
686 | 686 | */ |
687 | 687 | public function get_latest_version_from_api() { |
688 | 688 | $version = "0"; |
689 | - $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" ); |
|
690 | - if ( ! is_wp_error( $response ) && is_array( $response ) ) { |
|
691 | - $api_response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
692 | - if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) { |
|
689 | + $response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest"); |
|
690 | + if (!is_wp_error($response) && is_array($response)) { |
|
691 | + $api_response = json_decode(wp_remote_retrieve_body($response), true); |
|
692 | + if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) { |
|
693 | 693 | $version = $api_response['tag_name']; |
694 | 694 | } |
695 | 695 | } |
@@ -717,21 +717,21 @@ discard block |
||
717 | 717 | public function admin_notices() { |
718 | 718 | $settings = $this->settings; |
719 | 719 | |
720 | - if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) { |
|
721 | - if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) { |
|
720 | + if (defined('FONTAWESOME_PLUGIN_FILE')) { |
|
721 | + if (!empty($_REQUEST['page']) && $_REQUEST['page'] == 'wp-font-awesome-settings') { |
|
722 | 722 | ?> |
723 | 723 | <div class="notice notice-error is-dismissible"> |
724 | - <p><?php _e( 'The Official Font Awesome Plugin is active, please adjust your settings there.', 'ayecode-connect' ); ?></p> |
|
724 | + <p><?php _e('The Official Font Awesome Plugin is active, please adjust your settings there.', 'ayecode-connect'); ?></p> |
|
725 | 725 | </div> |
726 | 726 | <?php |
727 | 727 | } |
728 | 728 | } else { |
729 | - if ( ! empty( $settings ) ) { |
|
730 | - if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) { |
|
729 | + if (!empty($settings)) { |
|
730 | + if ($settings['type'] != 'KIT' && $settings['pro'] && ($settings['version'] == '' || version_compare($settings['version'], '6', '>='))) { |
|
731 | 731 | $link = admin_url('options-general.php?page=wp-font-awesome-settings'); |
732 | 732 | ?> |
733 | 733 | <div class="notice notice-error is-dismissible"> |
734 | - <p><?php echo wp_sprintf( __( 'Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'ayecode-connect' ),"<a href='". esc_url_raw( $link )."'>","</a>" ); ?></p> |
|
734 | + <p><?php echo wp_sprintf(__('Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'ayecode-connect'), "<a href='" . esc_url_raw($link) . "'>", "</a>"); ?></p> |
|
735 | 735 | </div> |
736 | 736 | <?php |
737 | 737 | } |
@@ -747,20 +747,20 @@ discard block |
||
747 | 747 | * @param string $option The option name. |
748 | 748 | * @param mixed $value The option value. |
749 | 749 | */ |
750 | - public function add_option_wp_font_awesome_settings( $option, $value ) { |
|
750 | + public function add_option_wp_font_awesome_settings($option, $value) { |
|
751 | 751 | // Do nothing if WordPress is being installed. |
752 | - if ( wp_installing() ) { |
|
752 | + if (wp_installing()) { |
|
753 | 753 | return; |
754 | 754 | } |
755 | 755 | |
756 | - if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) { |
|
757 | - $version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version(); |
|
756 | + if (!empty($value['local']) && empty($value['pro']) && !(!empty($value['type']) && $value['type'] == 'KIT')) { |
|
757 | + $version = isset($value['version']) && $value['version'] ? $value['version'] : $this->get_latest_version(); |
|
758 | 758 | |
759 | - if ( ! empty( $version ) ) { |
|
760 | - $response = $this->download_package( $version, $value ); |
|
759 | + if (!empty($version)) { |
|
760 | + $response = $this->download_package($version, $value); |
|
761 | 761 | |
762 | - if ( is_wp_error( $response ) ) { |
|
763 | - add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' ); |
|
762 | + if (is_wp_error($response)) { |
|
763 | + add_settings_error('general', 'fontawesome_download', __('ERROR:', 'ayecode-connect') . ' ' . $response->get_error_message(), 'error'); |
|
764 | 764 | } |
765 | 765 | } |
766 | 766 | } |
@@ -774,25 +774,25 @@ discard block |
||
774 | 774 | * @param mixed $old_value The old option value. |
775 | 775 | * @param mixed $value The new option value. |
776 | 776 | */ |
777 | - public function update_option_wp_font_awesome_settings( $old_value, $new_value ) { |
|
777 | + public function update_option_wp_font_awesome_settings($old_value, $new_value) { |
|
778 | 778 | // Do nothing if WordPress is being installed. |
779 | - if ( wp_installing() ) { |
|
779 | + if (wp_installing()) { |
|
780 | 780 | return; |
781 | 781 | } |
782 | 782 | |
783 | - if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) { |
|
783 | + if (!empty($new_value['local']) && empty($new_value['pro']) && !(!empty($new_value['type']) && $new_value['type'] == 'KIT')) { |
|
784 | 784 | // Old values |
785 | - $old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' ); |
|
786 | - $old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0; |
|
785 | + $old_version = isset($old_value['version']) && $old_value['version'] ? $old_value['version'] : (isset($old_value['local_version']) ? $old_value['local_version'] : ''); |
|
786 | + $old_local = isset($old_value['local']) ? (int) $old_value['local'] : 0; |
|
787 | 787 | |
788 | 788 | // New values |
789 | - $new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version(); |
|
789 | + $new_version = isset($new_value['version']) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version(); |
|
790 | 790 | |
791 | - if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) { |
|
792 | - $response = $this->download_package( $new_version, $new_value ); |
|
791 | + if (empty($old_local) || $old_version !== $new_version || !file_exists($this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css')) { |
|
792 | + $response = $this->download_package($new_version, $new_value); |
|
793 | 793 | |
794 | - if ( is_wp_error( $response ) ) { |
|
795 | - add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' ); |
|
794 | + if (is_wp_error($response)) { |
|
795 | + add_settings_error('general', 'fontawesome_download', __('ERROR:', 'ayecode-connect') . ' ' . $response->get_error_message(), 'error'); |
|
796 | 796 | } |
797 | 797 | } |
798 | 798 | } |
@@ -806,9 +806,9 @@ discard block |
||
806 | 806 | * @param string Fonts directory local path. |
807 | 807 | */ |
808 | 808 | public function get_fonts_dir() { |
809 | - $upload_dir = wp_upload_dir( null, false ); |
|
809 | + $upload_dir = wp_upload_dir(null, false); |
|
810 | 810 | |
811 | - return $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR; |
|
811 | + return $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR; |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | /** |
@@ -819,9 +819,9 @@ discard block |
||
819 | 819 | * @param string Fonts directory local url. |
820 | 820 | */ |
821 | 821 | public function get_fonts_url() { |
822 | - $upload_dir = wp_upload_dir( null, false ); |
|
822 | + $upload_dir = wp_upload_dir(null, false); |
|
823 | 823 | |
824 | - return $upload_dir['baseurl'] . '/ayefonts/fa/'; |
|
824 | + return $upload_dir['baseurl'] . '/ayefonts/fa/'; |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | /** |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | * @return bool True if active else false. |
833 | 833 | */ |
834 | 834 | public function has_local() { |
835 | - if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) { |
|
835 | + if (!empty($this->settings['local']) && empty($this->settings['pro']) && file_exists($this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css')) { |
|
836 | 836 | return true; |
837 | 837 | } |
838 | 838 | |
@@ -847,18 +847,18 @@ discard block |
||
847 | 847 | * @return object The WP Filesystem. |
848 | 848 | */ |
849 | 849 | public function get_wp_filesystem() { |
850 | - if ( ! function_exists( 'get_filesystem_method' ) ) { |
|
851 | - require_once( ABSPATH . "/wp-admin/includes/file.php" ); |
|
850 | + if (!function_exists('get_filesystem_method')) { |
|
851 | + require_once(ABSPATH . "/wp-admin/includes/file.php"); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | $access_type = get_filesystem_method(); |
855 | 855 | |
856 | - if ( $access_type === 'direct' ) { |
|
856 | + if ($access_type === 'direct') { |
|
857 | 857 | /* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
858 | - $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
858 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
859 | 859 | |
860 | 860 | /* Initialize the API */ |
861 | - if ( ! WP_Filesystem( $creds ) ) { |
|
861 | + if (!WP_Filesystem($creds)) { |
|
862 | 862 | /* Any problems and we exit */ |
863 | 863 | return false; |
864 | 864 | } |
@@ -867,11 +867,11 @@ discard block |
||
867 | 867 | |
868 | 868 | return $wp_filesystem; |
869 | 869 | /* Do our file manipulations below */ |
870 | - } else if ( defined( 'FTP_USER' ) ) { |
|
871 | - $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
870 | + } else if (defined('FTP_USER')) { |
|
871 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
872 | 872 | |
873 | 873 | /* Initialize the API */ |
874 | - if ( ! WP_Filesystem( $creds ) ) { |
|
874 | + if (!WP_Filesystem($creds)) { |
|
875 | 875 | /* Any problems and we exit */ |
876 | 876 | return false; |
877 | 877 | } |
@@ -894,38 +894,38 @@ discard block |
||
894 | 894 | * @param array $option Fontawesome settings. |
895 | 895 | * @return WP_ERROR|bool Error on fail and true on success. |
896 | 896 | */ |
897 | - public function download_package( $version, $option = array() ) { |
|
897 | + public function download_package($version, $option = array()) { |
|
898 | 898 | $filename = 'fontawesome-free-' . $version . '-web'; |
899 | 899 | $url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip'; |
900 | 900 | |
901 | - if ( ! function_exists( 'wp_handle_upload' ) ) { |
|
901 | + if (!function_exists('wp_handle_upload')) { |
|
902 | 902 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
903 | 903 | } |
904 | 904 | |
905 | - $download_file = download_url( esc_url_raw( $url ) ); |
|
905 | + $download_file = download_url(esc_url_raw($url)); |
|
906 | 906 | |
907 | - if ( is_wp_error( $download_file ) ) { |
|
908 | - return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'ayecode-connect' ) ); |
|
909 | - } else if ( empty( $download_file ) ) { |
|
910 | - return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'ayecode-connect' ) ); |
|
907 | + if (is_wp_error($download_file)) { |
|
908 | + return new WP_Error('fontawesome_download_failed', __($download_file->get_error_message(), 'ayecode-connect')); |
|
909 | + } else if (empty($download_file)) { |
|
910 | + return new WP_Error('fontawesome_download_failed', __('Something went wrong in downloading the font awesome to store locally.', 'ayecode-connect')); |
|
911 | 911 | } |
912 | 912 | |
913 | - $response = $this->extract_package( $download_file, $filename, true ); |
|
913 | + $response = $this->extract_package($download_file, $filename, true); |
|
914 | 914 | |
915 | 915 | // Update local version. |
916 | - if ( is_wp_error( $response ) ) { |
|
916 | + if (is_wp_error($response)) { |
|
917 | 917 | return $response; |
918 | - } else if ( $response ) { |
|
919 | - if ( empty( $option ) ) { |
|
920 | - $option = get_option( 'wp-font-awesome-settings' ); |
|
918 | + } else if ($response) { |
|
919 | + if (empty($option)) { |
|
920 | + $option = get_option('wp-font-awesome-settings'); |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | $option['local_version'] = $version; |
924 | 924 | |
925 | 925 | // Remove action to prevent looping. |
926 | - remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 ); |
|
926 | + remove_action('update_option_wp-font-awesome-settings', array($this, 'update_option_wp_font_awesome_settings'), 10, 2); |
|
927 | 927 | |
928 | - update_option( 'wp-font-awesome-settings', $option ); |
|
928 | + update_option('wp-font-awesome-settings', $option); |
|
929 | 929 | |
930 | 930 | return true; |
931 | 931 | } |
@@ -943,60 +943,60 @@ discard block |
||
943 | 943 | * @param bool $delete_package Delete temp file or not. |
944 | 944 | * @return WP_Error|bool True on success WP_Error on fail. |
945 | 945 | */ |
946 | - public function extract_package( $package, $dirname = '', $delete_package = false ) { |
|
946 | + public function extract_package($package, $dirname = '', $delete_package = false) { |
|
947 | 947 | global $wp_filesystem; |
948 | 948 | |
949 | 949 | $wp_filesystem = $this->get_wp_filesystem(); |
950 | 950 | |
951 | - if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { |
|
952 | - return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'ayecode-connect' ) ); |
|
953 | - } else if ( empty( $wp_filesystem ) ) { |
|
954 | - return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'ayecode-connect' ) ); |
|
951 | + if (empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
952 | + return new WP_Error('fontawesome_filesystem_error', __($wp_filesystem->errors->get_error_message(), 'ayecode-connect')); |
|
953 | + } else if (empty($wp_filesystem)) { |
|
954 | + return new WP_Error('fontawesome_filesystem_error', __('Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'ayecode-connect')); |
|
955 | 955 | } |
956 | 956 | |
957 | 957 | $fonts_dir = $this->get_fonts_dir(); |
958 | - $fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR; |
|
958 | + $fonts_tmp_dir = dirname($fonts_dir) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR; |
|
959 | 959 | |
960 | - if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) { |
|
961 | - $wp_filesystem->delete( $fonts_tmp_dir, true ); |
|
960 | + if ($wp_filesystem->is_dir($fonts_tmp_dir)) { |
|
961 | + $wp_filesystem->delete($fonts_tmp_dir, true); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | // Unzip package to working directory. |
965 | - $result = unzip_file( $package, $fonts_tmp_dir ); |
|
965 | + $result = unzip_file($package, $fonts_tmp_dir); |
|
966 | 966 | |
967 | - if ( is_wp_error( $result ) ) { |
|
968 | - $wp_filesystem->delete( $fonts_tmp_dir, true ); |
|
967 | + if (is_wp_error($result)) { |
|
968 | + $wp_filesystem->delete($fonts_tmp_dir, true); |
|
969 | 969 | |
970 | - if ( 'incompatible_archive' === $result->get_error_code() ) { |
|
971 | - return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'ayecode-connect' ) ); |
|
970 | + if ('incompatible_archive' === $result->get_error_code()) { |
|
971 | + return new WP_Error('fontawesome_incompatible_archive', __($result->get_error_message(), 'ayecode-connect')); |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | return $result; |
975 | 975 | } |
976 | 976 | |
977 | - if ( $wp_filesystem->is_dir( $fonts_dir ) ) { |
|
978 | - $wp_filesystem->delete( $fonts_dir, true ); |
|
977 | + if ($wp_filesystem->is_dir($fonts_dir)) { |
|
978 | + $wp_filesystem->delete($fonts_dir, true); |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | $extract_dir = $fonts_tmp_dir; |
982 | 982 | |
983 | - if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) { |
|
983 | + if ($dirname && $wp_filesystem->is_dir($extract_dir . $dirname . DIRECTORY_SEPARATOR)) { |
|
984 | 984 | $extract_dir .= $dirname . DIRECTORY_SEPARATOR; |
985 | 985 | } |
986 | 986 | |
987 | 987 | try { |
988 | - $return = $wp_filesystem->move( $extract_dir, $fonts_dir, true ); |
|
989 | - } catch ( Exception $e ) { |
|
990 | - $return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'ayecode-connect' ) ); |
|
988 | + $return = $wp_filesystem->move($extract_dir, $fonts_dir, true); |
|
989 | + } catch (Exception $e) { |
|
990 | + $return = new WP_Error('fontawesome_move_package', __('Fail to move font awesome package!', 'ayecode-connect')); |
|
991 | 991 | } |
992 | 992 | |
993 | - if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) { |
|
994 | - $wp_filesystem->delete( $fonts_tmp_dir, true ); |
|
993 | + if ($wp_filesystem->is_dir($fonts_tmp_dir)) { |
|
994 | + $wp_filesystem->delete($fonts_tmp_dir, true); |
|
995 | 995 | } |
996 | 996 | |
997 | 997 | // Once extracted, delete the package if required. |
998 | - if ( $delete_package ) { |
|
999 | - unlink( $package ); |
|
998 | + if ($delete_package) { |
|
999 | + unlink($package); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | return $return; |
@@ -1006,22 +1006,22 @@ discard block |
||
1006 | 1006 | * Output the version in the header. |
1007 | 1007 | */ |
1008 | 1008 | public function add_generator() { |
1009 | - $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) ); |
|
1010 | - $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) ); |
|
1009 | + $file = str_replace(array("/", "\\"), "/", realpath(__FILE__)); |
|
1010 | + $plugins_dir = str_replace(array("/", "\\"), "/", realpath(WP_PLUGIN_DIR)); |
|
1011 | 1011 | |
1012 | 1012 | // Find source plugin/theme. |
1013 | 1013 | $source = array(); |
1014 | - if ( strpos( $file, $plugins_dir ) !== false ) { |
|
1015 | - $source = explode( "/", plugin_basename( $file ) ); |
|
1016 | - } else if ( function_exists( 'get_theme_root' ) ) { |
|
1017 | - $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) ); |
|
1014 | + if (strpos($file, $plugins_dir) !== false) { |
|
1015 | + $source = explode("/", plugin_basename($file)); |
|
1016 | + } else if (function_exists('get_theme_root')) { |
|
1017 | + $themes_dir = str_replace(array("/", "\\"), "/", realpath(get_theme_root())); |
|
1018 | 1018 | |
1019 | - if ( strpos( $file, $themes_dir ) !== false ) { |
|
1020 | - $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) ); |
|
1019 | + if (strpos($file, $themes_dir) !== false) { |
|
1020 | + $source = explode("/", ltrim(str_replace($themes_dir, "", $file), "/")); |
|
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | |
1024 | - echo '<meta name="generator" content="WP Font Awesome Settings v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-ac-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />'; |
|
1024 | + echo '<meta name="generator" content="WP Font Awesome Settings v' . esc_attr($this->version) . '"' . (!empty($source[0]) ? ' data-ac-source="' . esc_attr($source[0]) . '"' : '') . ' />'; |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | /** |
@@ -1037,8 +1037,8 @@ discard block |
||
1037 | 1037 | * @param string $src The script url. |
1038 | 1038 | * @return string The script tag. |
1039 | 1039 | */ |
1040 | - public function script_loader_tag( $tag, $handle, $src ) { |
|
1041 | - if ( ( $handle == 'font-awesome' || $handle == 'font-awesome-shims' ) && ( strpos( $src, "kit.fontawesome.com" ) !== false || strpos( $src, ".fontawesome.com/releases/" ) !== false ) ) { |
|
1040 | + public function script_loader_tag($tag, $handle, $src) { |
|
1041 | + if (($handle == 'font-awesome' || $handle == 'font-awesome-shims') && (strpos($src, "kit.fontawesome.com") !== false || strpos($src, ".fontawesome.com/releases/") !== false)) { |
|
1042 | 1042 | $tag = preg_replace( |
1043 | 1043 | '/<script[\s]+(.*?)>/', |
1044 | 1044 | '<script defer crossorigin="anonymous" \1>', |
@@ -14,9 +14,9 @@ |
||
14 | 14 | } |
15 | 15 | if (!ini_get('display_errors')) { |
16 | 16 | if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
17 | - fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); |
|
17 | + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL . PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL . PHP_EOL); |
|
18 | 18 | } elseif (!headers_sent()) { |
19 | - echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; |
|
19 | + echo 'Composer detected issues in your platform:' . PHP_EOL . PHP_EOL . str_replace('You are running ' . PHP_VERSION . '.', '', implode(PHP_EOL, $issues)) . PHP_EOL . PHP_EOL; |
|
20 | 20 | } |
21 | 21 | } |
22 | 22 | throw new \RuntimeException( |
@@ -359,17 +359,17 @@ |
||
359 | 359 | $vendorDir = strtr($vendorDir, '\\', '/'); |
360 | 360 | if (isset(self::$installedByVendor[$vendorDir])) { |
361 | 361 | $installed[] = self::$installedByVendor[$vendorDir]; |
362 | - } elseif (is_file($vendorDir.'/composer/installed.php')) { |
|
362 | + } elseif (is_file($vendorDir . '/composer/installed.php')) { |
|
363 | 363 | /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ |
364 | - $required = require $vendorDir.'/composer/installed.php'; |
|
364 | + $required = require $vendorDir . '/composer/installed.php'; |
|
365 | 365 | self::$installedByVendor[$vendorDir] = $required; |
366 | 366 | $installed[] = $required; |
367 | - if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { |
|
367 | + if (self::$installed === null && $vendorDir . '/composer' === $selfDir) { |
|
368 | 368 | self::$installed = $required; |
369 | 369 | self::$installedIsLocalDir = true; |
370 | 370 | } |
371 | 371 | } |
372 | - if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { |
|
372 | + if (self::$installedIsLocalDir && $vendorDir . '/composer' === $selfDir) { |
|
373 | 373 | $copiedLocalDir = true; |
374 | 374 | } |
375 | 375 | } |
@@ -1,11 +1,11 @@ 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 | - define( 'SUPER_DUPER_VER', '1.2.25' ); |
|
8 | + define('SUPER_DUPER_VER', '1.2.25'); |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
@@ -38,40 +38,40 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * Take the array options and use them to build. |
40 | 40 | */ |
41 | - public function __construct( $options ) { |
|
41 | + public function __construct($options) { |
|
42 | 42 | global $sd_widgets; |
43 | 43 | |
44 | - $sd_widgets[ $options['base_id'] ] = array( |
|
44 | + $sd_widgets[$options['base_id']] = array( |
|
45 | 45 | 'name' => $options['name'], |
46 | 46 | 'class_name' => $options['class_name'], |
47 | 47 | 'output_types' => !empty($options['output_types']) ? $options['output_types'] : array() |
48 | 48 | ); |
49 | - $this->base_id = $options['base_id']; |
|
49 | + $this->base_id = $options['base_id']; |
|
50 | 50 | // lets filter the options before we do anything |
51 | - $options = apply_filters( "wp_super_duper_options", $options ); |
|
52 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
53 | - $options = $this->add_name_from_key( $options ); |
|
51 | + $options = apply_filters("wp_super_duper_options", $options); |
|
52 | + $options = apply_filters("wp_super_duper_options_{$this->base_id}", $options); |
|
53 | + $options = $this->add_name_from_key($options); |
|
54 | 54 | $this->options = $options; |
55 | 55 | |
56 | 56 | $this->base_id = $options['base_id']; |
57 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
57 | + $this->arguments = isset($options['arguments']) ? $options['arguments'] : array(); |
|
58 | 58 | |
59 | 59 | // nested blocks can't work as a widget |
60 | - if(!empty($this->options['nested-block'])){ |
|
61 | - if(empty($this->options['output_types'])){ |
|
62 | - $this->options['output_types'] = array('shortcode','block'); |
|
60 | + if (!empty($this->options['nested-block'])) { |
|
61 | + if (empty($this->options['output_types'])) { |
|
62 | + $this->options['output_types'] = array('shortcode', 'block'); |
|
63 | 63 | }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) { |
64 | 64 | unset($this->options['output_types'][$key]); |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | 68 | // init parent |
69 | - if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
70 | - parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
|
69 | + if (empty($this->options['output_types']) || in_array('widget', $this->options['output_types'])) { |
|
70 | + parent::__construct($options['base_id'], $options['name'], $options['widget_ops']); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | - if ( isset( $options['class_name'] ) ) { |
|
74 | + if (isset($options['class_name'])) { |
|
75 | 75 | // register widget |
76 | 76 | $this->class_name = $options['class_name']; |
77 | 77 | |
@@ -80,68 +80,68 @@ discard block |
||
80 | 80 | |
81 | 81 | |
82 | 82 | // Fusion Builder (avada) support |
83 | - if ( function_exists( 'fusion_builder_map' ) ) { |
|
84 | - add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
83 | + if (function_exists('fusion_builder_map')) { |
|
84 | + add_action('init', array($this, 'register_fusion_element')); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // maybe load the Bricks transformer class |
88 | - if( class_exists('\Bricks\Elements', false) ){ |
|
89 | - add_action( 'init', array( $this, 'load_bricks_element_class' ) ); |
|
88 | + if (class_exists('\Bricks\Elements', false)) { |
|
89 | + add_action('init', array($this, 'load_bricks_element_class')); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | // register block |
93 | - if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){ |
|
94 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
93 | + if (empty($this->options['output_types']) || in_array('block', $this->options['output_types'])) { |
|
94 | + add_action('admin_enqueue_scripts', array($this, 'register_block')); |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | 98 | // add the CSS and JS we need ONCE |
99 | 99 | global $sd_widget_scripts; |
100 | 100 | |
101 | - if ( ! $sd_widget_scripts ) { |
|
102 | - wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
103 | - wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
104 | - wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
101 | + if (!$sd_widget_scripts) { |
|
102 | + wp_add_inline_script('admin-widgets', $this->widget_js()); |
|
103 | + wp_add_inline_script('customize-controls', $this->widget_js()); |
|
104 | + wp_add_inline_style('widgets', $this->widget_css()); |
|
105 | 105 | |
106 | 106 | // maybe add elementor editor styles |
107 | - add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
107 | + add_action('elementor/editor/after_enqueue_styles', array($this, 'elementor_editor_styles')); |
|
108 | 108 | |
109 | 109 | $sd_widget_scripts = true; |
110 | 110 | |
111 | 111 | // add shortcode insert button once |
112 | - add_action( 'media_buttons', array( $this, 'wp_media_buttons' ), 1 ); |
|
113 | - add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
112 | + add_action('media_buttons', array($this, 'wp_media_buttons'), 1); |
|
113 | + add_action('media_buttons', array($this, 'shortcode_insert_button')); |
|
114 | 114 | // generatepress theme sections compatibility |
115 | - if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
116 | - add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
115 | + if (function_exists('generate_sections_sections_metabox')) { |
|
116 | + add_action('generate_sections_metabox', array($this, 'shortcode_insert_button_script')); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /* Load script on Divi theme builder page */ |
120 | - if ( ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) || ( function_exists( 'et_builder_d5_enabled' ) && et_builder_d5_enabled() && isset( $_GET['et_fb'] ) && '1' === $_GET['et_fb'] && et_pb_is_allowed( 'use_visual_builder' ) ) ) { |
|
120 | + if ((function_exists('et_builder_is_tb_admin_screen') && et_builder_is_tb_admin_screen()) || (function_exists('et_builder_d5_enabled') && et_builder_d5_enabled() && isset($_GET['et_fb']) && '1' === $_GET['et_fb'] && et_pb_is_allowed('use_visual_builder'))) { |
|
121 | 121 | add_thickbox(); |
122 | - add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
122 | + add_action('admin_footer', array($this, 'shortcode_insert_button_script')); |
|
123 | 123 | } |
124 | 124 | |
125 | - if ( $this->is_preview() ) { |
|
126 | - add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
125 | + if ($this->is_preview()) { |
|
126 | + add_action('wp_footer', array($this, 'shortcode_insert_button_script')); |
|
127 | 127 | // this makes the insert button work for elementor |
128 | - add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
128 | + add_action('elementor/editor/after_enqueue_scripts', array( |
|
129 | 129 | $this, |
130 | 130 | 'shortcode_insert_button_script' |
131 | - ) ); // for elementor |
|
131 | + )); // for elementor |
|
132 | 132 | } |
133 | 133 | // this makes the insert button work for cornerstone |
134 | - add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
134 | + add_action('wp_print_footer_scripts', array(__CLASS__, 'maybe_cornerstone_builder')); |
|
135 | 135 | |
136 | - add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
137 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
136 | + add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings')); |
|
137 | + add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker')); |
|
138 | 138 | |
139 | 139 | // add generator text to head |
140 | - add_action( 'admin_head', array( $this, 'generator' ), 99 ); |
|
141 | - add_action( 'wp_head', array( $this, 'generator' ), 99 ); |
|
140 | + add_action('admin_head', array($this, 'generator'), 99); |
|
141 | + add_action('wp_head', array($this, 'generator'), 99); |
|
142 | 142 | } |
143 | 143 | |
144 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
144 | + do_action('wp_super_duper_widget_init', $options, $this); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return void |
158 | 158 | */ |
159 | 159 | public function _register() { |
160 | - if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
160 | + if (empty($this->options['output_types']) || in_array('widget', $this->options['output_types'])) { |
|
161 | 161 | parent::_register(); |
162 | 162 | } |
163 | 163 | } |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | * Add our widget CSS to elementor editor. |
167 | 167 | */ |
168 | 168 | public function elementor_editor_styles() { |
169 | - wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
169 | + wp_add_inline_style('elementor-editor', $this->widget_css(false)); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | public function register_fusion_element() { |
173 | 173 | |
174 | 174 | $options = $this->options; |
175 | 175 | |
176 | - if ( $this->base_id ) { |
|
176 | + if ($this->base_id) { |
|
177 | 177 | |
178 | 178 | $params = $this->get_fusion_params(); |
179 | 179 | |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | 'allow_generator' => true, |
185 | 185 | ); |
186 | 186 | |
187 | - if ( ! empty( $params ) ) { |
|
187 | + if (!empty($params)) { |
|
188 | 188 | $args['params'] = $params; |
189 | 189 | } |
190 | 190 | |
191 | - fusion_builder_map( $args ); |
|
191 | + fusion_builder_map($args); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | } |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | $params = array(); |
198 | 198 | $arguments = $this->get_arguments(); |
199 | 199 | |
200 | - if ( ! empty( $arguments ) ) { |
|
201 | - foreach ( $arguments as $key => $val ) { |
|
200 | + if (!empty($arguments)) { |
|
201 | + foreach ($arguments as $key => $val) { |
|
202 | 202 | $param = array(); |
203 | 203 | // type |
204 | 204 | $param['type'] = str_replace( |
@@ -220,38 +220,38 @@ discard block |
||
220 | 220 | $val['type'] ); |
221 | 221 | |
222 | 222 | // multiselect |
223 | - if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
223 | + if ($val['type'] == 'multiselect' || (($param['type'] == 'select' || $val['type'] == 'select') && !empty($val['multiple']))) { |
|
224 | 224 | $param['type'] = 'multiple_select'; |
225 | 225 | $param['multiple'] = true; |
226 | 226 | } |
227 | 227 | |
228 | 228 | // heading |
229 | - $param['heading'] = isset( $val['title'] ) ? $val['title'] : ''; |
|
229 | + $param['heading'] = isset($val['title']) ? $val['title'] : ''; |
|
230 | 230 | |
231 | 231 | // description |
232 | - $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
232 | + $param['description'] = isset($val['desc']) ? $val['desc'] : ''; |
|
233 | 233 | |
234 | 234 | // param_name |
235 | 235 | $param['param_name'] = $key; |
236 | 236 | |
237 | 237 | // Default |
238 | - $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
238 | + $param['default'] = isset($val['default']) ? $val['default'] : ''; |
|
239 | 239 | |
240 | 240 | // Group |
241 | - if ( isset( $val['group'] ) ) { |
|
241 | + if (isset($val['group'])) { |
|
242 | 242 | $param['group'] = $val['group']; |
243 | 243 | } |
244 | 244 | |
245 | 245 | // value |
246 | - if ( $val['type'] == 'checkbox' ) { |
|
247 | - if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
248 | - unset( $param['default'] ); |
|
246 | + if ($val['type'] == 'checkbox') { |
|
247 | + if (isset($val['default']) && $val['default'] == '0') { |
|
248 | + unset($param['default']); |
|
249 | 249 | } |
250 | - $param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) ); |
|
251 | - } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
252 | - $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
250 | + $param['value'] = array('0' => __("No", 'ayecode-connect'), '1' => __("Yes", 'ayecode-connect')); |
|
251 | + } elseif ($param['type'] == 'select' || $param['type'] == 'multiple_select') { |
|
252 | + $param['value'] = isset($val['options']) ? $val['options'] : array(); |
|
253 | 253 | } else { |
254 | - $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
254 | + $param['value'] = isset($val['default']) ? $val['default'] : ''; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | // setup the param |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
269 | 269 | */ |
270 | 270 | public static function maybe_cornerstone_builder() { |
271 | - if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
271 | + if (did_action('cornerstone_before_boot_app')) { |
|
272 | 272 | self::shortcode_insert_button_script(); |
273 | 273 | } |
274 | 274 | } |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return string |
282 | 282 | */ |
283 | - public static function get_picker( $editor_id = '' ) { |
|
283 | + public static function get_picker($editor_id = '') { |
|
284 | 284 | |
285 | 285 | ob_start(); |
286 | - if ( isset( $_POST['editor_id'] ) ) { |
|
287 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
288 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
286 | + if (isset($_POST['editor_id'])) { |
|
287 | + $editor_id = esc_attr($_POST['editor_id']); |
|
288 | + } elseif (isset($_REQUEST['et_fb'])) { |
|
289 | 289 | $editor_id = 'main_content_content_vb_tiny_mce'; |
290 | 290 | } |
291 | 291 | |
@@ -296,14 +296,14 @@ discard block |
||
296 | 296 | |
297 | 297 | <div class="sd-shortcode-left-wrap"> |
298 | 298 | <?php |
299 | - ksort( $sd_widgets ); |
|
299 | + ksort($sd_widgets); |
|
300 | 300 | // print_r($sd_widgets);exit; |
301 | - if ( ! empty( $sd_widgets ) ) { |
|
301 | + if (!empty($sd_widgets)) { |
|
302 | 302 | echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
303 | - echo "<option>" . __( 'Select shortcode', 'ayecode-connect' ) . "</option>"; |
|
304 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
305 | - if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; } |
|
306 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
303 | + echo "<option>" . __('Select shortcode', 'ayecode-connect') . "</option>"; |
|
304 | + foreach ($sd_widgets as $shortcode => $class) { |
|
305 | + if (!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])) { continue; } |
|
306 | + echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>"; |
|
307 | 307 | } |
308 | 308 | echo "</select>"; |
309 | 309 | |
@@ -314,32 +314,32 @@ discard block |
||
314 | 314 | <div class="sd-shortcode-right-wrap"> |
315 | 315 | <textarea id='sd-shortcode-output' disabled></textarea> |
316 | 316 | <div id='sd-shortcode-output-actions'> |
317 | - <?php if ( $editor_id != '' ) { ?> |
|
318 | - <button class="button sd-insert-shortcode-button" onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { echo "'" . $editor_id . "'"; } ?>)"><?php esc_html_e( 'Insert shortcode', 'ayecode-connect' ); ?></button> |
|
317 | + <?php if ($editor_id != '') { ?> |
|
318 | + <button class="button sd-insert-shortcode-button" onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) { echo "'" . $editor_id . "'"; } ?>)"><?php esc_html_e('Insert shortcode', 'ayecode-connect'); ?></button> |
|
319 | 319 | <?php } ?> |
320 | - <button class="button" onclick="sd_copy_to_clipboard()"><?php esc_html_e( 'Copy shortcode' ); ?></button> |
|
320 | + <button class="button" onclick="sd_copy_to_clipboard()"><?php esc_html_e('Copy shortcode'); ?></button> |
|
321 | 321 | </div> |
322 | 322 | </div> |
323 | 323 | <?php |
324 | 324 | $html = ob_get_clean(); |
325 | 325 | |
326 | - if ( wp_doing_ajax() ) { |
|
326 | + if (wp_doing_ajax()) { |
|
327 | 327 | echo $html; |
328 | 328 | $should_die = true; |
329 | 329 | |
330 | 330 | // some builder get the editor via ajax so we should not die on those occasions |
331 | 331 | $dont_die = array( |
332 | - 'parent_tag',// WP Bakery |
|
332 | + 'parent_tag', // WP Bakery |
|
333 | 333 | 'avia_request' // enfold |
334 | 334 | ); |
335 | 335 | |
336 | - foreach ( $dont_die as $request ) { |
|
337 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
336 | + foreach ($dont_die as $request) { |
|
337 | + if (isset($_REQUEST[$request])) { |
|
338 | 338 | $should_die = false; |
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
342 | - if ( $should_die ) { |
|
342 | + if ($should_die) { |
|
343 | 343 | wp_die(); |
344 | 344 | } |
345 | 345 | } else { |
@@ -353,22 +353,22 @@ discard block |
||
353 | 353 | * Output the version in the header. |
354 | 354 | */ |
355 | 355 | public function generator() { |
356 | - $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) ); |
|
357 | - $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) ); |
|
356 | + $file = str_replace(array("/", "\\"), "/", realpath(__FILE__)); |
|
357 | + $plugins_dir = str_replace(array("/", "\\"), "/", realpath(WP_PLUGIN_DIR)); |
|
358 | 358 | |
359 | 359 | // Find source plugin/theme of SD |
360 | 360 | $source = array(); |
361 | - if ( strpos( $file, $plugins_dir ) !== false ) { |
|
362 | - $source = explode( "/", plugin_basename( $file ) ); |
|
363 | - } else if ( function_exists( 'get_theme_root' ) ) { |
|
364 | - $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) ); |
|
361 | + if (strpos($file, $plugins_dir) !== false) { |
|
362 | + $source = explode("/", plugin_basename($file)); |
|
363 | + } else if (function_exists('get_theme_root')) { |
|
364 | + $themes_dir = str_replace(array("/", "\\"), "/", realpath(get_theme_root())); |
|
365 | 365 | |
366 | - if ( strpos( $file, $themes_dir ) !== false ) { |
|
367 | - $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) ); |
|
366 | + if (strpos($file, $themes_dir) !== false) { |
|
367 | + $source = explode("/", ltrim(str_replace($themes_dir, "", $file), "/")); |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
371 | - echo '<meta name="generator" content="WP Super Duper v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />'; |
|
371 | + echo '<meta name="generator" content="WP Super Duper v' . esc_attr($this->version) . '"' . (!empty($source[0]) ? ' data-sd-source="' . esc_attr($source[0]) . '"' : '') . ' />'; |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | public static function get_widget_settings() { |
380 | 380 | global $sd_widgets; |
381 | 381 | |
382 | - $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
383 | - if ( ! $shortcode ) { |
|
382 | + $shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : ''; |
|
383 | + if (!$shortcode) { |
|
384 | 384 | wp_die(); |
385 | 385 | } |
386 | - $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
387 | - if ( ! $widget_args ) { |
|
386 | + $widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : ''; |
|
387 | + if (!$widget_args) { |
|
388 | 388 | wp_die(); |
389 | 389 | } |
390 | - $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
391 | - if ( ! $class_name ) { |
|
390 | + $class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
391 | + if (!$class_name) { |
|
392 | 392 | wp_die(); |
393 | 393 | } |
394 | 394 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | $widget = new $class_name; |
397 | 397 | |
398 | 398 | ob_start(); |
399 | - $widget->form( array() ); |
|
399 | + $widget->form(array()); |
|
400 | 400 | $form = ob_get_clean(); |
401 | 401 | echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
402 | 402 | echo "<style>" . $widget->widget_css() . "</style>"; |
@@ -415,9 +415,9 @@ discard block |
||
415 | 415 | *@since 1.0.0 |
416 | 416 | * |
417 | 417 | */ |
418 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
418 | + public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') { |
|
419 | 419 | global $sd_widgets, $shortcode_insert_button_once; |
420 | - if ( $shortcode_insert_button_once ) { |
|
420 | + if ($shortcode_insert_button_once) { |
|
421 | 421 | return; |
422 | 422 | } |
423 | 423 | add_thickbox(); |
@@ -426,21 +426,21 @@ discard block |
||
426 | 426 | * Cornerstone makes us play dirty tricks :/ |
427 | 427 | * 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. |
428 | 428 | */ |
429 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
429 | + if (function_exists('cornerstone_plugin_init') && !is_admin()) { |
|
430 | 430 | echo '<span id="insert-media-button">'; |
431 | 431 | } |
432 | 432 | |
433 | - echo self::shortcode_button( 'this', 'true' ); |
|
433 | + echo self::shortcode_button('this', 'true'); |
|
434 | 434 | |
435 | 435 | // see opening note |
436 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
436 | + if (function_exists('cornerstone_plugin_init') && !is_admin()) { |
|
437 | 437 | echo '</span>'; // end #insert-media-button |
438 | 438 | } |
439 | 439 | |
440 | 440 | // Add separate script for generatepress theme sections |
441 | - if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
441 | + if (function_exists('generate_sections_sections_metabox') && did_action('generate_sections_metabox')) { |
|
442 | 442 | } else { |
443 | - self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
443 | + self::shortcode_insert_button_script($editor_id, $insert_shortcode_function); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | $shortcode_insert_button_once = true; |
@@ -454,12 +454,12 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @return mixed |
456 | 456 | */ |
457 | - public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
457 | + public static function shortcode_button($id = '', $search_for_id = '') { |
|
458 | 458 | ob_start(); |
459 | 459 | ?> |
460 | 460 | <span class="sd-lable-shortcode-inserter"> |
461 | 461 | <a onclick="sd_ajax_get_picker(<?php echo $id; |
462 | - if ( $search_for_id ) { |
|
462 | + if ($search_for_id) { |
|
463 | 463 | echo "," . $search_for_id; |
464 | 464 | } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
465 | 465 | class="thickbox button super-duper-content-open" title="Add Shortcode"> |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | $html = ob_get_clean(); |
476 | 476 | |
477 | 477 | // remove line breaks so we can use it in js |
478 | - return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
478 | + return preg_replace("/\r|\n/", "", trim($html)); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | /** |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | jQuery($this).data('sd-widget-enabled', true); |
532 | 532 | } |
533 | 533 | |
534 | - var $button = '<button title="<?php _e( 'Advanced Settings', 'ayecode-connect' );?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>'; |
|
534 | + var $button = '<button title="<?php _e('Advanced Settings', 'ayecode-connect'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>'; |
|
535 | 535 | var form = jQuery($this).parents('' + $selector + ''); |
536 | 536 | |
537 | 537 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -566,10 +566,10 @@ discard block |
||
566 | 566 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
567 | 567 | */ |
568 | 568 | |
569 | - return str_replace( array( |
|
569 | + return str_replace(array( |
|
570 | 570 | '<script>', |
571 | 571 | '</script>' |
572 | - ), '', $output ); |
|
572 | + ), '', $output); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | *@since 1.0.6 |
582 | 582 | * |
583 | 583 | */ |
584 | - public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
584 | + public static function shortcode_insert_button_script($editor_id = '', $insert_shortcode_function = '') { |
|
585 | 585 | ?> |
586 | 586 | <style> |
587 | 587 | .sd-shortcode-left-wrap { |
@@ -700,25 +700,25 @@ discard block |
||
700 | 700 | width: 100%; |
701 | 701 | } |
702 | 702 | |
703 | - <?php if ( function_exists( 'generate_sections_sections_metabox' ) ) { ?> |
|
703 | + <?php if (function_exists('generate_sections_sections_metabox')) { ?> |
|
704 | 704 | .generate-sections-modal #custom-media-buttons > .sd-lable-shortcode-inserter { |
705 | 705 | display: inline; |
706 | 706 | } |
707 | 707 | <?php } ?> |
708 | - <?php if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { ?> |
|
708 | + <?php if (function_exists('et_builder_is_tb_admin_screen') && et_builder_is_tb_admin_screen()) { ?> |
|
709 | 709 | body.divi_page_et_theme_builder div#TB_window.gd-tb-window{z-index:9999999} |
710 | 710 | <?php } ?> |
711 | 711 | </style> |
712 | 712 | <?php |
713 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
713 | + if (class_exists('SiteOrigin_Panels')) { |
|
714 | 714 | echo "<script>" . self::siteorigin_js() . "</script>"; |
715 | 715 | } |
716 | 716 | ?> |
717 | 717 | <script> |
718 | 718 | <?php |
719 | - if(! empty( $insert_shortcode_function )){ |
|
719 | + if (!empty($insert_shortcode_function)) { |
|
720 | 720 | echo $insert_shortcode_function; |
721 | - }else{ |
|
721 | + } else { |
|
722 | 722 | |
723 | 723 | /** |
724 | 724 | * Function for super duper insert shortcode. |
@@ -731,9 +731,9 @@ discard block |
||
731 | 731 | if ($shortcode) { |
732 | 732 | if (!$editor_id) { |
733 | 733 | <?php |
734 | - if ( isset( $_REQUEST['et_fb'] ) ) { |
|
734 | + if (isset($_REQUEST['et_fb'])) { |
|
735 | 735 | echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
736 | - } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
736 | + } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') { |
|
737 | 737 | echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
738 | 738 | } else { |
739 | 739 | echo '$editor_id = "#wp-content-editor-container textarea";'; |
@@ -815,11 +815,11 @@ discard block |
||
815 | 815 | 'shortcode': $short_code, |
816 | 816 | 'attributes': 123, |
817 | 817 | 'post_id': 321, |
818 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
|
818 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>' |
|
819 | 819 | }; |
820 | 820 | |
821 | 821 | if (typeof ajaxurl === 'undefined') { |
822 | - var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>"; |
|
822 | + var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | jQuery.post(ajaxurl, data, function (response) { |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | }); |
945 | 945 | |
946 | 946 | // The below tries to add the shortcode builder button to the builders own raw/shortcode sections. |
947 | - <?php if ( function_exists( 'et_setup_theme' ) ) { ?> |
|
947 | + <?php if (function_exists('et_setup_theme')) { ?> |
|
948 | 948 | // DIVI |
949 | 949 | jQuery(document).on('focusin', '.et-fb-codemirror', function () { |
950 | 950 | // insert the shortcode button to the textarea lable if not there already |
@@ -1036,11 +1036,11 @@ discard block |
||
1036 | 1036 | var data = { |
1037 | 1037 | 'action': 'super_duper_get_picker', |
1038 | 1038 | 'editor_id': $id, |
1039 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_picker' );?>' |
|
1039 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_picker'); ?>' |
|
1040 | 1040 | }; |
1041 | 1041 | |
1042 | 1042 | if (!ajaxurl) { |
1043 | - var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>"; |
|
1043 | + var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | jQuery.post(ajaxurl, data, function (response) { |
@@ -1062,9 +1062,9 @@ discard block |
||
1062 | 1062 | */ |
1063 | 1063 | function sd_shortcode_button($id) { |
1064 | 1064 | if ($id) { |
1065 | - return '<?php echo self::shortcode_button( "\\''+\$id+'\\'" );?>'; |
|
1065 | + return '<?php echo self::shortcode_button("\\''+\$id+'\\'"); ?>'; |
|
1066 | 1066 | } else { |
1067 | - return '<?php echo self::shortcode_button();?>'; |
|
1067 | + return '<?php echo self::shortcode_button(); ?>'; |
|
1068 | 1068 | } |
1069 | 1069 | } |
1070 | 1070 | </script> |
@@ -1078,11 +1078,11 @@ discard block |
||
1078 | 1078 | * |
1079 | 1079 | * @return mixed |
1080 | 1080 | */ |
1081 | - public function widget_css( $advanced = true ) { |
|
1081 | + public function widget_css($advanced = true) { |
|
1082 | 1082 | ob_start(); |
1083 | 1083 | ?> |
1084 | 1084 | <style> |
1085 | - <?php if( $advanced ){ ?> |
|
1085 | + <?php if ($advanced) { ?> |
|
1086 | 1086 | .sd-advanced-setting { |
1087 | 1087 | display: none; |
1088 | 1088 | } |
@@ -1126,10 +1126,10 @@ discard block |
||
1126 | 1126 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1127 | 1127 | */ |
1128 | 1128 | |
1129 | - return str_replace( array( |
|
1129 | + return str_replace(array( |
|
1130 | 1130 | '<style>', |
1131 | 1131 | '</style>' |
1132 | - ), '', $output ); |
|
1132 | + ), '', $output); |
|
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | /** |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | jQuery($this).data('sd-widget-enabled', true); |
1197 | 1197 | } |
1198 | 1198 | |
1199 | - var $button = '<button title="<?php _e( 'Advanced Settings', 'ayecode-connect' );?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>'; |
|
1199 | + var $button = '<button title="<?php _e('Advanced Settings', 'ayecode-connect'); ?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>'; |
|
1200 | 1200 | var form = $form ? $form : jQuery($this).parents('' + $selector + ''); |
1201 | 1201 | |
1202 | 1202 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -1287,7 +1287,7 @@ discard block |
||
1287 | 1287 | }); |
1288 | 1288 | |
1289 | 1289 | } |
1290 | - <?php do_action( 'wp_super_duper_widget_js', $this ); ?> |
|
1290 | + <?php do_action('wp_super_duper_widget_js', $this); ?> |
|
1291 | 1291 | </script> |
1292 | 1292 | <?php |
1293 | 1293 | $output = ob_get_clean(); |
@@ -1296,10 +1296,10 @@ discard block |
||
1296 | 1296 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1297 | 1297 | */ |
1298 | 1298 | |
1299 | - return str_replace( array( |
|
1299 | + return str_replace(array( |
|
1300 | 1300 | '<script>', |
1301 | 1301 | '</script>' |
1302 | - ), '', $output ); |
|
1302 | + ), '', $output); |
|
1303 | 1303 | } |
1304 | 1304 | |
1305 | 1305 | |
@@ -1310,14 +1310,14 @@ discard block |
||
1310 | 1310 | * |
1311 | 1311 | * @return mixed |
1312 | 1312 | */ |
1313 | - private function add_name_from_key( $options, $arguments = false ) { |
|
1314 | - if ( ! empty( $options['arguments'] ) ) { |
|
1315 | - foreach ( $options['arguments'] as $key => $val ) { |
|
1316 | - $options['arguments'][ $key ]['name'] = $key; |
|
1313 | + private function add_name_from_key($options, $arguments = false) { |
|
1314 | + if (!empty($options['arguments'])) { |
|
1315 | + foreach ($options['arguments'] as $key => $val) { |
|
1316 | + $options['arguments'][$key]['name'] = $key; |
|
1317 | 1317 | } |
1318 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
1319 | - foreach ( $options as $key => $val ) { |
|
1320 | - $options[ $key ]['name'] = $key; |
|
1318 | + } elseif ($arguments && is_array($options) && !empty($options)) { |
|
1319 | + foreach ($options as $key => $val) { |
|
1320 | + $options[$key]['name'] = $key; |
|
1321 | 1321 | } |
1322 | 1322 | } |
1323 | 1323 | |
@@ -1330,8 +1330,8 @@ discard block |
||
1330 | 1330 | * @since 1.0.0 |
1331 | 1331 | */ |
1332 | 1332 | public function register_shortcode() { |
1333 | - add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
1334 | - add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) ); |
|
1333 | + add_shortcode($this->base_id, array($this, 'shortcode_output')); |
|
1334 | + add_action('wp_ajax_super_duper_output_shortcode', array($this, 'render_shortcode')); |
|
1335 | 1335 | } |
1336 | 1336 | |
1337 | 1337 | /** |
@@ -1340,50 +1340,50 @@ discard block |
||
1340 | 1340 | * @since 1.0.0 |
1341 | 1341 | */ |
1342 | 1342 | public function render_shortcode() { |
1343 | - check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
1344 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
1343 | + check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true); |
|
1344 | + if (!current_user_can('manage_options')) { |
|
1345 | 1345 | wp_die(); |
1346 | 1346 | } |
1347 | 1347 | |
1348 | 1348 | // we might need the $post value here so lets set it. |
1349 | - if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
1350 | - $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
1351 | - if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
1349 | + if (isset($_POST['post_id']) && $_POST['post_id']) { |
|
1350 | + $post_obj = get_post(absint($_POST['post_id'])); |
|
1351 | + if (!empty($post_obj) && empty($post)) { |
|
1352 | 1352 | global $post; |
1353 | 1353 | $post = $post_obj; |
1354 | 1354 | } |
1355 | 1355 | } |
1356 | 1356 | |
1357 | - if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
1357 | + if (isset($_POST['shortcode']) && $_POST['shortcode']) { |
|
1358 | 1358 | $is_preview = $this->is_preview(); |
1359 | - $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
1360 | - $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
1359 | + $shortcode_name = sanitize_title_with_dashes($_POST['shortcode']); |
|
1360 | + $attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
1361 | 1361 | $attributes = ''; |
1362 | - if ( ! empty( $attributes_array ) ) { |
|
1363 | - foreach ( $attributes_array as $key => $value ) { |
|
1364 | - if ( is_array( $value ) ) { |
|
1365 | - $value = implode( ",", $value ); |
|
1362 | + if (!empty($attributes_array)) { |
|
1363 | + foreach ($attributes_array as $key => $value) { |
|
1364 | + if (is_array($value)) { |
|
1365 | + $value = implode(",", $value); |
|
1366 | 1366 | } |
1367 | 1367 | |
1368 | - if ( ! empty( $value ) ) { |
|
1369 | - $value = wp_unslash( $value ); |
|
1368 | + if (!empty($value)) { |
|
1369 | + $value = wp_unslash($value); |
|
1370 | 1370 | |
1371 | 1371 | // Encode [ and ]. |
1372 | - if ( $is_preview ) { |
|
1373 | - $value = $this->encode_shortcodes( $value ); |
|
1372 | + if ($is_preview) { |
|
1373 | + $value = $this->encode_shortcodes($value); |
|
1374 | 1374 | } |
1375 | 1375 | } |
1376 | - $attributes .= " " . esc_attr( sanitize_title_with_dashes( $key ) ) . "='" . esc_attr( $value ) . "' "; |
|
1376 | + $attributes .= " " . esc_attr(sanitize_title_with_dashes($key)) . "='" . esc_attr($value) . "' "; |
|
1377 | 1377 | } |
1378 | 1378 | } |
1379 | 1379 | |
1380 | - $shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]"; |
|
1380 | + $shortcode = "[" . esc_attr($shortcode_name) . " " . $attributes . "]"; |
|
1381 | 1381 | |
1382 | - $content = do_shortcode( $shortcode ); |
|
1382 | + $content = do_shortcode($shortcode); |
|
1383 | 1383 | |
1384 | 1384 | // Decode [ and ]. |
1385 | - if ( ! empty( $content ) && $is_preview ) { |
|
1386 | - $content = $this->decode_shortcodes( $content ); |
|
1385 | + if (!empty($content) && $is_preview) { |
|
1386 | + $content = $this->decode_shortcodes($content); |
|
1387 | 1387 | } |
1388 | 1388 | |
1389 | 1389 | echo $content; |
@@ -1399,21 +1399,21 @@ discard block |
||
1399 | 1399 | * |
1400 | 1400 | * @return string |
1401 | 1401 | */ |
1402 | - public function shortcode_output( $args = array(), $content = '' ) { |
|
1402 | + public function shortcode_output($args = array(), $content = '') { |
|
1403 | 1403 | $_instance = $args; |
1404 | 1404 | |
1405 | - $args = $this->argument_values( $args ); |
|
1405 | + $args = $this->argument_values($args); |
|
1406 | 1406 | |
1407 | 1407 | // add extra argument so we know its a output to gutenberg |
1408 | 1408 | //$args |
1409 | - $args = $this->string_to_bool( $args ); |
|
1409 | + $args = $this->string_to_bool($args); |
|
1410 | 1410 | |
1411 | 1411 | // if we have a enclosed shortcode we add it to the special `html` argument |
1412 | - if ( ! empty( $content ) ) { |
|
1412 | + if (!empty($content)) { |
|
1413 | 1413 | $args['html'] = $content; |
1414 | 1414 | } |
1415 | 1415 | |
1416 | - if ( ! $this->is_preview() ) { |
|
1416 | + if (!$this->is_preview()) { |
|
1417 | 1417 | /** |
1418 | 1418 | * Filters the settings for a particular widget args. |
1419 | 1419 | * |
@@ -1424,40 +1424,40 @@ discard block |
||
1424 | 1424 | *@since 1.0.28 |
1425 | 1425 | * |
1426 | 1426 | */ |
1427 | - $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance ); |
|
1427 | + $args = apply_filters('wp_super_duper_widget_display_callback', $args, $this, $_instance); |
|
1428 | 1428 | |
1429 | - if ( ! is_array( $args ) ) { |
|
1429 | + if (!is_array($args)) { |
|
1430 | 1430 | return $args; |
1431 | 1431 | } |
1432 | 1432 | } |
1433 | 1433 | |
1434 | - $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
1435 | - $class .= " sdel-".$this->get_instance_hash(); |
|
1434 | + $class = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : ''; |
|
1435 | + $class .= " sdel-" . $this->get_instance_hash(); |
|
1436 | 1436 | |
1437 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
1438 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
1437 | + $class = apply_filters('wp_super_duper_div_classname', $class, $args, $this); |
|
1438 | + $class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this); |
|
1439 | 1439 | |
1440 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
1441 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
1440 | + $attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this); |
|
1441 | + $attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this); |
|
1442 | 1442 | |
1443 | 1443 | $shortcode_args = array(); |
1444 | 1444 | $output = ''; |
1445 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
1446 | - if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
1445 | + $no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false; |
|
1446 | + if (isset($args['no_wrap']) && $args['no_wrap']) { |
|
1447 | 1447 | $no_wrap = true; |
1448 | 1448 | } |
1449 | - $main_content = $this->output( $args, $shortcode_args, $content ); |
|
1450 | - if ( $main_content && ! $no_wrap ) { |
|
1449 | + $main_content = $this->output($args, $shortcode_args, $content); |
|
1450 | + if ($main_content && !$no_wrap) { |
|
1451 | 1451 | // wrap the shortcode in a div with the same class as the widget |
1452 | 1452 | $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
1453 | - if ( ! empty( $args['title'] ) ) { |
|
1453 | + if (!empty($args['title'])) { |
|
1454 | 1454 | // if its a shortcode and there is a title try to grab the title wrappers |
1455 | - $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
1456 | - if ( empty( $instance ) ) { |
|
1455 | + $shortcode_args = array('before_title' => '', 'after_title' => ''); |
|
1456 | + if (empty($instance)) { |
|
1457 | 1457 | global $wp_registered_sidebars; |
1458 | - if ( ! empty( $wp_registered_sidebars ) ) { |
|
1459 | - foreach ( $wp_registered_sidebars as $sidebar ) { |
|
1460 | - if ( ! empty( $sidebar['before_title'] ) ) { |
|
1458 | + if (!empty($wp_registered_sidebars)) { |
|
1459 | + foreach ($wp_registered_sidebars as $sidebar) { |
|
1460 | + if (!empty($sidebar['before_title'])) { |
|
1461 | 1461 | $shortcode_args['before_title'] = $sidebar['before_title']; |
1462 | 1462 | $shortcode_args['after_title'] = $sidebar['after_title']; |
1463 | 1463 | break; |
@@ -1465,20 +1465,20 @@ discard block |
||
1465 | 1465 | } |
1466 | 1466 | } |
1467 | 1467 | } |
1468 | - $output .= $this->output_title( $shortcode_args, $args ); |
|
1468 | + $output .= $this->output_title($shortcode_args, $args); |
|
1469 | 1469 | } |
1470 | 1470 | $output .= $main_content; |
1471 | 1471 | $output .= '</div>'; |
1472 | - } elseif ( $main_content && $no_wrap ) { |
|
1472 | + } elseif ($main_content && $no_wrap) { |
|
1473 | 1473 | $output .= $main_content; |
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | // if preview show a placeholder if empty |
1477 | - if ( $this->is_preview() && $output == '' ) { |
|
1478 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
1477 | + if ($this->is_preview() && $output == '') { |
|
1478 | + $output = $this->preview_placeholder_text("{{" . $this->base_id . "}}"); |
|
1479 | 1479 | } |
1480 | 1480 | |
1481 | - return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
1481 | + return apply_filters('wp_super_duper_widget_output', $output, $args, $shortcode_args, $this); |
|
1482 | 1482 | } |
1483 | 1483 | |
1484 | 1484 | /** |
@@ -1488,8 +1488,8 @@ discard block |
||
1488 | 1488 | * |
1489 | 1489 | * @return string |
1490 | 1490 | */ |
1491 | - public function preview_placeholder_text( $name = '' ) { |
|
1492 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "</div>"; |
|
1491 | + public function preview_placeholder_text($name = '') { |
|
1492 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf(__('Placeholder for: %s', 'ayecode-connect'), $name) . "</div>"; |
|
1493 | 1493 | } |
1494 | 1494 | |
1495 | 1495 | /** |
@@ -1499,13 +1499,13 @@ discard block |
||
1499 | 1499 | * |
1500 | 1500 | * @return mixed |
1501 | 1501 | */ |
1502 | - public function string_to_bool( $options ) { |
|
1502 | + public function string_to_bool($options) { |
|
1503 | 1503 | // convert bool strings to booleans |
1504 | - foreach ( $options as $key => $val ) { |
|
1505 | - if ( $val == 'false' ) { |
|
1506 | - $options[ $key ] = false; |
|
1507 | - } elseif ( $val == 'true' ) { |
|
1508 | - $options[ $key ] = true; |
|
1504 | + foreach ($options as $key => $val) { |
|
1505 | + if ($val == 'false') { |
|
1506 | + $options[$key] = false; |
|
1507 | + } elseif ($val == 'true') { |
|
1508 | + $options[$key] = true; |
|
1509 | 1509 | } |
1510 | 1510 | } |
1511 | 1511 | |
@@ -1521,26 +1521,26 @@ discard block |
||
1521 | 1521 | *@since 1.0.12 Don't set checkbox default value if the value is empty. |
1522 | 1522 | * |
1523 | 1523 | */ |
1524 | - public function argument_values( $instance ) { |
|
1524 | + public function argument_values($instance) { |
|
1525 | 1525 | $argument_values = array(); |
1526 | 1526 | |
1527 | 1527 | // set widget instance |
1528 | 1528 | $this->instance = $instance; |
1529 | 1529 | |
1530 | - if ( empty( $this->arguments ) ) { |
|
1530 | + if (empty($this->arguments)) { |
|
1531 | 1531 | $this->arguments = $this->get_arguments(); |
1532 | 1532 | } |
1533 | 1533 | |
1534 | - if ( ! empty( $this->arguments ) ) { |
|
1535 | - foreach ( $this->arguments as $key => $args ) { |
|
1534 | + if (!empty($this->arguments)) { |
|
1535 | + foreach ($this->arguments as $key => $args) { |
|
1536 | 1536 | // set the input name from the key |
1537 | 1537 | $args['name'] = $key; |
1538 | 1538 | // |
1539 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
1540 | - if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
1539 | + $argument_values[$key] = isset($instance[$key]) ? $instance[$key] : ''; |
|
1540 | + if ($args['type'] == 'checkbox' && $argument_values[$key] == '') { |
|
1541 | 1541 | // don't set default for an empty checkbox |
1542 | - } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
1543 | - $argument_values[ $key ] = $args['default']; |
|
1542 | + } elseif ($argument_values[$key] == '' && isset($args['default'])) { |
|
1543 | + $argument_values[$key] = $args['default']; |
|
1544 | 1544 | } |
1545 | 1545 | } |
1546 | 1546 | } |
@@ -1567,15 +1567,15 @@ discard block |
||
1567 | 1567 | * |
1568 | 1568 | */ |
1569 | 1569 | public function get_arguments() { |
1570 | - if ( empty( $this->arguments ) ) { |
|
1570 | + if (empty($this->arguments)) { |
|
1571 | 1571 | $this->arguments = $this->set_arguments(); |
1572 | 1572 | } |
1573 | 1573 | |
1574 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
1575 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
1574 | + $this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance); |
|
1575 | + $this->arguments = $this->add_name_from_key($this->arguments, true); |
|
1576 | 1576 | |
1577 | - if( !empty( $this->arguments['title']['value'] ) ){ |
|
1578 | - $this->arguments['title']['value'] = wp_kses_post( $this->arguments['title']['value'] ); |
|
1577 | + if (!empty($this->arguments['title']['value'])) { |
|
1578 | + $this->arguments['title']['value'] = wp_kses_post($this->arguments['title']['value']); |
|
1579 | 1579 | } |
1580 | 1580 | |
1581 | 1581 | return $this->arguments; |
@@ -1588,7 +1588,7 @@ discard block |
||
1588 | 1588 | * @param array $widget_args |
1589 | 1589 | * @param string $content |
1590 | 1590 | */ |
1591 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
1591 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
1592 | 1592 | |
1593 | 1593 | } |
1594 | 1594 | |
@@ -1596,9 +1596,9 @@ discard block |
||
1596 | 1596 | * Add the dynamic block code inline when the wp-block in enqueued. |
1597 | 1597 | */ |
1598 | 1598 | public function register_block() { |
1599 | - wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
1600 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
1601 | - wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
1599 | + wp_add_inline_script('wp-blocks', $this->block()); |
|
1600 | + if (class_exists('SiteOrigin_Panels')) { |
|
1601 | + wp_add_inline_script('wp-blocks', $this->siteorigin_js()); |
|
1602 | 1602 | } |
1603 | 1603 | } |
1604 | 1604 | |
@@ -1612,9 +1612,9 @@ discard block |
||
1612 | 1612 | $show = false; |
1613 | 1613 | $arguments = $this->get_arguments(); |
1614 | 1614 | |
1615 | - if ( ! empty( $arguments ) ) { |
|
1616 | - foreach ( $arguments as $argument ) { |
|
1617 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
1615 | + if (!empty($arguments)) { |
|
1616 | + foreach ($arguments as $argument) { |
|
1617 | + if (isset($argument['advanced']) && $argument['advanced']) { |
|
1618 | 1618 | $show = true; |
1619 | 1619 | break; // no need to continue if we know we have it |
1620 | 1620 | } |
@@ -1632,19 +1632,19 @@ discard block |
||
1632 | 1632 | public function get_url() { |
1633 | 1633 | $url = $this->url; |
1634 | 1634 | |
1635 | - if ( ! $url ) { |
|
1636 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
1637 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
1635 | + if (!$url) { |
|
1636 | + $content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR)); |
|
1637 | + $content_url = untrailingslashit(WP_CONTENT_URL); |
|
1638 | 1638 | |
1639 | 1639 | // Replace http:// to https://. |
1640 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
1641 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
1640 | + if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) { |
|
1641 | + $content_url = str_replace('http://', 'https://', $content_url); |
|
1642 | 1642 | } |
1643 | 1643 | |
1644 | 1644 | // Check if we are inside a plugin |
1645 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
1646 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
1647 | - $url = trailingslashit( $url ); |
|
1645 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
1646 | + $url = str_replace($content_dir, $content_url, $file_dir); |
|
1647 | + $url = trailingslashit($url); |
|
1648 | 1648 | $this->url = $url; |
1649 | 1649 | } |
1650 | 1650 | |
@@ -1660,15 +1660,15 @@ discard block |
||
1660 | 1660 | |
1661 | 1661 | $url = $this->url; |
1662 | 1662 | |
1663 | - if ( ! $url ) { |
|
1663 | + if (!$url) { |
|
1664 | 1664 | // check if we are inside a plugin |
1665 | - $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
1665 | + $file_dir = str_replace("/includes", "", dirname(__FILE__)); |
|
1666 | 1666 | |
1667 | - $dir_parts = explode( "/wp-content/", $file_dir ); |
|
1668 | - $url_parts = explode( "/wp-content/", plugins_url() ); |
|
1667 | + $dir_parts = explode("/wp-content/", $file_dir); |
|
1668 | + $url_parts = explode("/wp-content/", plugins_url()); |
|
1669 | 1669 | |
1670 | - if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
1671 | - $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
1670 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
1671 | + $url = trailingslashit($url_parts[0] . "/wp-content/" . $dir_parts[1]); |
|
1672 | 1672 | $this->url = $url; |
1673 | 1673 | } |
1674 | 1674 | } |
@@ -1689,45 +1689,45 @@ discard block |
||
1689 | 1689 | * @return string |
1690 | 1690 | *@since 1.1.0 |
1691 | 1691 | */ |
1692 | - public function get_block_icon( $icon ) { |
|
1692 | + public function get_block_icon($icon) { |
|
1693 | 1693 | |
1694 | 1694 | // check if we have a Font Awesome icon |
1695 | 1695 | $fa_type = ''; |
1696 | - if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
1696 | + if (substr($icon, 0, 7) === "fas fa-") { |
|
1697 | 1697 | $fa_type = 'solid'; |
1698 | - } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
1698 | + } elseif (substr($icon, 0, 7) === "far fa-") { |
|
1699 | 1699 | $fa_type = 'regular'; |
1700 | - } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
1700 | + } elseif (substr($icon, 0, 7) === "fab fa-") { |
|
1701 | 1701 | $fa_type = 'brands'; |
1702 | 1702 | } else { |
1703 | 1703 | $icon = "'" . $icon . "'"; |
1704 | 1704 | } |
1705 | 1705 | |
1706 | 1706 | // set the icon if we found one |
1707 | - if ( $fa_type ) { |
|
1708 | - $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
1707 | + if ($fa_type) { |
|
1708 | + $fa_icon = str_replace(array("fas fa-", "far fa-", "fab fa-"), "", $icon); |
|
1709 | 1709 | $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 . "'}))"; |
1710 | 1710 | } |
1711 | 1711 | |
1712 | 1712 | return $icon; |
1713 | 1713 | } |
1714 | 1714 | |
1715 | - public function group_arguments( $arguments ) { |
|
1716 | - if ( ! empty( $arguments ) ) { |
|
1715 | + public function group_arguments($arguments) { |
|
1716 | + if (!empty($arguments)) { |
|
1717 | 1717 | $temp_arguments = array(); |
1718 | - $general = __( "General", 'ayecode-connect' ); |
|
1718 | + $general = __("General", 'ayecode-connect'); |
|
1719 | 1719 | $add_sections = false; |
1720 | - foreach ( $arguments as $key => $args ) { |
|
1721 | - if ( isset( $args['group'] ) ) { |
|
1722 | - $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
1720 | + foreach ($arguments as $key => $args) { |
|
1721 | + if (isset($args['group'])) { |
|
1722 | + $temp_arguments[$args['group']][$key] = $args; |
|
1723 | 1723 | $add_sections = true; |
1724 | 1724 | } else { |
1725 | - $temp_arguments[ $general ][ $key ] = $args; |
|
1725 | + $temp_arguments[$general][$key] = $args; |
|
1726 | 1726 | } |
1727 | 1727 | } |
1728 | 1728 | |
1729 | 1729 | // only add sections if more than one |
1730 | - if ( $add_sections ) { |
|
1730 | + if ($add_sections) { |
|
1731 | 1731 | $arguments = $temp_arguments; |
1732 | 1732 | } |
1733 | 1733 | } |
@@ -1740,38 +1740,38 @@ discard block |
||
1740 | 1740 | * |
1741 | 1741 | * @since 1.1.17 |
1742 | 1742 | */ |
1743 | - public function group_block_tabs( $tabs, $arguments ) { |
|
1744 | - if ( ! empty( $tabs ) && ! empty( $arguments ) ) { |
|
1743 | + public function group_block_tabs($tabs, $arguments) { |
|
1744 | + if (!empty($tabs) && !empty($arguments)) { |
|
1745 | 1745 | $has_sections = false; |
1746 | 1746 | |
1747 | - foreach ( $this->arguments as $key => $args ) { |
|
1748 | - if ( isset( $args['group'] ) ) { |
|
1747 | + foreach ($this->arguments as $key => $args) { |
|
1748 | + if (isset($args['group'])) { |
|
1749 | 1749 | $has_sections = true; |
1750 | 1750 | break; |
1751 | 1751 | } |
1752 | 1752 | } |
1753 | 1753 | |
1754 | - if ( ! $has_sections ) { |
|
1754 | + if (!$has_sections) { |
|
1755 | 1755 | return $tabs; |
1756 | 1756 | } |
1757 | 1757 | |
1758 | 1758 | $new_tabs = array(); |
1759 | 1759 | |
1760 | - foreach ( $tabs as $tab_key => $tab ) { |
|
1760 | + foreach ($tabs as $tab_key => $tab) { |
|
1761 | 1761 | $new_groups = array(); |
1762 | 1762 | |
1763 | - if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) { |
|
1764 | - foreach ( $tab['groups'] as $group ) { |
|
1765 | - if ( isset( $arguments[ $group ] ) ) { |
|
1763 | + if (!empty($tab['groups']) && is_array($tab['groups'])) { |
|
1764 | + foreach ($tab['groups'] as $group) { |
|
1765 | + if (isset($arguments[$group])) { |
|
1766 | 1766 | $new_groups[] = $group; |
1767 | 1767 | } |
1768 | 1768 | } |
1769 | 1769 | } |
1770 | 1770 | |
1771 | - if ( ! empty( $new_groups ) ) { |
|
1771 | + if (!empty($new_groups)) { |
|
1772 | 1772 | $tab['groups'] = $new_groups; |
1773 | 1773 | |
1774 | - $new_tabs[ $tab_key ] = $tab; |
|
1774 | + $new_tabs[$tab_key] = $tab; |
|
1775 | 1775 | } |
1776 | 1776 | } |
1777 | 1777 | |
@@ -1798,7 +1798,7 @@ discard block |
||
1798 | 1798 | ?> |
1799 | 1799 | <script> |
1800 | 1800 | <?php |
1801 | - if ( ! $sd_is_js_functions_loaded ) { |
|
1801 | + if (!$sd_is_js_functions_loaded) { |
|
1802 | 1802 | $sd_is_js_functions_loaded = true; |
1803 | 1803 | ?> |
1804 | 1804 | function sd_show_view_options($this){ |
@@ -2121,7 +2121,7 @@ discard block |
||
2121 | 2121 | } |
2122 | 2122 | } |
2123 | 2123 | |
2124 | -<?php if( !isset( $_REQUEST['sd-block-recover-debug'] ) ){ ?> |
|
2124 | +<?php if (!isset($_REQUEST['sd-block-recover-debug'])) { ?> |
|
2125 | 2125 | // Wait will window is loaded before calling. |
2126 | 2126 | window.onload = function() { |
2127 | 2127 | sd_auto_recover_blocks(); |
@@ -2300,7 +2300,7 @@ discard block |
||
2300 | 2300 | $classes = []; |
2301 | 2301 | |
2302 | 2302 | <?php |
2303 | - if($aui_bs5){ |
|
2303 | + if ($aui_bs5) { |
|
2304 | 2304 | ?> |
2305 | 2305 | $aui_bs5 = true; |
2306 | 2306 | $p_ml = 'ms-'; |
@@ -2309,7 +2309,7 @@ discard block |
||
2309 | 2309 | $p_pl = 'ps-'; |
2310 | 2310 | $p_pr = 'pe-'; |
2311 | 2311 | <?php |
2312 | - }else{ |
|
2312 | + } else { |
|
2313 | 2313 | ?> |
2314 | 2314 | $aui_bs5 = false; |
2315 | 2315 | $p_ml = 'ml-'; |
@@ -2497,7 +2497,7 @@ discard block |
||
2497 | 2497 | } |
2498 | 2498 | |
2499 | 2499 | function sd_get_class_build_keys(){ |
2500 | - return <?php echo json_encode(sd_get_class_build_keys());?>; |
|
2500 | + return <?php echo json_encode(sd_get_class_build_keys()); ?>; |
|
2501 | 2501 | } |
2502 | 2502 | |
2503 | 2503 | <?php |
@@ -2505,7 +2505,7 @@ discard block |
||
2505 | 2505 | |
2506 | 2506 | } |
2507 | 2507 | |
2508 | - if(method_exists($this,'block_global_js')){ |
|
2508 | + if (method_exists($this, 'block_global_js')) { |
|
2509 | 2509 | echo $this->block_global_js(); |
2510 | 2510 | } |
2511 | 2511 | ?> |
@@ -2537,9 +2537,9 @@ discard block |
||
2537 | 2537 | var InnerBlocks = blockEditor.InnerBlocks; |
2538 | 2538 | |
2539 | 2539 | var term_query_type = ''; |
2540 | - 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 "[]";} ?>; |
|
2541 | - const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}]; |
|
2542 | - const sort_by_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}]; |
|
2540 | + 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 "[]"; } ?>; |
|
2541 | + const taxonomies_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}]; |
|
2542 | + const sort_by_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}]; |
|
2543 | 2543 | const MediaUpload = wp.blockEditor.MediaUpload; |
2544 | 2544 | |
2545 | 2545 | /** |
@@ -2554,87 +2554,87 @@ discard block |
||
2554 | 2554 | * @return {?WPBlock} The block, if it has been successfully |
2555 | 2555 | * registered; otherwise `undefined`. |
2556 | 2556 | */ |
2557 | - 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. |
|
2558 | - apiVersion: <?php echo isset($this->options['block-api-version']) ? absint($this->options['block-api-version']) : 2 ; ?>, |
|
2559 | - title: '<?php echo addslashes( $this->options['name'] ); ?>', // Block title. |
|
2560 | - description: '<?php echo addslashes( $this->options['widget_ops']['description'] )?>', // Block title. |
|
2561 | - 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/. |
|
2557 | + 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. |
|
2558 | + apiVersion: <?php echo isset($this->options['block-api-version']) ? absint($this->options['block-api-version']) : 2; ?>, |
|
2559 | + title: '<?php echo addslashes($this->options['name']); ?>', // Block title. |
|
2560 | + description: '<?php echo addslashes($this->options['widget_ops']['description'])?>', // Block title. |
|
2561 | + 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/. |
|
2562 | 2562 | supports: { |
2563 | 2563 | <?php |
2564 | - if(!isset($this->options['block-supports']['renaming'])){ |
|
2564 | + if (!isset($this->options['block-supports']['renaming'])) { |
|
2565 | 2565 | $this->options['block-supports']['renaming'] = false; |
2566 | 2566 | } |
2567 | - if ( isset( $this->options['block-supports'] ) ) { |
|
2568 | - echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
2567 | + if (isset($this->options['block-supports'])) { |
|
2568 | + echo $this->array_to_attributes($this->options['block-supports']); |
|
2569 | 2569 | } |
2570 | 2570 | ?> |
2571 | 2571 | }, |
2572 | 2572 | __experimentalLabel( attributes, { context } ) { |
2573 | 2573 | var visibility_html = attributes && attributes.visibility_conditions ? ' 👁' : ''; |
2574 | 2574 | var metadata_name = attributes && attributes.metadata && attributes.metadata.name ? attributes.metadata.name : ''; |
2575 | - var label_name = <?php echo !empty($this->options['block-label']) ? $this->options['block-label'] : "'" . esc_attr( addslashes( $this->options['name'] ) ) . "'"; ?>; |
|
2575 | + var label_name = <?php echo !empty($this->options['block-label']) ? $this->options['block-label'] : "'" . esc_attr(addslashes($this->options['name'])) . "'"; ?>; |
|
2576 | 2576 | return metadata_name ? metadata_name + visibility_html : label_name + visibility_html; |
2577 | 2577 | }, |
2578 | - 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. |
|
2579 | - <?php if ( isset( $this->options['block-keywords'] ) ) { |
|
2578 | + 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. |
|
2579 | + <?php if (isset($this->options['block-keywords'])) { |
|
2580 | 2580 | echo "keywords : " . $this->options['block-keywords'] . ","; |
2581 | 2581 | } |
2582 | 2582 | |
2583 | 2583 | |
2584 | 2584 | // block hover preview. |
2585 | 2585 | $example_args = array(); |
2586 | - if(!empty($this->arguments)){ |
|
2587 | - foreach($this->arguments as $key => $a_args){ |
|
2588 | - if(isset($a_args['example'])){ |
|
2586 | + if (!empty($this->arguments)) { |
|
2587 | + foreach ($this->arguments as $key => $a_args) { |
|
2588 | + if (isset($a_args['example'])) { |
|
2589 | 2589 | $example_args[$key] = $a_args['example']; |
2590 | 2590 | } |
2591 | 2591 | } |
2592 | 2592 | } |
2593 | - $viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : ''; |
|
2593 | + $viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: ' . absint($this->options['example']['viewportWidth']) : ''; |
|
2594 | 2594 | $example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : ''; |
2595 | - if( isset( $this->options['example'] ) && $this->options['example'] === false ){ |
|
2595 | + if (isset($this->options['example']) && $this->options['example'] === false) { |
|
2596 | 2596 | // no preview if set to false |
2597 | - }elseif( !empty( $example_args ) ){ |
|
2598 | - echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},"; |
|
2599 | - }elseif( !empty( $this->options['example'] ) ){ |
|
2597 | + }elseif (!empty($example_args)) { |
|
2598 | + echo "example : {attributes:{" . $this->array_to_attributes($example_args) . "},$viewport_width},"; |
|
2599 | + }elseif (!empty($this->options['example'])) { |
|
2600 | 2600 | unset($this->options['example']['viewportWidth']); |
2601 | 2601 | unset($this->options['example']['innerBlocks']); |
2602 | - $example_atts = $this->array_to_attributes( $this->options['example'] ); |
|
2602 | + $example_atts = $this->array_to_attributes($this->options['example']); |
|
2603 | 2603 | $example_parts = array(); |
2604 | - if($example_atts){ |
|
2605 | - $example_parts[] = rtrim($example_atts,","); |
|
2604 | + if ($example_atts) { |
|
2605 | + $example_parts[] = rtrim($example_atts, ","); |
|
2606 | 2606 | } |
2607 | - if($viewport_width){ |
|
2607 | + if ($viewport_width) { |
|
2608 | 2608 | $example_parts[] = $viewport_width; |
2609 | 2609 | } |
2610 | - if($example_inner_blocks){ |
|
2610 | + if ($example_inner_blocks) { |
|
2611 | 2611 | $example_parts[] = $example_inner_blocks; |
2612 | 2612 | } |
2613 | - if(!empty($example_parts)){ |
|
2614 | - echo "example : {".implode(',', $example_parts)."},"; |
|
2613 | + if (!empty($example_parts)) { |
|
2614 | + echo "example : {" . implode(',', $example_parts) . "},"; |
|
2615 | 2615 | } |
2616 | - }else{ |
|
2616 | + } else { |
|
2617 | 2617 | echo 'example : {viewportWidth: 500},'; |
2618 | 2618 | } |
2619 | 2619 | |
2620 | 2620 | |
2621 | 2621 | |
2622 | 2622 | // limit to parent |
2623 | - if( !empty( $this->options['parent'] ) ){ |
|
2624 | - echo "parent : " . wp_json_encode( $this->options['parent'] ) . ","; |
|
2623 | + if (!empty($this->options['parent'])) { |
|
2624 | + echo "parent : " . wp_json_encode($this->options['parent']) . ","; |
|
2625 | 2625 | } |
2626 | 2626 | |
2627 | 2627 | // limit allowed blocks |
2628 | - if( !empty( $this->options['allowed-blocks'] ) ){ |
|
2629 | - echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ","; |
|
2628 | + if (!empty($this->options['allowed-blocks'])) { |
|
2629 | + echo "allowedBlocks : " . wp_json_encode($this->options['allowed-blocks']) . ","; |
|
2630 | 2630 | } |
2631 | 2631 | |
2632 | 2632 | // maybe set no_wrap |
2633 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
2634 | - if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
2633 | + $no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false; |
|
2634 | + if (isset($this->arguments['no_wrap']) && $this->arguments['no_wrap']) { |
|
2635 | 2635 | $no_wrap = true; |
2636 | 2636 | } |
2637 | - if ( $no_wrap ) { |
|
2637 | + if ($no_wrap) { |
|
2638 | 2638 | $this->options['block-wrap'] = ''; |
2639 | 2639 | } |
2640 | 2640 | |
@@ -2644,7 +2644,7 @@ discard block |
||
2644 | 2644 | |
2645 | 2645 | echo "attributes : {"; |
2646 | 2646 | |
2647 | - if ( $show_advanced ) { |
|
2647 | + if ($show_advanced) { |
|
2648 | 2648 | echo "show_advanced: {"; |
2649 | 2649 | echo " type: 'boolean',"; |
2650 | 2650 | echo " default: false"; |
@@ -2652,60 +2652,60 @@ discard block |
||
2652 | 2652 | } |
2653 | 2653 | |
2654 | 2654 | // Block wrap element |
2655 | - if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
2655 | + if (!empty($this->options['block-wrap'])) { //@todo we should validate this? |
|
2656 | 2656 | echo "block_wrap: {"; |
2657 | 2657 | echo " type: 'string',"; |
2658 | - echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "'"; |
|
2658 | + echo " default: '" . esc_attr($this->options['block-wrap']) . "'"; |
|
2659 | 2659 | echo "},"; |
2660 | 2660 | } |
2661 | 2661 | |
2662 | - if ( ! empty( $this->arguments ) ) { |
|
2663 | - foreach ( $this->arguments as $key => $args ) { |
|
2664 | - if ( $args['type'] == 'image' || $args['type'] == 'images' ) { |
|
2662 | + if (!empty($this->arguments)) { |
|
2663 | + foreach ($this->arguments as $key => $args) { |
|
2664 | + if ($args['type'] == 'image' || $args['type'] == 'images') { |
|
2665 | 2665 | $img_drag_drop = true; |
2666 | 2666 | } |
2667 | 2667 | |
2668 | 2668 | // Set if we should show alignment. |
2669 | - if ( $key == 'alignment' ) { |
|
2669 | + if ($key == 'alignment') { |
|
2670 | 2670 | $show_alignment = true; |
2671 | 2671 | } |
2672 | 2672 | |
2673 | 2673 | $extra = ''; |
2674 | - $_default = isset( $args['default'] ) && ! is_null( $args['default'] ) ? $args['default'] : ''; |
|
2674 | + $_default = isset($args['default']) && !is_null($args['default']) ? $args['default'] : ''; |
|
2675 | 2675 | |
2676 | - if ( ! empty( $_default ) ) { |
|
2677 | - $_default = wp_slash( $_default ); |
|
2676 | + if (!empty($_default)) { |
|
2677 | + $_default = wp_slash($_default); |
|
2678 | 2678 | } |
2679 | 2679 | |
2680 | - if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
|
2680 | + if ($args['type'] == 'notice' || $args['type'] == 'tab') { |
|
2681 | 2681 | continue; |
2682 | - } else if ( $args['type'] == 'checkbox' ) { |
|
2682 | + } else if ($args['type'] == 'checkbox') { |
|
2683 | 2683 | $type = 'boolean'; |
2684 | 2684 | $default = $_default ? 'true' : 'false'; |
2685 | - } else if ( $args['type'] == 'number' ) { |
|
2685 | + } else if ($args['type'] == 'number') { |
|
2686 | 2686 | $type = 'number'; |
2687 | 2687 | $default = "'" . $_default . "'"; |
2688 | - } else if ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
2688 | + } else if ($args['type'] == 'select' && !empty($args['multiple'])) { |
|
2689 | 2689 | $type = 'array'; |
2690 | - if ( isset( $args['default'] ) && is_array( $args['default'] ) ) { |
|
2691 | - $default = ! empty( $_default ) ? "['" . implode( "','", $_default ) . "']" : "[]"; |
|
2690 | + if (isset($args['default']) && is_array($args['default'])) { |
|
2691 | + $default = !empty($_default) ? "['" . implode("','", $_default) . "']" : "[]"; |
|
2692 | 2692 | } else { |
2693 | 2693 | $default = "'" . $_default . "'"; |
2694 | 2694 | } |
2695 | - } else if ( $args['type'] == 'tagselect' ) { |
|
2695 | + } else if ($args['type'] == 'tagselect') { |
|
2696 | 2696 | $type = 'array'; |
2697 | 2697 | $default = "'" . $_default . "'"; |
2698 | - } else if ( $args['type'] == 'multiselect' ) { |
|
2698 | + } else if ($args['type'] == 'multiselect') { |
|
2699 | 2699 | $type = 'array'; |
2700 | 2700 | $default = "'" . $_default . "'"; |
2701 | - } else if ( $args['type'] == 'image_xy' ) { |
|
2701 | + } else if ($args['type'] == 'image_xy') { |
|
2702 | 2702 | $type = 'object'; |
2703 | 2703 | $default = "'" . $_default . "'"; |
2704 | - } else if ( $args['type'] == 'image' ) { |
|
2704 | + } else if ($args['type'] == 'image') { |
|
2705 | 2705 | $type = 'string'; |
2706 | 2706 | $default = "'" . $_default . "'"; |
2707 | 2707 | } else { |
2708 | - $type = ! empty( $args['hidden_type'] ) ? esc_attr( $args['hidden_type'] ) : 'string'; |
|
2708 | + $type = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string'; |
|
2709 | 2709 | $default = "'" . $_default . "'"; |
2710 | 2710 | } |
2711 | 2711 | |
@@ -2719,7 +2719,7 @@ discard block |
||
2719 | 2719 | echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},"; |
2720 | 2720 | echo "sd_shortcode : {type : 'string',default: ''},"; |
2721 | 2721 | |
2722 | - if ( ! empty( $this->options['nested-block'] ) || ! empty( $this->arguments['html'] ) ) { |
|
2722 | + if (!empty($this->options['nested-block']) || !empty($this->arguments['html'])) { |
|
2723 | 2723 | echo "sd_shortcode_close : {type : 'string',default: ''},"; |
2724 | 2724 | } |
2725 | 2725 | |
@@ -2731,7 +2731,7 @@ discard block |
||
2731 | 2731 | const selectedBlock = wp.data.select('core/block-editor').getSelectedBlock(); |
2732 | 2732 | <?php |
2733 | 2733 | // only include the drag/drop functions if required. |
2734 | -if ( $img_drag_drop ) { |
|
2734 | +if ($img_drag_drop) { |
|
2735 | 2735 | ?> |
2736 | 2736 | |
2737 | 2737 | function enableDragSort(listClass) { |
@@ -2796,9 +2796,9 @@ discard block |
||
2796 | 2796 | } |
2797 | 2797 | |
2798 | 2798 | <?php |
2799 | - if(!empty($this->options['block-edit-raw'])) { |
|
2799 | + if (!empty($this->options['block-edit-raw'])) { |
|
2800 | 2800 | echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues |
2801 | - }else{ |
|
2801 | + } else { |
|
2802 | 2802 | ?> |
2803 | 2803 | |
2804 | 2804 | function hasSelectedInnerBlock(props) { |
@@ -2822,7 +2822,7 @@ discard block |
||
2822 | 2822 | var $value = ''; |
2823 | 2823 | <?php |
2824 | 2824 | // if we have a post_type and a category then link them |
2825 | - if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){ |
|
2825 | + if (isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked'])) { |
|
2826 | 2826 | ?> |
2827 | 2827 | if(typeof(prev_attributes[props.clientId]) != 'undefined' && selectedBlock && selectedBlock.clientId === props.clientId){ |
2828 | 2828 | $pt = props.attributes.post_type; |
@@ -2837,9 +2837,9 @@ discard block |
||
2837 | 2837 | } |
2838 | 2838 | <?php |
2839 | 2839 | $cat_path = ''; |
2840 | - if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) { |
|
2841 | - $cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) ); |
|
2842 | - $cat_path = str_replace( array( '"', ''' ), array( '"', "'" ), $cat_path ); |
|
2840 | + if (!empty($this->arguments['post_type']['onchange_rest']['path'])) { |
|
2841 | + $cat_path = esc_js(strip_tags($this->arguments['post_type']['onchange_rest']['path'])); |
|
2842 | + $cat_path = str_replace(array('"', '''), array('"', "'"), $cat_path); |
|
2843 | 2843 | } |
2844 | 2844 | ?> |
2845 | 2845 | /* taxonomies */ |
@@ -2847,15 +2847,15 @@ discard block |
||
2847 | 2847 | if (!window.gdCPTCats) { |
2848 | 2848 | window.gdCPTCats = []; |
2849 | 2849 | } |
2850 | - var gdCatPath = "<?php echo ( ! empty( $cat_path ) ? $cat_path : "/wp/v2/" + $value + "/categories/?per_page=100" ); ?>"; |
|
2850 | + var gdCatPath = "<?php echo (!empty($cat_path) ? $cat_path : "/wp/v2/" +$value + "/categories/?per_page=100"); ?>"; |
|
2851 | 2851 | if (window.gdCPTCats[gdCatPath]) { |
2852 | 2852 | terms = window.gdCPTCats[gdCatPath]; |
2853 | - while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) { |
|
2854 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop(); |
|
2853 | + while (taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.length) { |
|
2854 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.pop(); |
|
2855 | 2855 | } |
2856 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: "All", value: 0}); |
|
2856 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: "All", value: 0}); |
|
2857 | 2857 | jQuery.each( terms, function( key, val ) { |
2858 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: val.name, value: val.id}); |
|
2858 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val.name, value: val.id}); |
|
2859 | 2859 | }); |
2860 | 2860 | |
2861 | 2861 | /* Setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. */ |
@@ -2865,12 +2865,12 @@ discard block |
||
2865 | 2865 | } else { |
2866 | 2866 | wp.apiFetch({path: gdCatPath}).then(terms => { |
2867 | 2867 | window.gdCPTCats[gdCatPath] = terms; |
2868 | - while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) { |
|
2869 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop(); |
|
2868 | + while (taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.length) { |
|
2869 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.pop(); |
|
2870 | 2870 | } |
2871 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: "All", value: 0}); |
|
2871 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: "All", value: 0}); |
|
2872 | 2872 | jQuery.each( terms, function( key, val ) { |
2873 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: val.name, value: val.id}); |
|
2873 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val.name, value: val.id}); |
|
2874 | 2874 | }); |
2875 | 2875 | |
2876 | 2876 | /* Setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. */ |
@@ -2878,7 +2878,7 @@ discard block |
||
2878 | 2878 | props.setAttributes({category: [0] }); |
2879 | 2879 | props.setAttributes({category: $old_cat_value }); |
2880 | 2880 | |
2881 | - return taxonomies_<?php echo str_replace("-","_", $this->id);?>; |
|
2881 | + return taxonomies_<?php echo str_replace("-", "_", $this->id); ?>; |
|
2882 | 2882 | }); |
2883 | 2883 | } |
2884 | 2884 | } |
@@ -2890,12 +2890,12 @@ discard block |
||
2890 | 2890 | } |
2891 | 2891 | if (window.gdCPTSort[$pt]) { |
2892 | 2892 | response = window.gdCPTSort[$pt]; |
2893 | - while (sort_by_<?php echo str_replace("-","_", $this->id);?>.length) { |
|
2894 | - sort_by_<?php echo str_replace("-","_", $this->id);?>.pop(); |
|
2893 | + while (sort_by_<?php echo str_replace("-", "_", $this->id); ?>.length) { |
|
2894 | + sort_by_<?php echo str_replace("-", "_", $this->id); ?>.pop(); |
|
2895 | 2895 | } |
2896 | 2896 | |
2897 | 2897 | jQuery.each( response, function( key, val ) { |
2898 | - sort_by_<?php echo str_replace("-","_", $this->id);?>.push({label: val, value: key}); |
|
2898 | + sort_by_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val, value: key}); |
|
2899 | 2899 | }); |
2900 | 2900 | |
2901 | 2901 | // setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. |
@@ -2910,12 +2910,12 @@ discard block |
||
2910 | 2910 | jQuery.post(ajaxurl, data, function(response) { |
2911 | 2911 | response = JSON.parse(response); |
2912 | 2912 | window.gdCPTSort[$pt] = response; |
2913 | - while (sort_by_<?php echo str_replace("-","_", $this->id);?>.length) { |
|
2914 | - sort_by_<?php echo str_replace("-","_", $this->id);?>.pop(); |
|
2913 | + while (sort_by_<?php echo str_replace("-", "_", $this->id); ?>.length) { |
|
2914 | + sort_by_<?php echo str_replace("-", "_", $this->id); ?>.pop(); |
|
2915 | 2915 | } |
2916 | 2916 | |
2917 | 2917 | jQuery.each( response, function( key, val ) { |
2918 | - sort_by_<?php echo str_replace("-","_", $this->id);?>.push({label: val, value: key}); |
|
2918 | + sort_by_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val, value: key}); |
|
2919 | 2919 | }); |
2920 | 2920 | |
2921 | 2921 | // setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. |
@@ -2923,7 +2923,7 @@ discard block |
||
2923 | 2923 | props.setAttributes({sort_by: [0] }); |
2924 | 2924 | props.setAttributes({sort_by: $old_sort_by_value }); |
2925 | 2925 | |
2926 | - return sort_by_<?php echo str_replace("-","_", $this->id);?>; |
|
2926 | + return sort_by_<?php echo str_replace("-", "_", $this->id); ?>; |
|
2927 | 2927 | }); |
2928 | 2928 | } |
2929 | 2929 | } |
@@ -2931,9 +2931,9 @@ discard block |
||
2931 | 2931 | <?php } ?> |
2932 | 2932 | <?php |
2933 | 2933 | $current_screen = function_exists('get_current_screen') ? get_current_screen() : ''; |
2934 | -if(!empty($current_screen->base) && $current_screen->base==='widgets'){ |
|
2934 | +if (!empty($current_screen->base) && $current_screen->base === 'widgets') { |
|
2935 | 2935 | echo 'const { deviceType } = "";'; |
2936 | -}else{ |
|
2936 | +} else { |
|
2937 | 2937 | ?> |
2938 | 2938 | /** Get device type const. */ |
2939 | 2939 | const wpVersion = '<?php global $wp_version; echo esc_attr($wp_version); ?>'; |
@@ -2982,13 +2982,13 @@ discard block |
||
2982 | 2982 | |
2983 | 2983 | var data = { |
2984 | 2984 | 'action': 'super_duper_output_shortcode', |
2985 | - 'shortcode': '<?php echo $this->options['base_id'];?>', |
|
2985 | + 'shortcode': '<?php echo $this->options['base_id']; ?>', |
|
2986 | 2986 | 'attributes': props.attributes, |
2987 | 2987 | 'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '', |
2988 | - 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
|
2988 | + 'post_id': <?php global $post; if (isset($post->ID)) { |
|
2989 | 2989 | echo $post->ID; |
2990 | - }else{echo '0';}?>, |
|
2991 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
|
2990 | + } else {echo '0'; }?>, |
|
2991 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>' |
|
2992 | 2992 | }; |
2993 | 2993 | |
2994 | 2994 | jQuery.post(ajaxurl, data, function (response) { |
@@ -2996,17 +2996,17 @@ discard block |
||
2996 | 2996 | }).then(function (env) { |
2997 | 2997 | // if the content is empty then we place some placeholder text |
2998 | 2998 | if (env == '') { |
2999 | - env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for:', 'ayecode-connect' );?> " + props.name + "</div>"; |
|
2999 | + env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for:', 'ayecode-connect'); ?> " + props.name + "</div>"; |
|
3000 | 3000 | } |
3001 | 3001 | |
3002 | 3002 | <?php |
3003 | - if(!empty($this->options['nested-block'])){ |
|
3003 | + if (!empty($this->options['nested-block'])) { |
|
3004 | 3004 | ?> |
3005 | 3005 | // props.setAttributes({content: env}); |
3006 | 3006 | is_fetching = false; |
3007 | 3007 | prev_attributes[props.clientId] = props.attributes; |
3008 | 3008 | <?php |
3009 | - }else{ |
|
3009 | + } else { |
|
3010 | 3010 | ?> |
3011 | 3011 | props.setAttributes({content: env}); |
3012 | 3012 | is_fetching = false; |
@@ -3026,35 +3026,35 @@ discard block |
||
3026 | 3026 | } |
3027 | 3027 | |
3028 | 3028 | <?php |
3029 | - if(!empty($this->options['block-edit-js'])) { |
|
3030 | - echo $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues |
|
3029 | + if (!empty($this->options['block-edit-js'])) { |
|
3030 | + echo $this->options['block-edit-js']; // strings have to be in single quotes, may cause issues |
|
3031 | 3031 | } |
3032 | 3032 | |
3033 | - if(empty($this->options['block-save-return'])){ |
|
3033 | + if (empty($this->options['block-save-return'])) { |
|
3034 | 3034 | ?> |
3035 | 3035 | /////////////////////////////////////////////////////////////////////// |
3036 | 3036 | |
3037 | 3037 | // build the shortcode. |
3038 | - shortcode = "[<?php echo $this->options['base_id'];?>"; |
|
3038 | + shortcode = "[<?php echo $this->options['base_id']; ?>"; |
|
3039 | 3039 | <?php |
3040 | 3040 | |
3041 | - if(! empty( $this->arguments )){ |
|
3041 | + if (!empty($this->arguments)) { |
|
3042 | 3042 | |
3043 | - foreach($this->arguments as $key => $args){ |
|
3043 | + foreach ($this->arguments as $key => $args) { |
|
3044 | 3044 | // if($args['type']=='tabs'){continue;} |
3045 | 3045 | |
3046 | 3046 | // don't add metadata arguments |
3047 | - if (substr($key, 0, 9 ) === 'metadata_') { |
|
3047 | + if (substr($key, 0, 9) === 'metadata_') { |
|
3048 | 3048 | continue; |
3049 | 3049 | } |
3050 | 3050 | ?> |
3051 | - if (props.attributes.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
|
3052 | - if ('<?php echo esc_attr( $key );?>' == 'html') { |
|
3053 | - } else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') { |
|
3054 | - shortcode += props.attributes.<?php echo esc_attr( $key );?>.length && ( props.attributes.<?php echo esc_attr( $key );?>.x.length || props.attributes.<?php echo esc_attr( $key );?>.y.length ) ? " <?php echo esc_attr( $key );?>='{x:" + props.attributes.<?php echo esc_attr( $key );?>.x + ",y:"+props.attributes.<?php echo esc_attr( $key );?>.y +"}' " : ""; |
|
3051 | + if (props.attributes.hasOwnProperty("<?php echo esc_attr($key); ?>")) { |
|
3052 | + if ('<?php echo esc_attr($key); ?>' == 'html') { |
|
3053 | + } else if ('<?php echo esc_attr($args['type']); ?>' == 'image_xy') { |
|
3054 | + shortcode += props.attributes.<?php echo esc_attr($key); ?>.length && ( props.attributes.<?php echo esc_attr($key); ?>.x.length || props.attributes.<?php echo esc_attr($key); ?>.y.length ) ? " <?php echo esc_attr($key); ?>='{x:" + props.attributes.<?php echo esc_attr($key); ?>.x + ",y:"+props.attributes.<?php echo esc_attr($key); ?>.y +"}' " : ""; |
|
3055 | 3055 | } else { |
3056 | - //shortcode += props.attributes.<?php echo esc_attr( $key );?>.length ? " <?php echo esc_attr( $key );?>='" + props.attributes.<?php echo esc_attr( $key );?>.toString().replace('\'',''') + "' " : ""; |
|
3057 | - shortcode += " <?php echo esc_attr( $key );?>='" + props.attributes.<?php echo esc_attr( $key );?>.toString().replace('\'',''') + "' "; |
|
3056 | + //shortcode += props.attributes.<?php echo esc_attr($key); ?>.length ? " <?php echo esc_attr($key); ?>='" + props.attributes.<?php echo esc_attr($key); ?>.toString().replace('\'',''') + "' " : ""; |
|
3057 | + shortcode += " <?php echo esc_attr($key); ?>='" + props.attributes.<?php echo esc_attr($key); ?>.toString().replace('\'',''') + "' "; |
|
3058 | 3058 | } |
3059 | 3059 | } |
3060 | 3060 | <?php |
@@ -3073,8 +3073,8 @@ discard block |
||
3073 | 3073 | |
3074 | 3074 | |
3075 | 3075 | <?php |
3076 | - if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){ |
|
3077 | - echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});"; |
|
3076 | + if (!empty($this->options['nested-block']) || !empty($this->arguments['html'])) { |
|
3077 | + echo "props.setAttributes({sd_shortcode_close: '[/" . esc_attr($this->options['base_id']) . "]'});"; |
|
3078 | 3078 | } |
3079 | 3079 | ?> |
3080 | 3080 | } |
@@ -3089,7 +3089,7 @@ discard block |
||
3089 | 3089 | |
3090 | 3090 | el(wp.blockEditor.BlockControls, {key: 'controls'}, |
3091 | 3091 | |
3092 | - <?php if($show_alignment){?> |
|
3092 | + <?php if ($show_alignment) {?> |
|
3093 | 3093 | el( |
3094 | 3094 | wp.blockEditor.AlignmentToolbar, |
3095 | 3095 | { |
@@ -3107,9 +3107,9 @@ discard block |
||
3107 | 3107 | |
3108 | 3108 | <?php |
3109 | 3109 | |
3110 | - if(! empty( $this->arguments )){ |
|
3110 | + if (!empty($this->arguments)) { |
|
3111 | 3111 | |
3112 | - if ( $show_advanced ) { |
|
3112 | + if ($show_advanced) { |
|
3113 | 3113 | ?> |
3114 | 3114 | el('div', { |
3115 | 3115 | style: {'padding-left': '16px','padding-right': '16px'} |
@@ -3129,42 +3129,42 @@ discard block |
||
3129 | 3129 | <?php |
3130 | 3130 | } |
3131 | 3131 | |
3132 | - $arguments = $this->group_arguments( $this->arguments ); |
|
3133 | - $block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array(); |
|
3132 | + $arguments = $this->group_arguments($this->arguments); |
|
3133 | + $block_group_tabs = !empty($this->options['block_group_tabs']) ? $this->group_block_tabs($this->options['block_group_tabs'], $arguments) : array(); |
|
3134 | 3134 | |
3135 | 3135 | // Do we have sections? |
3136 | 3136 | $has_sections = $arguments == $this->arguments ? false : true; |
3137 | 3137 | |
3138 | - if($has_sections){ |
|
3138 | + if ($has_sections) { |
|
3139 | 3139 | $panel_count = 0; |
3140 | 3140 | $open_tab = ''; |
3141 | 3141 | |
3142 | 3142 | $open_tab_groups = array(); |
3143 | 3143 | $used_tabs = array(); |
3144 | 3144 | |
3145 | - foreach ( $arguments as $key => $args ) { |
|
3145 | + foreach ($arguments as $key => $args) { |
|
3146 | 3146 | $close_tab = false; |
3147 | 3147 | $close_tabs = false; |
3148 | 3148 | |
3149 | - if ( ! empty( $block_group_tabs ) ) { |
|
3150 | - foreach ( $block_group_tabs as $tab_name => $tab_args ) { |
|
3151 | - if ( in_array( $key, $tab_args['groups'] ) ) { |
|
3149 | + if (!empty($block_group_tabs)) { |
|
3150 | + foreach ($block_group_tabs as $tab_name => $tab_args) { |
|
3151 | + if (in_array($key, $tab_args['groups'])) { |
|
3152 | 3152 | $open_tab_groups[] = $key; |
3153 | 3153 | |
3154 | - if ( $open_tab != $tab_name ) { |
|
3154 | + if ($open_tab != $tab_name) { |
|
3155 | 3155 | $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false; |
3156 | 3156 | $tab_args['tab']['open'] = true; |
3157 | 3157 | |
3158 | - $this->block_tab_start( '', $tab_args ); |
|
3158 | + $this->block_tab_start('', $tab_args); |
|
3159 | 3159 | $open_tab = $tab_name; |
3160 | 3160 | $used_tabs[] = $tab_name; |
3161 | 3161 | } |
3162 | 3162 | |
3163 | - if ( $open_tab_groups == $tab_args['groups'] ) { |
|
3163 | + if ($open_tab_groups == $tab_args['groups']) { |
|
3164 | 3164 | $close_tab = true; |
3165 | 3165 | $open_tab_groups = array(); |
3166 | 3166 | |
3167 | - if ( $used_tabs == array_keys( $block_group_tabs ) ) { |
|
3167 | + if ($used_tabs == array_keys($block_group_tabs)) { |
|
3168 | 3168 | $close_tabs = true; |
3169 | 3169 | } |
3170 | 3170 | } |
@@ -3173,27 +3173,27 @@ discard block |
||
3173 | 3173 | } |
3174 | 3174 | ?> |
3175 | 3175 | el(wp.components.PanelBody, { |
3176 | - title: '<?php esc_attr_e( $key ); ?>', |
|
3177 | - initialOpen: <?php if ( $panel_count ) { |
|
3176 | + title: '<?php esc_attr_e($key); ?>', |
|
3177 | + initialOpen: <?php if ($panel_count) { |
|
3178 | 3178 | echo "false"; |
3179 | 3179 | } else { |
3180 | 3180 | echo "true"; |
3181 | 3181 | }?> |
3182 | 3182 | }, |
3183 | 3183 | <?php |
3184 | - foreach ( $args as $k => $a ) { |
|
3185 | - $this->block_tab_start( $k, $a ); |
|
3186 | - $this->block_row_start( $k, $a ); |
|
3187 | - $this->build_block_arguments( $k, $a ); |
|
3188 | - $this->block_row_end( $k, $a ); |
|
3189 | - $this->block_tab_end( $k, $a ); |
|
3184 | + foreach ($args as $k => $a) { |
|
3185 | + $this->block_tab_start($k, $a); |
|
3186 | + $this->block_row_start($k, $a); |
|
3187 | + $this->build_block_arguments($k, $a); |
|
3188 | + $this->block_row_end($k, $a); |
|
3189 | + $this->block_tab_end($k, $a); |
|
3190 | 3190 | } |
3191 | 3191 | ?> |
3192 | 3192 | ), |
3193 | 3193 | <?php |
3194 | - $panel_count ++; |
|
3194 | + $panel_count++; |
|
3195 | 3195 | |
3196 | - if($close_tab || $close_tabs){ |
|
3196 | + if ($close_tab || $close_tabs) { |
|
3197 | 3197 | $tab_args = array( |
3198 | 3198 | 'tab' => array( |
3199 | 3199 | 'tabs_close' => $close_tabs, |
@@ -3201,24 +3201,24 @@ discard block |
||
3201 | 3201 | ) |
3202 | 3202 | |
3203 | 3203 | ); |
3204 | - $this->block_tab_end( '', $tab_args ); |
|
3204 | + $this->block_tab_end('', $tab_args); |
|
3205 | 3205 | // echo '###close'; print_r($tab_args); |
3206 | 3206 | $panel_count = 0; |
3207 | 3207 | } |
3208 | 3208 | // |
3209 | 3209 | |
3210 | 3210 | } |
3211 | - }else { |
|
3211 | + } else { |
|
3212 | 3212 | ?> |
3213 | 3213 | el(wp.components.PanelBody, { |
3214 | - title: '<?php esc_attr_e( "Settings", 'ayecode-connect' ); ?>', |
|
3214 | + title: '<?php esc_attr_e("Settings", 'ayecode-connect'); ?>', |
|
3215 | 3215 | initialOpen: true |
3216 | 3216 | }, |
3217 | 3217 | <?php |
3218 | - foreach ( $this->arguments as $key => $args ) { |
|
3219 | - $this->block_row_start( $key, $args ); |
|
3220 | - $this->build_block_arguments( $key, $args ); |
|
3221 | - $this->block_row_end( $key, $args ); |
|
3218 | + foreach ($this->arguments as $key => $args) { |
|
3219 | + $this->block_row_start($key, $args); |
|
3220 | + $this->build_block_arguments($key, $args); |
|
3221 | + $this->block_row_end($key, $args); |
|
3222 | 3222 | } |
3223 | 3223 | ?> |
3224 | 3224 | ), |
@@ -3232,11 +3232,11 @@ discard block |
||
3232 | 3232 | |
3233 | 3233 | <?php |
3234 | 3234 | // If the user sets block-output array then build it |
3235 | - if ( ! empty( $this->options['block-output'] ) ) { |
|
3236 | - $this->block_element( $this->options['block-output'] ); |
|
3237 | - }elseif(!empty($this->options['block-edit-return'])){ |
|
3235 | + if (!empty($this->options['block-output'])) { |
|
3236 | + $this->block_element($this->options['block-output']); |
|
3237 | + }elseif (!empty($this->options['block-edit-return'])) { |
|
3238 | 3238 | echo $this->options['block-edit-return']; |
3239 | - }else{ |
|
3239 | + } else { |
|
3240 | 3240 | // if no block-output is set then we try and get the shortcode html output via ajax. |
3241 | 3241 | $block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div'; |
3242 | 3242 | ?> |
@@ -3263,27 +3263,27 @@ discard block |
||
3263 | 3263 | var align = ''; |
3264 | 3264 | |
3265 | 3265 | // build the shortcode. |
3266 | - var content = "[<?php echo $this->options['base_id'];?>"; |
|
3266 | + var content = "[<?php echo $this->options['base_id']; ?>"; |
|
3267 | 3267 | $html = ''; |
3268 | 3268 | <?php |
3269 | 3269 | |
3270 | - if(! empty( $this->arguments )){ |
|
3270 | + if (!empty($this->arguments)) { |
|
3271 | 3271 | |
3272 | - foreach($this->arguments as $key => $args){ |
|
3272 | + foreach ($this->arguments as $key => $args) { |
|
3273 | 3273 | // if($args['type']=='tabs'){continue;} |
3274 | 3274 | |
3275 | 3275 | // don't add metadata arguments |
3276 | - if (substr($key, 0, 9 ) === 'metadata_') { |
|
3276 | + if (substr($key, 0, 9) === 'metadata_') { |
|
3277 | 3277 | continue; |
3278 | 3278 | } |
3279 | 3279 | ?> |
3280 | - if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
|
3281 | - if ('<?php echo esc_attr( $key );?>' == 'html') { |
|
3282 | - $html = attr.<?php echo esc_attr( $key );?>; |
|
3283 | - } else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') { |
|
3284 | - content += " <?php echo esc_attr( $key );?>='{x:" + attr.<?php echo esc_attr( $key );?>.x + ",y:"+attr.<?php echo esc_attr( $key );?>.y +"}' "; |
|
3280 | + if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) { |
|
3281 | + if ('<?php echo esc_attr($key); ?>' == 'html') { |
|
3282 | + $html = attr.<?php echo esc_attr($key); ?>; |
|
3283 | + } else if ('<?php echo esc_attr($args['type']); ?>' == 'image_xy') { |
|
3284 | + content += " <?php echo esc_attr($key); ?>='{x:" + attr.<?php echo esc_attr($key); ?>.x + ",y:"+attr.<?php echo esc_attr($key); ?>.y +"}' "; |
|
3285 | 3285 | } else { |
3286 | - content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>.toString().replace('\'',''') + "' "; |
|
3286 | + content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>.toString().replace('\'',''') + "' "; |
|
3287 | 3287 | } |
3288 | 3288 | } |
3289 | 3289 | <?php |
@@ -3303,7 +3303,7 @@ discard block |
||
3303 | 3303 | ?> |
3304 | 3304 | // if has html element |
3305 | 3305 | if ($html) { |
3306 | - //content += $html + "[/<?php echo $this->options['base_id'];?>]"; |
|
3306 | + //content += $html + "[/<?php echo $this->options['base_id']; ?>]"; |
|
3307 | 3307 | } |
3308 | 3308 | |
3309 | 3309 | // @todo should we add inline style here or just css classes? |
@@ -3333,7 +3333,7 @@ discard block |
||
3333 | 3333 | // <x?php |
3334 | 3334 | // }else |
3335 | 3335 | |
3336 | - if(!empty($this->options['block-output'])){ |
|
3336 | + if (!empty($this->options['block-output'])) { |
|
3337 | 3337 | // echo "return"; |
3338 | 3338 | // $this->block_element( $this->options['block-output'], true ); |
3339 | 3339 | // echo ";"; |
@@ -3343,30 +3343,30 @@ discard block |
||
3343 | 3343 | '', |
3344 | 3344 | {}, |
3345 | 3345 | // el('', {dangerouslySetInnerHTML: {__html: content}}), |
3346 | - <?php $this->block_element( $this->options['block-output'], true ); ?> |
|
3347 | - // el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}}) |
|
3346 | + <?php $this->block_element($this->options['block-output'], true); ?> |
|
3347 | + // el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}}) |
|
3348 | 3348 | ); |
3349 | 3349 | <?php |
3350 | 3350 | |
3351 | - }elseif(!empty($this->options['block-save-return'])){ |
|
3351 | + }elseif (!empty($this->options['block-save-return'])) { |
|
3352 | 3352 | echo 'return ' . $this->options['block-save-return']; |
3353 | - }elseif(!empty($this->options['nested-block'])){ |
|
3353 | + }elseif (!empty($this->options['nested-block'])) { |
|
3354 | 3354 | ?> |
3355 | 3355 | return el( |
3356 | 3356 | '', |
3357 | 3357 | {}, |
3358 | 3358 | el('', {dangerouslySetInnerHTML: {__html: content+"\n"}}), |
3359 | 3359 | InnerBlocks.Content ? el( InnerBlocks.Content ) : '', // @todo i think we need a comma here |
3360 | - // el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}}) |
|
3360 | + // el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}}) |
|
3361 | 3361 | ); |
3362 | 3362 | <?php |
3363 | - }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
3364 | - echo "return ". $this->options['block-edit-return'].";"; |
|
3365 | - }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
3363 | + }elseif (!empty($this->options['block-save-return'])) { |
|
3364 | + echo "return " . $this->options['block-edit-return'] . ";"; |
|
3365 | + }elseif (isset($this->options['block-wrap']) && $this->options['block-wrap'] == '') { |
|
3366 | 3366 | ?> |
3367 | 3367 | return content; |
3368 | 3368 | <?php |
3369 | - }else{ |
|
3369 | + } else { |
|
3370 | 3370 | ?> |
3371 | 3371 | var block_wrap = 'div'; |
3372 | 3372 | if (attr.hasOwnProperty("block_wrap")) { |
@@ -3395,48 +3395,48 @@ discard block |
||
3395 | 3395 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
3396 | 3396 | */ |
3397 | 3397 | |
3398 | - return str_replace( array( |
|
3398 | + return str_replace(array( |
|
3399 | 3399 | '<script>', |
3400 | 3400 | '</script>' |
3401 | - ), '', $output ); |
|
3401 | + ), '', $output); |
|
3402 | 3402 | } |
3403 | 3403 | |
3404 | 3404 | |
3405 | 3405 | |
3406 | - public function block_row_start($key, $args){ |
|
3406 | + public function block_row_start($key, $args) { |
|
3407 | 3407 | |
3408 | 3408 | // check for row |
3409 | - if(!empty($args['row'])){ |
|
3409 | + if (!empty($args['row'])) { |
|
3410 | 3410 | |
3411 | - if(!empty($args['row']['open'])){ |
|
3411 | + if (!empty($args['row']['open'])) { |
|
3412 | 3412 | |
3413 | 3413 | // element require |
3414 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
3415 | - $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
|
3416 | - $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
|
3414 | + $element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : ""; |
|
3415 | + $device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : ''; |
|
3416 | + $device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
|
3417 | 3417 | $device_type_icon = ''; |
3418 | - if($device_type=='Desktop'){ |
|
3418 | + if ($device_type == 'Desktop') { |
|
3419 | 3419 | $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
3420 | - }elseif($device_type=='Tablet'){ |
|
3420 | + }elseif ($device_type == 'Tablet') { |
|
3421 | 3421 | $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
3422 | - }elseif($device_type=='Mobile'){ |
|
3422 | + }elseif ($device_type == 'Mobile') { |
|
3423 | 3423 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
3424 | 3424 | } |
3425 | 3425 | echo $element_require; |
3426 | 3426 | echo $device_type_require; |
3427 | 3427 | |
3428 | - if(false){?><script><?php }?> |
|
3428 | + if (false) {?><script><?php }?> |
|
3429 | 3429 | el('div', { |
3430 | 3430 | className: 'bsui components-base-control', |
3431 | 3431 | }, |
3432 | - <?php if(!empty($args['row']['title'])){ ?> |
|
3432 | + <?php if (!empty($args['row']['title'])) { ?> |
|
3433 | 3433 | el('label', { |
3434 | 3434 | className: 'components-base-control__label position-relative', |
3435 | 3435 | style: {width:"100%"} |
3436 | 3436 | }, |
3437 | - el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['row']['title'] ) ?>'}}), |
|
3438 | - <?php if($device_type_icon){ ?> |
|
3439 | - deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}}) |
|
3437 | + el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes($args['row']['title']) ?>'}}), |
|
3438 | + <?php if ($device_type_icon) { ?> |
|
3439 | + deviceType == '<?php echo $device_type; ?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}}) |
|
3440 | 3440 | <?php |
3441 | 3441 | } |
3442 | 3442 | ?> |
@@ -3444,17 +3444,17 @@ discard block |
||
3444 | 3444 | |
3445 | 3445 | ), |
3446 | 3446 | <?php }?> |
3447 | - <?php if(!empty($args['row']['desc'])){ ?> |
|
3447 | + <?php if (!empty($args['row']['desc'])) { ?> |
|
3448 | 3448 | el('p', { |
3449 | 3449 | className: 'components-base-control__help mb-0', |
3450 | 3450 | }, |
3451 | - '<?php echo addslashes( $args['row']['desc'] ); ?>' |
|
3451 | + '<?php echo addslashes($args['row']['desc']); ?>' |
|
3452 | 3452 | ), |
3453 | 3453 | <?php }?> |
3454 | 3454 | el( |
3455 | 3455 | 'div', |
3456 | 3456 | { |
3457 | - className: 'row mb-n2 <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>', |
|
3457 | + className: 'row mb-n2 <?php if (!empty($args['row']['class'])) { echo esc_attr($args['row']['class']); } ?>', |
|
3458 | 3458 | }, |
3459 | 3459 | el( |
3460 | 3460 | 'div', |
@@ -3463,36 +3463,36 @@ discard block |
||
3463 | 3463 | }, |
3464 | 3464 | |
3465 | 3465 | <?php |
3466 | - if(false){?></script><?php } |
|
3467 | - }elseif(!empty($args['row']['close'])){ |
|
3468 | - if(false){?><script><?php }?> |
|
3466 | + if (false) {?></script><?php } |
|
3467 | + }elseif (!empty($args['row']['close'])) { |
|
3468 | + if (false) {?><script><?php }?> |
|
3469 | 3469 | el( |
3470 | 3470 | 'div', |
3471 | 3471 | { |
3472 | 3472 | className: 'col pl-0 ps-0', |
3473 | 3473 | }, |
3474 | 3474 | <?php |
3475 | - if(false){?></script><?php } |
|
3476 | - }else{ |
|
3477 | - if(false){?><script><?php }?> |
|
3475 | + if (false) {?></script><?php } |
|
3476 | + } else { |
|
3477 | + if (false) {?><script><?php }?> |
|
3478 | 3478 | el( |
3479 | 3479 | 'div', |
3480 | 3480 | { |
3481 | 3481 | className: 'col pl-0 ps-0 pr-2 pe-2', |
3482 | 3482 | }, |
3483 | 3483 | <?php |
3484 | - if(false){?></script><?php } |
|
3484 | + if (false) {?></script><?php } |
|
3485 | 3485 | } |
3486 | 3486 | |
3487 | 3487 | } |
3488 | 3488 | |
3489 | 3489 | } |
3490 | 3490 | |
3491 | - public function block_row_end($key, $args){ |
|
3491 | + public function block_row_end($key, $args) { |
|
3492 | 3492 | |
3493 | - if(!empty($args['row'])){ |
|
3493 | + if (!empty($args['row'])) { |
|
3494 | 3494 | // maybe close |
3495 | - if(!empty($args['row']['close'])){ |
|
3495 | + if (!empty($args['row']['close'])) { |
|
3496 | 3496 | echo "))"; |
3497 | 3497 | } |
3498 | 3498 | |
@@ -3500,14 +3500,14 @@ discard block |
||
3500 | 3500 | } |
3501 | 3501 | } |
3502 | 3502 | |
3503 | - public function block_tab_start($key, $args){ |
|
3503 | + public function block_tab_start($key, $args) { |
|
3504 | 3504 | |
3505 | 3505 | // check for row |
3506 | - if(!empty($args['tab'])){ |
|
3506 | + if (!empty($args['tab'])) { |
|
3507 | 3507 | |
3508 | - if(!empty($args['tab']['tabs_open'])){ |
|
3508 | + if (!empty($args['tab']['tabs_open'])) { |
|
3509 | 3509 | |
3510 | - if(false){?><script><?php }?> |
|
3510 | + if (false) {?><script><?php }?> |
|
3511 | 3511 | |
3512 | 3512 | el('div',{className: 'bsui'}, |
3513 | 3513 | |
@@ -3516,52 +3516,52 @@ discard block |
||
3516 | 3516 | { |
3517 | 3517 | activeClass: 'is-active', |
3518 | 3518 | className: 'btn-groupx', |
3519 | - initialTabName: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>', |
|
3519 | + initialTabName: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>', |
|
3520 | 3520 | tabs: [ |
3521 | 3521 | |
3522 | 3522 | <?php |
3523 | - if(false){?></script><?php } |
|
3523 | + if (false) {?></script><?php } |
|
3524 | 3524 | } |
3525 | 3525 | |
3526 | - if(!empty($args['tab']['open'])){ |
|
3526 | + if (!empty($args['tab']['open'])) { |
|
3527 | 3527 | |
3528 | - if(false){?><script><?php }?> |
|
3528 | + if (false) {?><script><?php }?> |
|
3529 | 3529 | { |
3530 | - name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>', |
|
3531 | - title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}), |
|
3532 | - className: '<?php echo addslashes( esc_attr( $args['tab']['class']) ); ?>', |
|
3533 | - content: el('div',{}, <?php if(!empty($args['tab']['desc'])){ ?>el('p', { |
|
3530 | + name: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>', |
|
3531 | + title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes(esc_attr($args['tab']['title'])); ?>'}}), |
|
3532 | + className: '<?php echo addslashes(esc_attr($args['tab']['class'])); ?>', |
|
3533 | + content: el('div',{}, <?php if (!empty($args['tab']['desc'])) { ?>el('p', { |
|
3534 | 3534 | className: 'components-base-control__help mb-0', |
3535 | - dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'} |
|
3535 | + dangerouslySetInnerHTML: {__html:'<?php echo addslashes($args['tab']['desc']); ?>'} |
|
3536 | 3536 | }),<?php } |
3537 | - if(false){?></script><?php } |
|
3537 | + if (false) {?></script><?php } |
|
3538 | 3538 | } |
3539 | 3539 | |
3540 | 3540 | } |
3541 | 3541 | |
3542 | 3542 | } |
3543 | 3543 | |
3544 | - public function block_tab_end($key, $args){ |
|
3544 | + public function block_tab_end($key, $args) { |
|
3545 | 3545 | |
3546 | - if(!empty($args['tab'])){ |
|
3546 | + if (!empty($args['tab'])) { |
|
3547 | 3547 | // maybe close |
3548 | - if(!empty($args['tab']['close'])){ |
|
3548 | + if (!empty($args['tab']['close'])) { |
|
3549 | 3549 | echo ")}, /* tab close */"; |
3550 | 3550 | } |
3551 | 3551 | |
3552 | - if(!empty($args['tab']['tabs_close'])){ |
|
3553 | - if(false){?><script><?php }?> |
|
3552 | + if (!empty($args['tab']['tabs_close'])) { |
|
3553 | + if (false) {?><script><?php }?> |
|
3554 | 3554 | ]}, ( tab ) => { |
3555 | 3555 | return tab.content; |
3556 | 3556 | } |
3557 | 3557 | )), /* tabs close */ |
3558 | - <?php if(false){ ?></script><?php } |
|
3558 | + <?php if (false) { ?></script><?php } |
|
3559 | 3559 | } |
3560 | 3560 | } |
3561 | 3561 | } |
3562 | 3562 | |
3563 | - public function build_block_arguments( $key, $args ) { |
|
3564 | - $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
3563 | + public function build_block_arguments($key, $args) { |
|
3564 | + $custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : ''; |
|
3565 | 3565 | $options = ''; |
3566 | 3566 | $extra = ''; |
3567 | 3567 | $require = ''; |
@@ -3569,28 +3569,28 @@ discard block |
||
3569 | 3569 | $after_elements = ''; |
3570 | 3570 | |
3571 | 3571 | // `content` is a protected and special argument |
3572 | - if ( $key == 'content' ) { |
|
3572 | + if ($key == 'content') { |
|
3573 | 3573 | return; |
3574 | 3574 | } |
3575 | 3575 | |
3576 | - $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
|
3577 | - $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
|
3576 | + $device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : ''; |
|
3577 | + $device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
|
3578 | 3578 | $device_type_icon = ''; |
3579 | - if($device_type=='Desktop'){ |
|
3579 | + if ($device_type == 'Desktop') { |
|
3580 | 3580 | $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
3581 | - }elseif($device_type=='Tablet'){ |
|
3581 | + }elseif ($device_type == 'Tablet') { |
|
3582 | 3582 | $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
3583 | - }elseif($device_type=='Mobile'){ |
|
3583 | + }elseif ($device_type == 'Mobile') { |
|
3584 | 3584 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
3585 | 3585 | } |
3586 | 3586 | |
3587 | 3587 | // icon |
3588 | 3588 | $icon = ''; |
3589 | - if( !empty( $args['icon'] ) ){ |
|
3589 | + if (!empty($args['icon'])) { |
|
3590 | 3590 | $icon .= "el('div', {"; |
3591 | - $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},"; |
|
3591 | + $icon .= "dangerouslySetInnerHTML: {__html: '" . self::get_widget_icon(esc_attr($args['icon'])) . "'},"; |
|
3592 | 3592 | $icon .= "className: 'text-center',"; |
3593 | - $icon .= "title: '".addslashes( $args['title'] )."',"; |
|
3593 | + $icon .= "title: '" . addslashes($args['title']) . "',"; |
|
3594 | 3594 | $icon .= "}),"; |
3595 | 3595 | |
3596 | 3596 | // blank title as its added to the icon. |
@@ -3598,27 +3598,27 @@ discard block |
||
3598 | 3598 | } |
3599 | 3599 | |
3600 | 3600 | // require advanced |
3601 | - $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; |
|
3601 | + $require_advanced = !empty($args['advanced']) ? "props.attributes.show_advanced && " : ""; |
|
3602 | 3602 | |
3603 | 3603 | // element require |
3604 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
3604 | + $element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : ""; |
|
3605 | 3605 | |
3606 | 3606 | |
3607 | 3607 | $onchange = "props.setAttributes({ $key: $key } )"; |
3608 | - $onchangecomplete = ""; |
|
3608 | + $onchangecomplete = ""; |
|
3609 | 3609 | $value = "props.attributes.$key"; |
3610 | - $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' ); |
|
3611 | - if ( in_array( $args['type'], $text_type ) ) { |
|
3610 | + $text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'colorx', 'range'); |
|
3611 | + if (in_array($args['type'], $text_type)) { |
|
3612 | 3612 | $type = 'TextControl'; |
3613 | 3613 | // Save numbers as numbers and not strings |
3614 | - if ( $args['type'] == 'number' ) { |
|
3614 | + if ($args['type'] == 'number') { |
|
3615 | 3615 | $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; |
3616 | 3616 | } |
3617 | 3617 | |
3618 | - if (substr($key, 0, 9 ) === 'metadata_') { |
|
3619 | - $real_key = str_replace('metadata_','', $key ); |
|
3618 | + if (substr($key, 0, 9) === 'metadata_') { |
|
3619 | + $real_key = str_replace('metadata_', '', $key); |
|
3620 | 3620 | $onchange = "props.setAttributes({ metadata: { $real_key: $key } } )"; |
3621 | - $value = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''"; |
|
3621 | + $value = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''"; |
|
3622 | 3622 | } |
3623 | 3623 | } |
3624 | 3624 | // else if ( $args['type'] == 'popup' ) { |
@@ -3638,12 +3638,12 @@ discard block |
||
3638 | 3638 | // |
3639 | 3639 | // $value = "props.attributes.$key ? props.attributes.$key : ''"; |
3640 | 3640 | // } |
3641 | - else if ( $args['type'] == 'styleid' ) { |
|
3641 | + else if ($args['type'] == 'styleid') { |
|
3642 | 3642 | $type = 'TextControl'; |
3643 | 3643 | $args['type'] == 'text'; |
3644 | 3644 | // Save numbers as numbers and not strings |
3645 | - $value = "props.attributes.$key ? props.attributes.$key : ''"; |
|
3646 | - }else if ( $args['type'] == 'notice' ) { |
|
3645 | + $value = "props.attributes.$key ? props.attributes.$key : ''"; |
|
3646 | + } else if ($args['type'] == 'notice') { |
|
3647 | 3647 | |
3648 | 3648 | $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
3649 | 3649 | $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
@@ -3705,11 +3705,11 @@ discard block |
||
3705 | 3705 | return; |
3706 | 3706 | } |
3707 | 3707 | */ |
3708 | - elseif ( $args['type'] == 'color' ) { |
|
3708 | + elseif ($args['type'] == 'color') { |
|
3709 | 3709 | $type = 'ColorPicker'; |
3710 | 3710 | $onchange = ""; |
3711 | 3711 | $extra = "color: $value,"; |
3712 | - if(!empty($args['disable_alpha'])){ |
|
3712 | + if (!empty($args['disable_alpha'])) { |
|
3713 | 3713 | $extra .= "disableAlpha: true,"; |
3714 | 3714 | } |
3715 | 3715 | $onchangecomplete = "onChangeComplete: function($key) { |
@@ -3718,7 +3718,7 @@ discard block |
||
3718 | 3718 | $key: value |
3719 | 3719 | }); |
3720 | 3720 | },"; |
3721 | - }elseif ( $args['type'] == 'gradient' ) { |
|
3721 | + }elseif ($args['type'] == 'gradient') { |
|
3722 | 3722 | $type = 'GradientPicker'; |
3723 | 3723 | $extra .= "gradients: [{ |
3724 | 3724 | name: 'Vivid cyan blue to vivid purple', |
@@ -3757,7 +3757,7 @@ discard block |
||
3757 | 3757 | slug: 'cool-to-warm-spectrum', |
3758 | 3758 | }],"; |
3759 | 3759 | |
3760 | - }elseif ( $args['type'] == 'image' ) { |
|
3760 | + }elseif ($args['type'] == 'image') { |
|
3761 | 3761 | // print_r($args); |
3762 | 3762 | |
3763 | 3763 | $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key || props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{ |
@@ -3819,7 +3819,7 @@ discard block |
||
3819 | 3819 | $onchange = ""; |
3820 | 3820 | |
3821 | 3821 | //$inside_elements = ",el('div',{},'file upload')"; |
3822 | - } else if ( $args['type'] == 'images' ) { |
|
3822 | + } else if ($args['type'] == 'images') { |
|
3823 | 3823 | $img_preview = "props.attributes.$key && (function() { |
3824 | 3824 | let uploads = JSON.parse('['+props.attributes.$key+']'); |
3825 | 3825 | let images = []; |
@@ -3832,7 +3832,7 @@ discard block |
||
3832 | 3832 | el('i',{ |
3833 | 3833 | className: 'fas fa-times-circle text-danger position-absolute ml-n2 mt-n1 bg-white rounded-circle c-pointer', |
3834 | 3834 | onClick: function() { |
3835 | - aui_confirm('".esc_attr__('Are you sure?')."', '".esc_attr__('Delete')."', '".esc_attr__('Cancel')."', true).then(function(confirmed) { |
|
3835 | + aui_confirm('" . esc_attr__('Are you sure?') . "', '" . esc_attr__('Delete') . "', '" . esc_attr__('Cancel') . "', true).then(function(confirmed) { |
|
3836 | 3836 | if (confirmed) { |
3837 | 3837 | let new_uploads = JSON.parse('['+props.attributes.$key+']'); |
3838 | 3838 | new_uploads.splice(index, 1); |
@@ -3895,36 +3895,36 @@ discard block |
||
3895 | 3895 | |
3896 | 3896 | //$inside_elements = ",el('div',{},'file upload')"; |
3897 | 3897 | } |
3898 | - elseif ( $args['type'] == 'checkbox' ) { |
|
3898 | + elseif ($args['type'] == 'checkbox') { |
|
3899 | 3899 | $type = 'CheckboxControl'; |
3900 | 3900 | $extra .= "checked: props.attributes.$key,"; |
3901 | 3901 | $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
3902 | - } elseif ( $args['type'] == 'textarea' ) { |
|
3902 | + } elseif ($args['type'] == 'textarea') { |
|
3903 | 3903 | $type = 'TextareaControl'; |
3904 | 3904 | |
3905 | - } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
3905 | + } elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') { |
|
3906 | 3906 | $type = 'SelectControl'; |
3907 | 3907 | |
3908 | - if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
|
3909 | - $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
|
3910 | - }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
3911 | - $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
|
3912 | - }else { |
|
3908 | + if ($args['name'] == 'category' && !empty($args['post_type_linked'])) { |
|
3909 | + $options .= "options: taxonomies_" . str_replace("-", "_", $this->id) . ","; |
|
3910 | + }elseif ($args['name'] == 'sort_by' && !empty($args['post_type_linked'])) { |
|
3911 | + $options .= "options: sort_by_" . str_replace("-", "_", $this->id) . ","; |
|
3912 | + } else { |
|
3913 | 3913 | |
3914 | - if ( ! empty( $args['options'] ) ) { |
|
3914 | + if (!empty($args['options'])) { |
|
3915 | 3915 | $options .= "options: ["; |
3916 | - foreach ( $args['options'] as $option_val => $option_label ) { |
|
3917 | - $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },"; |
|
3916 | + foreach ($args['options'] as $option_val => $option_label) { |
|
3917 | + $options .= "{ value: '" . esc_attr($option_val) . "', label: '" . esc_js(addslashes($option_label)) . "' },"; |
|
3918 | 3918 | } |
3919 | 3919 | $options .= "],"; |
3920 | 3920 | } |
3921 | 3921 | } |
3922 | - if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
3922 | + if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
3923 | 3923 | $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, '; |
3924 | 3924 | } |
3925 | 3925 | |
3926 | - if($args['type'] == 'multiselect' || ( isset( $args['multiple'] ) && $args['multiple'] ) ){ |
|
3927 | - $after_elements .= "props.attributes.$key && el( wp.components.Button, { |
|
3926 | + if ($args['type'] == 'multiselect' || (isset($args['multiple']) && $args['multiple'])) { |
|
3927 | + $after_elements .= "props.attributes.$key && el( wp.components.Button, { |
|
3928 | 3928 | className: 'components-button components-circular-option-picker__clear is-secondary is-small', |
3929 | 3929 | style: {margin:'-8px 0 8px 0',display: 'block'}, |
3930 | 3930 | onClick: function(){ |
@@ -3936,7 +3936,7 @@ discard block |
||
3936 | 3936 | 'Clear' |
3937 | 3937 | ),"; |
3938 | 3938 | } |
3939 | - } elseif ( $args['type'] == 'tagselect' ) { |
|
3939 | + } elseif ($args['type'] == 'tagselect') { |
|
3940 | 3940 | // $type = 'FormTokenField'; |
3941 | 3941 | // |
3942 | 3942 | // if ( ! empty( $args['options'] ) ) { |
@@ -3971,19 +3971,19 @@ discard block |
||
3971 | 3971 | // $value = "[]"; |
3972 | 3972 | // $extra .= ' __experimentalExpandOnFocus: true,'; |
3973 | 3973 | |
3974 | - } else if ( $args['type'] == 'alignment' ) { |
|
3974 | + } else if ($args['type'] == 'alignment') { |
|
3975 | 3975 | $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
3976 | - } else if ( $args['type'] == 'margins' ) { |
|
3976 | + } else if ($args['type'] == 'margins') { |
|
3977 | 3977 | |
3978 | - } else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) { |
|
3978 | + } else if ($args['type'] == 'visibility_conditions' && (function_exists('wp_is_block_theme') && wp_is_block_theme())) { |
|
3979 | 3979 | $type = 'TextControl'; |
3980 | 3980 | $value = "(props.attributes.$key ? props.attributes.$key : '')"; |
3981 | 3981 | $args['type'] = 'text'; |
3982 | 3982 | $options .= 'disabled:true,'; |
3983 | - $bsvc_title = esc_attr( addslashes( $args['title'] ) ); |
|
3984 | - $bsvc_body = $this->block_visibility_fields( $args ); |
|
3983 | + $bsvc_title = esc_attr(addslashes($args['title'])); |
|
3984 | + $bsvc_body = $this->block_visibility_fields($args); |
|
3985 | 3985 | // @TODO reset button |
3986 | - $bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __( 'Reset', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __( 'Close', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __( 'Save Rules', 'ayecode-connect' ) . '</button>'; |
|
3986 | + $bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __('Reset', 'ayecode-connect') . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __('Close', 'ayecode-connect') . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __('Save Rules', 'ayecode-connect') . '</button>'; |
|
3987 | 3987 | $after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, { |
3988 | 3988 | className: 'components-button components-circular-option-picker__clear is-primary is-smallx', |
3989 | 3989 | onClick: function() { |
@@ -4002,25 +4002,25 @@ discard block |
||
4002 | 4002 | jQuery('.bs-vc-modal-form').trigger('change'); |
4003 | 4003 | } |
4004 | 4004 | }); |
4005 | - aui_modal('" . $bsvc_title . "', '" . addslashes( $bsvc_body ) . "', '" . $bsvc_footer . "', true, 'bs-vc-modal', 'modal-lg', ''); |
|
4005 | + aui_modal('" . $bsvc_title . "', '" . addslashes($bsvc_body) . "', '" . $bsvc_footer . "', true, 'bs-vc-modal', 'modal-lg', ''); |
|
4006 | 4006 | jQuery(document).off('change', '#bsvc_raw_value').on('change', '#bsvc_raw_value', function(e) { |
4007 | 4007 | props.setAttributes({" . $key . ": e.target.value}); |
4008 | 4008 | }); |
4009 | 4009 | } |
4010 | 4010 | }, |
4011 | - '" . addslashes( ! empty( $args['button_title'] ) ? $args['button_title'] : $args['title'] ) . "' |
|
4011 | + '" . addslashes(!empty($args['button_title']) ? $args['button_title'] : $args['title']) . "' |
|
4012 | 4012 | ) ),"; |
4013 | 4013 | } else { |
4014 | - return;// if we have not implemented the control then don't break the JS. |
|
4014 | + return; // if we have not implemented the control then don't break the JS. |
|
4015 | 4015 | } |
4016 | 4016 | |
4017 | 4017 | // color input does not show the labels so we add them |
4018 | - if($args['type']=='color'){ |
|
4018 | + if ($args['type'] == 'color') { |
|
4019 | 4019 | // add show only if advanced |
4020 | 4020 | echo $require_advanced; |
4021 | 4021 | // add setting require if defined |
4022 | 4022 | echo $element_require; |
4023 | - echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; |
|
4023 | + echo "el('div', {style: {'marginBottom': '8px'}}, '" . addslashes($args['title']) . "'),"; |
|
4024 | 4024 | } |
4025 | 4025 | |
4026 | 4026 | // add show only if advanced |
@@ -4032,22 +4032,22 @@ discard block |
||
4032 | 4032 | // icon |
4033 | 4033 | echo $icon; |
4034 | 4034 | ?> |
4035 | - el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components.".$type; ?>, { |
|
4036 | - label: <?php if ( empty( $args['title'] ) ) { echo "''"; } else if ( empty( $args['row'] ) && ! empty( $args['device_type'] ) ) { ?>el('label',{className:'components-base-control__label',style:{width:"100%"}},el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['title'] ) ?>'}}),<?php if ( $device_type_icon ) { ?>deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})<?php } ?>)<?php |
|
4037 | - } else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>, |
|
4038 | - help: <?php echo ( isset( $args['desc'] ) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim( wp_kses_post( addslashes( $args['desc'] ) ) ) . "'}})" : "''" ); ?>, |
|
4035 | + el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components." . $type; ?>, { |
|
4036 | + label: <?php if (empty($args['title'])) { echo "''"; } else if (empty($args['row']) && !empty($args['device_type'])) { ?>el('label',{className:'components-base-control__label',style:{width:"100%"}},el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes($args['title']) ?>'}}),<?php if ($device_type_icon) { ?>deviceType == '<?php echo $device_type; ?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})<?php } ?>)<?php |
|
4037 | + } else { ?>'<?php echo addslashes(trim(esc_html($args['title']))); ?>'<?php } ?>, |
|
4038 | + help: <?php echo (isset($args['desc']) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim(wp_kses_post(addslashes($args['desc']))) . "'}})" : "''"); ?>, |
|
4039 | 4039 | value: <?php echo $value; ?>, |
4040 | - <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
|
4041 | - echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
4040 | + <?php if ($type == 'TextControl' && $args['type'] != 'text') { |
|
4041 | + echo "type: '" . addslashes($args['type']) . "',"; |
|
4042 | 4042 | } ?> |
4043 | - <?php if ( ! empty( $args['placeholder'] ) ) { |
|
4044 | - echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',"; |
|
4043 | + <?php if (!empty($args['placeholder'])) { |
|
4044 | + echo "placeholder: '" . esc_js(addslashes(trim(esc_html($args['placeholder'])))) . "',"; |
|
4045 | 4045 | } ?> |
4046 | 4046 | <?php echo $options; ?> |
4047 | 4047 | <?php echo $extra; ?> |
4048 | 4048 | <?php echo $custom_attributes; ?> |
4049 | 4049 | <?php echo $onchangecomplete; ?> |
4050 | - <?php if ( $onchange ) { ?> |
|
4050 | + <?php if ($onchange) { ?> |
|
4051 | 4051 | onChange: function ( <?php echo $key; ?> ) { |
4052 | 4052 | <?php echo $onchange; ?> |
4053 | 4053 | } |
@@ -4066,15 +4066,15 @@ discard block |
||
4066 | 4066 | *@todo there is prob a faster way to do this, also we could add some validation here. |
4067 | 4067 | * |
4068 | 4068 | */ |
4069 | - public function array_to_attributes( $custom_attributes, $html = false ) { |
|
4069 | + public function array_to_attributes($custom_attributes, $html = false) { |
|
4070 | 4070 | $attributes = ''; |
4071 | - if ( ! empty( $custom_attributes ) ) { |
|
4071 | + if (!empty($custom_attributes)) { |
|
4072 | 4072 | |
4073 | - foreach ( $custom_attributes as $key => $val ) { |
|
4074 | - if(is_array($val)){ |
|
4075 | - $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
|
4076 | - }else{ |
|
4077 | - $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
4073 | + foreach ($custom_attributes as $key => $val) { |
|
4074 | + if (is_array($val)) { |
|
4075 | + $attributes .= $key . ': {' . $this->array_to_attributes($val, $html) . '},'; |
|
4076 | + } else { |
|
4077 | + $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
4078 | 4078 | } |
4079 | 4079 | } |
4080 | 4080 | |
@@ -4092,113 +4092,113 @@ discard block |
||
4092 | 4092 | * |
4093 | 4093 | * @param $args |
4094 | 4094 | */ |
4095 | - public function block_element( $args, $save = false ) { |
|
4095 | + public function block_element($args, $save = false) { |
|
4096 | 4096 | |
4097 | 4097 | // print_r($args);echo '###';exit; |
4098 | 4098 | |
4099 | - if ( ! empty( $args ) ) { |
|
4100 | - foreach ( $args as $element => $new_args ) { |
|
4099 | + if (!empty($args)) { |
|
4100 | + foreach ($args as $element => $new_args) { |
|
4101 | 4101 | |
4102 | - if ( is_array( $new_args ) ) { // its an element |
|
4102 | + if (is_array($new_args)) { // its an element |
|
4103 | 4103 | |
4104 | 4104 | |
4105 | - if ( isset( $new_args['element'] ) ) { |
|
4105 | + if (isset($new_args['element'])) { |
|
4106 | 4106 | |
4107 | - if ( isset( $new_args['element_require'] ) ) { |
|
4108 | - echo str_replace( array( |
|
4107 | + if (isset($new_args['element_require'])) { |
|
4108 | + echo str_replace(array( |
|
4109 | 4109 | "'+", |
4110 | 4110 | "+'" |
4111 | - ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
4112 | - unset( $new_args['element_require'] ); |
|
4111 | + ), '', $this->block_props_replace($new_args['element_require'])) . " && "; |
|
4112 | + unset($new_args['element_require']); |
|
4113 | 4113 | } |
4114 | 4114 | |
4115 | - if($new_args['element']=='InnerBlocks'){ |
|
4115 | + if ($new_args['element'] == 'InnerBlocks') { |
|
4116 | 4116 | echo "\n el( InnerBlocks, {"; |
4117 | - }elseif($new_args['element']=='innerBlocksProps'){ |
|
4117 | + }elseif ($new_args['element'] == 'innerBlocksProps') { |
|
4118 | 4118 | $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div'; |
4119 | 4119 | // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
4120 | 4120 | // echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
4121 | 4121 | echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
4122 | 4122 | echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {"; |
4123 | - echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; |
|
4123 | + echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : ''; |
|
4124 | 4124 | |
4125 | 4125 | echo "} ), {"; |
4126 | - echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : ''; |
|
4126 | + echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element($new_args['innerBlocksProps'], $save) : ''; |
|
4127 | 4127 | // echo '###'; |
4128 | 4128 | |
4129 | 4129 | // echo '###'; |
4130 | - }elseif($new_args['element']=='BlocksProps'){ |
|
4130 | + }elseif ($new_args['element'] == 'BlocksProps') { |
|
4131 | 4131 | |
4132 | - if ( isset($new_args['if_inner_element']) ) { |
|
4132 | + if (isset($new_args['if_inner_element'])) { |
|
4133 | 4133 | $element = $new_args['if_inner_element']; |
4134 | - }else { |
|
4135 | - $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
|
4134 | + } else { |
|
4135 | + $element = isset($new_args['inner_element']) ? "'" . esc_attr($new_args['inner_element']) . "'" : "'div'"; |
|
4136 | 4136 | } |
4137 | 4137 | |
4138 | 4138 | unset($new_args['inner_element']); |
4139 | 4139 | echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {"; |
4140 | - echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; |
|
4140 | + echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : ''; |
|
4141 | 4141 | |
4142 | 4142 | |
4143 | 4143 | // echo "} ),"; |
4144 | 4144 | |
4145 | - }else{ |
|
4145 | + } else { |
|
4146 | 4146 | echo "\n el( '" . $new_args['element'] . "', {"; |
4147 | 4147 | } |
4148 | 4148 | |
4149 | 4149 | |
4150 | 4150 | // get the attributes |
4151 | - foreach ( $new_args as $new_key => $new_value ) { |
|
4151 | + foreach ($new_args as $new_key => $new_value) { |
|
4152 | 4152 | |
4153 | 4153 | |
4154 | - if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
4154 | + if ($new_key == 'element' || $new_key == 'content' || $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) { |
|
4155 | 4155 | // do nothing |
4156 | 4156 | } else { |
4157 | - echo $this->block_element( array( $new_key => $new_value ),$save ); |
|
4157 | + echo $this->block_element(array($new_key => $new_value), $save); |
|
4158 | 4158 | } |
4159 | 4159 | } |
4160 | 4160 | |
4161 | - echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes |
|
4161 | + echo $new_args['element'] == 'BlocksProps' ? '} ),' : "},"; // end attributes |
|
4162 | 4162 | |
4163 | 4163 | // get the content |
4164 | 4164 | $first_item = 0; |
4165 | - foreach ( $new_args as $new_key => $new_value ) { |
|
4166 | - if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) { |
|
4165 | + foreach ($new_args as $new_key => $new_value) { |
|
4166 | + if ($new_key === 'content' || $new_key === 'if_content' || is_array($new_value)) { |
|
4167 | 4167 | |
4168 | - if ( $new_key === 'content' ) { |
|
4169 | - echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
4170 | - }else if ( $new_key === 'if_content' ) { |
|
4171 | - echo $this->block_props_replace( $new_value ); |
|
4168 | + if ($new_key === 'content') { |
|
4169 | + echo "'" . $this->block_props_replace(wp_slash($new_value)) . "'"; |
|
4170 | + } else if ($new_key === 'if_content') { |
|
4171 | + echo $this->block_props_replace($new_value); |
|
4172 | 4172 | } |
4173 | 4173 | |
4174 | - if ( is_array( $new_value ) ) { |
|
4174 | + if (is_array($new_value)) { |
|
4175 | 4175 | |
4176 | - if ( isset( $new_value['element_require'] ) ) { |
|
4177 | - echo str_replace( array( |
|
4176 | + if (isset($new_value['element_require'])) { |
|
4177 | + echo str_replace(array( |
|
4178 | 4178 | "'+", |
4179 | 4179 | "+'" |
4180 | - ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
4181 | - unset( $new_value['element_require'] ); |
|
4180 | + ), '', $this->block_props_replace($new_value['element_require'])) . " && "; |
|
4181 | + unset($new_value['element_require']); |
|
4182 | 4182 | } |
4183 | 4183 | |
4184 | - if ( isset( $new_value['element_repeat'] ) ) { |
|
4184 | + if (isset($new_value['element_repeat'])) { |
|
4185 | 4185 | $x = 1; |
4186 | - while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
4187 | - $this->block_element( array( '' => $new_value ),$save ); |
|
4188 | - $x ++; |
|
4186 | + while ($x <= absint($new_value['element_repeat'])) { |
|
4187 | + $this->block_element(array('' => $new_value), $save); |
|
4188 | + $x++; |
|
4189 | 4189 | } |
4190 | 4190 | } else { |
4191 | - $this->block_element( array( '' => $new_value ),$save ); |
|
4191 | + $this->block_element(array('' => $new_value), $save); |
|
4192 | 4192 | } |
4193 | 4193 | } |
4194 | - $first_item ++; |
|
4194 | + $first_item++; |
|
4195 | 4195 | } |
4196 | 4196 | } |
4197 | 4197 | |
4198 | - if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){ |
|
4199 | - echo "))";// end content |
|
4200 | - }else{ |
|
4201 | - echo ")";// end content |
|
4198 | + if ($new_args['element'] == 'innerBlocksProps' || $new_args['element'] == 'xBlocksProps') { |
|
4199 | + echo "))"; // end content |
|
4200 | + } else { |
|
4201 | + echo ")"; // end content |
|
4202 | 4202 | } |
4203 | 4203 | |
4204 | 4204 | |
@@ -4207,26 +4207,26 @@ discard block |
||
4207 | 4207 | } |
4208 | 4208 | } else { |
4209 | 4209 | |
4210 | - if ( substr( $element, 0, 3 ) === "if_" ) { |
|
4210 | + if (substr($element, 0, 3) === "if_") { |
|
4211 | 4211 | $extra = ''; |
4212 | - if( strpos($new_args, '[%WrapClass%]') !== false ){ |
|
4213 | - $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args); |
|
4214 | - $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args); |
|
4212 | + if (strpos($new_args, '[%WrapClass%]') !== false) { |
|
4213 | + $new_args = str_replace('[%WrapClass%]"', '" + sd_build_aui_class(props.attributes)', $new_args); |
|
4214 | + $new_args = str_replace('[%WrapClass%]', '+ sd_build_aui_class(props.attributes)', $new_args); |
|
4215 | 4215 | } |
4216 | - echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
4217 | - } elseif ( $element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false ) { |
|
4218 | - $new_args = str_replace('[%WrapStyle%]','',$new_args); |
|
4219 | - echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },"; |
|
4216 | + echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ","; |
|
4217 | + } elseif ($element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false) { |
|
4218 | + $new_args = str_replace('[%WrapStyle%]', '', $new_args); |
|
4219 | + echo $element . ": {..." . $this->block_props_replace($new_args) . " , ...sd_build_aui_styles(props.attributes) },"; |
|
4220 | 4220 | // echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
4221 | - } elseif ( $element == 'style' ) { |
|
4222 | - echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
4223 | - } elseif ( ( $element == 'class' || $element == 'className' ) && strpos($new_args, '[%WrapClass%]') !== false ) { |
|
4224 | - $new_args = str_replace('[%WrapClass%]','',$new_args); |
|
4225 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),"; |
|
4226 | - } elseif ( $element == 'template' && $new_args ) { |
|
4221 | + } elseif ($element == 'style') { |
|
4222 | + echo $element . ": " . $this->block_props_replace($new_args) . ","; |
|
4223 | + } elseif (($element == 'class' || $element == 'className') && strpos($new_args, '[%WrapClass%]') !== false) { |
|
4224 | + $new_args = str_replace('[%WrapClass%]', '', $new_args); |
|
4225 | + echo $element . ": '" . $this->block_props_replace($new_args) . "' + sd_build_aui_class(props.attributes),"; |
|
4226 | + } elseif ($element == 'template' && $new_args) { |
|
4227 | 4227 | echo $element . ": $new_args,"; |
4228 | 4228 | } else { |
4229 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
4229 | + echo $element . ": '" . $this->block_props_replace($new_args) . "',"; |
|
4230 | 4230 | } |
4231 | 4231 | |
4232 | 4232 | } |
@@ -4241,11 +4241,11 @@ discard block |
||
4241 | 4241 | * |
4242 | 4242 | * @return mixed |
4243 | 4243 | */ |
4244 | - public function block_props_replace( $string, $no_wrap = false ) { |
|
4245 | - if ( $no_wrap ) { |
|
4246 | - $string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string ); |
|
4244 | + public function block_props_replace($string, $no_wrap = false) { |
|
4245 | + if ($no_wrap) { |
|
4246 | + $string = str_replace(array("[%", "%]", "%:checked]"), array("props.attributes.", "", ""), $string); |
|
4247 | 4247 | } else { |
4248 | - $string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string ); |
|
4248 | + $string = str_replace(array("![%", "[%", "%]", "%:checked]"), array("'+!props.attributes.", "'+props.attributes.", "+'", "+'"), $string); |
|
4249 | 4249 | } |
4250 | 4250 | |
4251 | 4251 | return $string; |
@@ -4257,65 +4257,65 @@ discard block |
||
4257 | 4257 | * @param array $args |
4258 | 4258 | * @param array $instance |
4259 | 4259 | */ |
4260 | - public function widget( $args, $instance ) { |
|
4261 | - if ( ! is_array( $args ) ) { |
|
4260 | + public function widget($args, $instance) { |
|
4261 | + if (!is_array($args)) { |
|
4262 | 4262 | $args = array(); |
4263 | 4263 | } |
4264 | 4264 | |
4265 | 4265 | // Get the filtered values |
4266 | - $argument_values = $this->argument_values( $instance ); |
|
4267 | - $argument_values = $this->string_to_bool( $argument_values ); |
|
4268 | - $output = $this->output( $argument_values, $args ); |
|
4266 | + $argument_values = $this->argument_values($instance); |
|
4267 | + $argument_values = $this->string_to_bool($argument_values); |
|
4268 | + $output = $this->output($argument_values, $args); |
|
4269 | 4269 | |
4270 | 4270 | $no_wrap = false; |
4271 | - if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
4271 | + if (isset($argument_values['no_wrap']) && $argument_values['no_wrap']) { |
|
4272 | 4272 | $no_wrap = true; |
4273 | 4273 | } |
4274 | 4274 | |
4275 | 4275 | ob_start(); |
4276 | - if ( $output && ! $no_wrap ) { |
|
4276 | + if ($output && !$no_wrap) { |
|
4277 | 4277 | |
4278 | 4278 | $class_original = $this->options['widget_ops']['classname']; |
4279 | - $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); |
|
4279 | + $class = $this->options['widget_ops']['classname'] . " sdel-" . $this->get_instance_hash(); |
|
4280 | 4280 | |
4281 | 4281 | // Before widget |
4282 | - $before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : ''; |
|
4283 | - $before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget; |
|
4284 | - $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
4285 | - $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
4282 | + $before_widget = !empty($args['before_widget']) ? $args['before_widget'] : ''; |
|
4283 | + $before_widget = $before_widget ? str_replace($class_original, $class, $before_widget) : $before_widget; |
|
4284 | + $before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this); |
|
4285 | + $before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this); |
|
4286 | 4286 | |
4287 | 4287 | // After widget |
4288 | - $after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : ''; |
|
4289 | - $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
4290 | - $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
4288 | + $after_widget = !empty($args['after_widget']) ? $args['after_widget'] : ''; |
|
4289 | + $after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this); |
|
4290 | + $after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this); |
|
4291 | 4291 | |
4292 | 4292 | echo $before_widget; |
4293 | 4293 | // elementor strips the widget wrapping div so we check for and add it back if needed |
4294 | - if ( $this->is_elementor_widget_output() ) { |
|
4294 | + if ($this->is_elementor_widget_output()) { |
|
4295 | 4295 | // Filter class & attrs for elementor widget output. |
4296 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
4297 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
4296 | + $class = apply_filters('wp_super_duper_div_classname', $class, $args, $this); |
|
4297 | + $class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this); |
|
4298 | 4298 | |
4299 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
4300 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
4299 | + $attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this); |
|
4300 | + $attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this); |
|
4301 | 4301 | |
4302 | - echo "<span class='" . esc_attr( $class ) . "' " . $attrs . ">"; |
|
4302 | + echo "<span class='" . esc_attr($class) . "' " . $attrs . ">"; |
|
4303 | 4303 | } |
4304 | - echo $this->output_title( $args, $instance ); |
|
4304 | + echo $this->output_title($args, $instance); |
|
4305 | 4305 | echo $output; |
4306 | - if ( $this->is_elementor_widget_output() ) { |
|
4306 | + if ($this->is_elementor_widget_output()) { |
|
4307 | 4307 | echo "</span>"; |
4308 | 4308 | } |
4309 | 4309 | echo $after_widget; |
4310 | - } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
4311 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
4310 | + } elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty |
|
4311 | + $output = $this->preview_placeholder_text("{{" . $this->base_id . "}}"); |
|
4312 | 4312 | echo $output; |
4313 | - } elseif ( $output && $no_wrap ) { |
|
4313 | + } elseif ($output && $no_wrap) { |
|
4314 | 4314 | echo $output; |
4315 | 4315 | } |
4316 | 4316 | $output = ob_get_clean(); |
4317 | 4317 | |
4318 | - $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
4318 | + $output = apply_filters('wp_super_duper_widget_output', $output, $instance, $args, $this); |
|
4319 | 4319 | |
4320 | 4320 | echo $output; |
4321 | 4321 | } |
@@ -4328,7 +4328,7 @@ discard block |
||
4328 | 4328 | */ |
4329 | 4329 | public function is_elementor_widget_output() { |
4330 | 4330 | $result = false; |
4331 | - if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
4331 | + if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') { |
|
4332 | 4332 | $result = true; |
4333 | 4333 | } |
4334 | 4334 | |
@@ -4343,7 +4343,7 @@ discard block |
||
4343 | 4343 | */ |
4344 | 4344 | public function is_elementor_preview() { |
4345 | 4345 | $result = false; |
4346 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
4346 | + if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) { |
|
4347 | 4347 | $result = true; |
4348 | 4348 | } |
4349 | 4349 | |
@@ -4358,7 +4358,7 @@ discard block |
||
4358 | 4358 | */ |
4359 | 4359 | public function is_divi_preview() { |
4360 | 4360 | $result = false; |
4361 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
4361 | + if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) { |
|
4362 | 4362 | $result = true; |
4363 | 4363 | } |
4364 | 4364 | |
@@ -4373,7 +4373,7 @@ discard block |
||
4373 | 4373 | */ |
4374 | 4374 | public function is_beaver_preview() { |
4375 | 4375 | $result = false; |
4376 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
4376 | + if (isset($_REQUEST['fl_builder'])) { |
|
4377 | 4377 | $result = true; |
4378 | 4378 | } |
4379 | 4379 | |
@@ -4388,7 +4388,7 @@ discard block |
||
4388 | 4388 | */ |
4389 | 4389 | public function is_siteorigin_preview() { |
4390 | 4390 | $result = false; |
4391 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
4391 | + if (!empty($_REQUEST['siteorigin_panels_live_editor'])) { |
|
4392 | 4392 | $result = true; |
4393 | 4393 | } |
4394 | 4394 | |
@@ -4403,7 +4403,7 @@ discard block |
||
4403 | 4403 | */ |
4404 | 4404 | public function is_cornerstone_preview() { |
4405 | 4405 | $result = false; |
4406 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
4406 | + if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') { |
|
4407 | 4407 | $result = true; |
4408 | 4408 | } |
4409 | 4409 | |
@@ -4418,7 +4418,7 @@ discard block |
||
4418 | 4418 | */ |
4419 | 4419 | public function is_fusion_preview() { |
4420 | 4420 | $result = false; |
4421 | - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
4421 | + if (!empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce'])) { |
|
4422 | 4422 | $result = true; |
4423 | 4423 | } |
4424 | 4424 | |
@@ -4433,7 +4433,7 @@ discard block |
||
4433 | 4433 | */ |
4434 | 4434 | public function is_oxygen_preview() { |
4435 | 4435 | $result = false; |
4436 | - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
4436 | + if (!empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_"))) { |
|
4437 | 4437 | $result = true; |
4438 | 4438 | } |
4439 | 4439 | |
@@ -4450,7 +4450,7 @@ discard block |
||
4450 | 4450 | public function is_kallyas_zion_preview() { |
4451 | 4451 | $result = false; |
4452 | 4452 | |
4453 | - if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) { |
|
4453 | + if (function_exists('znhg_kallyas_theme_config') && !empty($_REQUEST['zn_pb_edit'])) { |
|
4454 | 4454 | $result = true; |
4455 | 4455 | } |
4456 | 4456 | |
@@ -4467,7 +4467,7 @@ discard block |
||
4467 | 4467 | public function is_bricks_preview() { |
4468 | 4468 | $result = false; |
4469 | 4469 | |
4470 | - if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) { |
|
4470 | + if (function_exists('bricks_is_builder') && (bricks_is_builder() || bricks_is_builder_call())) { |
|
4471 | 4471 | $result = true; |
4472 | 4472 | } |
4473 | 4473 | |
@@ -4482,25 +4482,25 @@ discard block |
||
4482 | 4482 | */ |
4483 | 4483 | public function is_preview() { |
4484 | 4484 | $preview = false; |
4485 | - if ( $this->is_divi_preview() ) { |
|
4485 | + if ($this->is_divi_preview()) { |
|
4486 | 4486 | $preview = true; |
4487 | - } elseif ( $this->is_elementor_preview() ) { |
|
4487 | + } elseif ($this->is_elementor_preview()) { |
|
4488 | 4488 | $preview = true; |
4489 | - } elseif ( $this->is_beaver_preview() ) { |
|
4489 | + } elseif ($this->is_beaver_preview()) { |
|
4490 | 4490 | $preview = true; |
4491 | - } elseif ( $this->is_siteorigin_preview() ) { |
|
4491 | + } elseif ($this->is_siteorigin_preview()) { |
|
4492 | 4492 | $preview = true; |
4493 | - } elseif ( $this->is_cornerstone_preview() ) { |
|
4493 | + } elseif ($this->is_cornerstone_preview()) { |
|
4494 | 4494 | $preview = true; |
4495 | - } elseif ( $this->is_fusion_preview() ) { |
|
4495 | + } elseif ($this->is_fusion_preview()) { |
|
4496 | 4496 | $preview = true; |
4497 | - } elseif ( $this->is_oxygen_preview() ) { |
|
4497 | + } elseif ($this->is_oxygen_preview()) { |
|
4498 | 4498 | $preview = true; |
4499 | - } elseif( $this->is_kallyas_zion_preview() ) { |
|
4499 | + } elseif ($this->is_kallyas_zion_preview()) { |
|
4500 | 4500 | $preview = true; |
4501 | - } elseif( $this->is_block_content_call() ) { |
|
4501 | + } elseif ($this->is_block_content_call()) { |
|
4502 | 4502 | $preview = true; |
4503 | - } elseif( $this->is_bricks_preview() ) { |
|
4503 | + } elseif ($this->is_bricks_preview()) { |
|
4504 | 4504 | $preview = true; |
4505 | 4505 | } |
4506 | 4506 | |
@@ -4515,44 +4515,44 @@ discard block |
||
4515 | 4515 | * |
4516 | 4516 | * @return string |
4517 | 4517 | */ |
4518 | - public function output_title( $args, $instance = array() ) { |
|
4518 | + public function output_title($args, $instance = array()) { |
|
4519 | 4519 | $output = ''; |
4520 | - if ( ! empty( $instance['title'] ) ) { |
|
4520 | + if (!empty($instance['title'])) { |
|
4521 | 4521 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
4522 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
4522 | + $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); |
|
4523 | 4523 | |
4524 | - if ( empty( $instance['widget_title_tag'] ) ) { |
|
4525 | - if ( ! isset( $args['before_title'] ) ) { |
|
4524 | + if (empty($instance['widget_title_tag'])) { |
|
4525 | + if (!isset($args['before_title'])) { |
|
4526 | 4526 | $args['before_title'] = ''; |
4527 | 4527 | } |
4528 | 4528 | |
4529 | - if ( ! isset( $args['after_title'] ) ) { |
|
4529 | + if (!isset($args['after_title'])) { |
|
4530 | 4530 | $args['after_title'] = ''; |
4531 | 4531 | } |
4532 | 4532 | |
4533 | 4533 | $output = $args['before_title'] . $title . $args['after_title']; |
4534 | 4534 | } else { |
4535 | - $tag = esc_attr( $instance['widget_title_tag'] ); |
|
4536 | - $allowed_tags = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' ); |
|
4537 | - $title_tag = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2'; |
|
4535 | + $tag = esc_attr($instance['widget_title_tag']); |
|
4536 | + $allowed_tags = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p'); |
|
4537 | + $title_tag = in_array($tag, $allowed_tags, true) ? esc_attr($tag) : 'h2'; |
|
4538 | 4538 | |
4539 | 4539 | // classes |
4540 | 4540 | $title_classes = array(); |
4541 | - $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
4542 | - $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
4543 | - $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
4544 | - $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
4545 | - $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
4546 | - $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
4547 | - $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
4548 | - $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
4549 | - $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
4550 | - $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
4551 | - $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
4552 | - $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
4553 | - $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
4554 | - |
|
4555 | - $class = !empty( $title_classes ) ? implode(" ",$title_classes) : ''; |
|
4541 | + $title_classes[] = !empty($instance['widget_title_size_class']) ? sanitize_html_class($instance['widget_title_size_class']) : ''; |
|
4542 | + $title_classes[] = !empty($instance['widget_title_align_class']) ? sanitize_html_class($instance['widget_title_align_class']) : ''; |
|
4543 | + $title_classes[] = !empty($instance['widget_title_color_class']) ? "text-" . sanitize_html_class($instance['widget_title_color_class']) : ''; |
|
4544 | + $title_classes[] = !empty($instance['widget_title_border_class']) ? sanitize_html_class($instance['widget_title_border_class']) : ''; |
|
4545 | + $title_classes[] = !empty($instance['widget_title_border_color_class']) ? "border-" . sanitize_html_class($instance['widget_title_border_color_class']) : ''; |
|
4546 | + $title_classes[] = !empty($instance['widget_title_mt_class']) ? "mt-" . absint($instance['widget_title_mt_class']) : ''; |
|
4547 | + $title_classes[] = !empty($instance['widget_title_mr_class']) ? "mr-" . absint($instance['widget_title_mr_class']) : ''; |
|
4548 | + $title_classes[] = !empty($instance['widget_title_mb_class']) ? "mb-" . absint($instance['widget_title_mb_class']) : ''; |
|
4549 | + $title_classes[] = !empty($instance['widget_title_ml_class']) ? "ml-" . absint($instance['widget_title_ml_class']) : ''; |
|
4550 | + $title_classes[] = !empty($instance['widget_title_pt_class']) ? "pt-" . absint($instance['widget_title_pt_class']) : ''; |
|
4551 | + $title_classes[] = !empty($instance['widget_title_pr_class']) ? "pr-" . absint($instance['widget_title_pr_class']) : ''; |
|
4552 | + $title_classes[] = !empty($instance['widget_title_pb_class']) ? "pb-" . absint($instance['widget_title_pb_class']) : ''; |
|
4553 | + $title_classes[] = !empty($instance['widget_title_pl_class']) ? "pl-" . absint($instance['widget_title_pl_class']) : ''; |
|
4554 | + |
|
4555 | + $class = !empty($title_classes) ? implode(" ", $title_classes) : ''; |
|
4556 | 4556 | $output = "<$title_tag class='$class' >$title</$title_tag>"; |
4557 | 4557 | } |
4558 | 4558 | |
@@ -4566,7 +4566,7 @@ discard block |
||
4566 | 4566 | * |
4567 | 4567 | * @param array $instance The widget options. |
4568 | 4568 | */ |
4569 | - public function form( $instance ) { |
|
4569 | + public function form($instance) { |
|
4570 | 4570 | |
4571 | 4571 | // set widget instance |
4572 | 4572 | $this->instance = $instance; |
@@ -4574,20 +4574,20 @@ discard block |
||
4574 | 4574 | // set it as a SD widget |
4575 | 4575 | echo $this->widget_advanced_toggle(); |
4576 | 4576 | |
4577 | - echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
4577 | + echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>"; |
|
4578 | 4578 | $arguments_raw = $this->get_arguments(); |
4579 | 4579 | |
4580 | - if ( is_array( $arguments_raw ) ) { |
|
4580 | + if (is_array($arguments_raw)) { |
|
4581 | 4581 | |
4582 | - $arguments = $this->group_arguments( $arguments_raw ); |
|
4582 | + $arguments = $this->group_arguments($arguments_raw); |
|
4583 | 4583 | |
4584 | 4584 | // Do we have sections? |
4585 | 4585 | $has_sections = $arguments == $arguments_raw ? false : true; |
4586 | 4586 | |
4587 | 4587 | |
4588 | - if ( $has_sections ) { |
|
4588 | + if ($has_sections) { |
|
4589 | 4589 | $panel_count = 0; |
4590 | - foreach ( $arguments as $key => $args ) { |
|
4590 | + foreach ($arguments as $key => $args) { |
|
4591 | 4591 | |
4592 | 4592 | ?> |
4593 | 4593 | <script> |
@@ -4597,26 +4597,26 @@ discard block |
||
4597 | 4597 | |
4598 | 4598 | $hide = $panel_count ? ' style="display:none;" ' : ''; |
4599 | 4599 | $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
4600 | - 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>"; |
|
4601 | - echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
4600 | + 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>"; |
|
4601 | + echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes($key) . "' $hide>"; |
|
4602 | 4602 | |
4603 | - foreach ( $args as $k => $a ) { |
|
4603 | + foreach ($args as $k => $a) { |
|
4604 | 4604 | |
4605 | 4605 | $this->widget_inputs_row_start($k, $a); |
4606 | - $this->widget_inputs( $a, $instance ); |
|
4606 | + $this->widget_inputs($a, $instance); |
|
4607 | 4607 | $this->widget_inputs_row_end($k, $a); |
4608 | 4608 | |
4609 | 4609 | } |
4610 | 4610 | |
4611 | 4611 | echo "</div>"; |
4612 | 4612 | |
4613 | - $panel_count ++; |
|
4613 | + $panel_count++; |
|
4614 | 4614 | |
4615 | 4615 | } |
4616 | 4616 | } else { |
4617 | - foreach ( $arguments as $key => $args ) { |
|
4617 | + foreach ($arguments as $key => $args) { |
|
4618 | 4618 | $this->widget_inputs_row_start($key, $args); |
4619 | - $this->widget_inputs( $args, $instance ); |
|
4619 | + $this->widget_inputs($args, $instance); |
|
4620 | 4620 | $this->widget_inputs_row_end($key, $args); |
4621 | 4621 | } |
4622 | 4622 | } |
@@ -4624,28 +4624,28 @@ discard block |
||
4624 | 4624 | } |
4625 | 4625 | } |
4626 | 4626 | |
4627 | - public function widget_inputs_row_start( $key, $args ) { |
|
4628 | - if ( ! empty( $args['row'] ) ) { |
|
4627 | + public function widget_inputs_row_start($key, $args) { |
|
4628 | + if (!empty($args['row'])) { |
|
4629 | 4629 | // Maybe open |
4630 | - if ( ! empty( $args['row']['open'] ) ) { |
|
4630 | + if (!empty($args['row']['open'])) { |
|
4631 | 4631 | ?> |
4632 | - <div class='bsui sd-argument' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php echo ( ! empty( $args['row']['element_require'] ) ? $this->convert_element_require( $args['row']['element_require'] ) : '' ); ?>'> |
|
4633 | - <?php if ( ! empty( $args['row']['title'] ) ) { ?> |
|
4632 | + <div class='bsui sd-argument' data-argument='<?php echo esc_attr($args['row']['key']); ?>' data-element_require='<?php echo (!empty($args['row']['element_require']) ? $this->convert_element_require($args['row']['element_require']) : ''); ?>'> |
|
4633 | + <?php if (!empty($args['row']['title'])) { ?> |
|
4634 | 4634 | <?php |
4635 | - if ( isset( $args['row']['icon'] ) ) { |
|
4635 | + if (isset($args['row']['icon'])) { |
|
4636 | 4636 | $args['row']['icon'] = ''; |
4637 | 4637 | } |
4638 | 4638 | |
4639 | - if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) { |
|
4639 | + if (!isset($args['row']['device_type']) && isset($args['device_type'])) { |
|
4640 | 4640 | $args['row']['device_type'] = $args['device_type']; |
4641 | 4641 | } |
4642 | 4642 | ?> |
4643 | - <label class="mb-0"><?php echo $this->widget_field_title( $args['row'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label> |
|
4643 | + <label class="mb-0"><?php echo $this->widget_field_title($args['row']); ?><?php echo $this->widget_field_desc($args['row']); ?></label> |
|
4644 | 4644 | <?php } ?> |
4645 | - <div class='row<?php echo ( ! empty( $args['row']['class'] ) ? ' ' . esc_attr( $args['row']['class'] ) : '' ); ?>'> |
|
4645 | + <div class='row<?php echo (!empty($args['row']['class']) ? ' ' . esc_attr($args['row']['class']) : ''); ?>'> |
|
4646 | 4646 | <div class='col pr-2'> |
4647 | 4647 | <?php |
4648 | - } else if ( ! empty( $args['row']['close'] ) ) { |
|
4648 | + } else if (!empty($args['row']['close'])) { |
|
4649 | 4649 | echo "<div class='col pl-0 ps-0'>"; |
4650 | 4650 | } else { |
4651 | 4651 | echo "<div class='col pl-0 ps-0 pr-2 pe-2'>"; |
@@ -4653,10 +4653,10 @@ discard block |
||
4653 | 4653 | } |
4654 | 4654 | } |
4655 | 4655 | |
4656 | - public function widget_inputs_row_end( $key, $args ) { |
|
4657 | - if ( ! empty( $args['row'] ) ) { |
|
4656 | + public function widget_inputs_row_end($key, $args) { |
|
4657 | + if (!empty($args['row'])) { |
|
4658 | 4658 | // Maybe close |
4659 | - if ( ! empty( $args['row']['close'] ) ) { |
|
4659 | + if (!empty($args['row']['close'])) { |
|
4660 | 4660 | echo "</div></div>"; |
4661 | 4661 | } |
4662 | 4662 | echo "</div>"; |
@@ -4671,7 +4671,7 @@ discard block |
||
4671 | 4671 | public function widget_advanced_toggle() { |
4672 | 4672 | |
4673 | 4673 | $output = ''; |
4674 | - if ( $this->block_show_advanced() ) { |
|
4674 | + if ($this->block_show_advanced()) { |
|
4675 | 4675 | $val = 1; |
4676 | 4676 | } else { |
4677 | 4677 | $val = 0; |
@@ -4691,14 +4691,14 @@ discard block |
||
4691 | 4691 | *@since 1.0.0 |
4692 | 4692 | * |
4693 | 4693 | */ |
4694 | - public function convert_element_require( $input ) { |
|
4695 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
4694 | + public function convert_element_require($input) { |
|
4695 | + $input = str_replace("'", '"', $input); // we only want double quotes |
|
4696 | 4696 | |
4697 | - $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array( |
|
4697 | + $output = esc_attr(str_replace(array("[%", "%]", "%:checked]"), array( |
|
4698 | 4698 | "jQuery(form).find('[data-argument=\"", |
4699 | 4699 | "\"]').find('input,select,textarea').val()", |
4700 | 4700 | "\"]').find('input:checked').val()" |
4701 | - ), $input ) ); |
|
4701 | + ), $input)); |
|
4702 | 4702 | |
4703 | 4703 | return $output; |
4704 | 4704 | } |
@@ -4709,48 +4709,48 @@ discard block |
||
4709 | 4709 | * @param $args |
4710 | 4710 | * @param $instance |
4711 | 4711 | */ |
4712 | - public function widget_inputs( $args, $instance ) { |
|
4712 | + public function widget_inputs($args, $instance) { |
|
4713 | 4713 | |
4714 | 4714 | $class = ""; |
4715 | 4715 | $element_require = ""; |
4716 | 4716 | $custom_attributes = ""; |
4717 | 4717 | |
4718 | 4718 | // get value |
4719 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
4720 | - $value = $instance[ $args['name'] ]; |
|
4721 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
4722 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
4719 | + if (isset($instance[$args['name']])) { |
|
4720 | + $value = $instance[$args['name']]; |
|
4721 | + } elseif (!isset($instance[$args['name']]) && !empty($args['default'])) { |
|
4722 | + $value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']); |
|
4723 | 4723 | } else { |
4724 | 4724 | $value = ''; |
4725 | 4725 | } |
4726 | 4726 | |
4727 | 4727 | // get placeholder |
4728 | - if ( ! empty( $args['placeholder'] ) ) { |
|
4729 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
4728 | + if (!empty($args['placeholder'])) { |
|
4729 | + $placeholder = "placeholder='" . esc_html($args['placeholder']) . "'"; |
|
4730 | 4730 | } else { |
4731 | 4731 | $placeholder = ''; |
4732 | 4732 | } |
4733 | 4733 | |
4734 | 4734 | // get if advanced |
4735 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
4735 | + if (isset($args['advanced']) && $args['advanced']) { |
|
4736 | 4736 | $class .= " sd-advanced-setting "; |
4737 | 4737 | } |
4738 | 4738 | |
4739 | 4739 | // element_require |
4740 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
4740 | + if (isset($args['element_require']) && $args['element_require']) { |
|
4741 | 4741 | $element_require = $args['element_require']; |
4742 | 4742 | } |
4743 | 4743 | |
4744 | 4744 | // custom_attributes |
4745 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
4746 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
4745 | + if (isset($args['custom_attributes']) && $args['custom_attributes']) { |
|
4746 | + $custom_attributes = $this->array_to_attributes($args['custom_attributes'], true); |
|
4747 | 4747 | } |
4748 | 4748 | |
4749 | 4749 | // before wrapper |
4750 | 4750 | ?> |
4751 | - <p class="sd-argument <?php echo esc_attr( $class ); ?>" data-argument='<?php echo esc_attr( $args['name'] ); ?>' data-element_require='<?php if ( $element_require ) { echo $this->convert_element_require( $element_require );} ?>'> |
|
4751 | + <p class="sd-argument <?php echo esc_attr($class); ?>" data-argument='<?php echo esc_attr($args['name']); ?>' data-element_require='<?php if ($element_require) { echo $this->convert_element_require($element_require); } ?>'> |
|
4752 | 4752 | <?php |
4753 | - switch ( $args['type'] ) { |
|
4753 | + switch ($args['type']) { |
|
4754 | 4754 | //array('text','password','number','email','tel','url','color') |
4755 | 4755 | case "text": |
4756 | 4756 | case "password": |
@@ -4760,33 +4760,33 @@ discard block |
||
4760 | 4760 | case "url": |
4761 | 4761 | case "color": |
4762 | 4762 | ?> |
4763 | - <label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
4764 | - <input <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="<?php echo esc_attr( $args['type'] ); ?>" value="<?php echo esc_attr( $value ); ?>"> |
|
4763 | + <label for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
4764 | + <input <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="<?php echo esc_attr($args['type']); ?>" value="<?php echo esc_attr($value); ?>"> |
|
4765 | 4765 | <?php |
4766 | 4766 | |
4767 | 4767 | break; |
4768 | 4768 | case "select": |
4769 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
4770 | - if ( $multiple ) { |
|
4771 | - if ( empty( $value ) ) { |
|
4769 | + $multiple = isset($args['multiple']) && $args['multiple'] ? true : false; |
|
4770 | + if ($multiple) { |
|
4771 | + if (empty($value)) { |
|
4772 | 4772 | $value = array(); |
4773 | 4773 | } |
4774 | 4774 | } |
4775 | 4775 | ?> |
4776 | - <label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
4777 | - <select <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); if ( $multiple ) { echo "[]"; } ?>" |
|
4778 | - <?php if ( $multiple ) { |
|
4776 | + <label for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
4777 | + <select <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); if ($multiple) { echo "[]"; } ?>" |
|
4778 | + <?php if ($multiple) { |
|
4779 | 4779 | echo "multiple"; |
4780 | 4780 | } //@todo not implemented yet due to gutenberg not supporting it |
4781 | 4781 | ?>> |
4782 | 4782 | <?php |
4783 | 4783 | |
4784 | - if ( ! empty( $args['options'] ) ) { |
|
4785 | - foreach ( $args['options'] as $val => $label ) { |
|
4786 | - if ( $multiple ) { |
|
4787 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
4784 | + if (!empty($args['options'])) { |
|
4785 | + foreach ($args['options'] as $val => $label) { |
|
4786 | + if ($multiple) { |
|
4787 | + $selected = in_array($val, $value) ? 'selected="selected"' : ''; |
|
4788 | 4788 | } else { |
4789 | - $selected = selected( $value, $val, false ); |
|
4789 | + $selected = selected($value, $val, false); |
|
4790 | 4790 | } |
4791 | 4791 | echo "<option value='$val' " . $selected . ">$label</option>"; |
4792 | 4792 | } |
@@ -4797,20 +4797,20 @@ discard block |
||
4797 | 4797 | break; |
4798 | 4798 | case "checkbox": |
4799 | 4799 | ?> |
4800 | - <input <?php echo $placeholder; ?> <?php checked( 1, $value, true ) ?> <?php echo $custom_attributes; ?> class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox" value="1"> |
|
4801 | - <label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
4800 | + <input <?php echo $placeholder; ?> <?php checked(1, $value, true) ?> <?php echo $custom_attributes; ?> class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox" value="1"> |
|
4801 | + <label for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
4802 | 4802 | <?php |
4803 | 4803 | break; |
4804 | 4804 | case "textarea": |
4805 | 4805 | ?> |
4806 | - <label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
4807 | - <textarea <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"><?php echo esc_attr( $value ); ?></textarea> |
|
4806 | + <label for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
4807 | + <textarea <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>"><?php echo esc_attr($value); ?></textarea> |
|
4808 | 4808 | <?php |
4809 | 4809 | |
4810 | 4810 | break; |
4811 | 4811 | case "hidden": |
4812 | 4812 | ?> |
4813 | - <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" value="<?php echo esc_attr( $value ); ?>"> |
|
4813 | + <input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden" value="<?php echo esc_attr($value); ?>"> |
|
4814 | 4814 | <?php |
4815 | 4815 | break; |
4816 | 4816 | default: |
@@ -4820,15 +4820,15 @@ discard block |
||
4820 | 4820 | ?></p><?php |
4821 | 4821 | } |
4822 | 4822 | |
4823 | - public function get_widget_icon($icon = 'box-top', $title = ''){ |
|
4824 | - if($icon=='box-top'){ |
|
4825 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
4826 | - }elseif($icon=='box-right'){ |
|
4827 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
4828 | - }elseif($icon=='box-bottom'){ |
|
4829 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
4830 | - }elseif($icon=='box-left'){ |
|
4831 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
4823 | + public function get_widget_icon($icon = 'box-top', $title = '') { |
|
4824 | + if ($icon == 'box-top') { |
|
4825 | + return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
4826 | + }elseif ($icon == 'box-right') { |
|
4827 | + return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
4828 | + }elseif ($icon == 'box-bottom') { |
|
4829 | + return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
4830 | + }elseif ($icon == 'box-left') { |
|
4831 | + return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
4832 | 4832 | } |
4833 | 4833 | } |
4834 | 4834 | |
@@ -4840,14 +4840,14 @@ discard block |
||
4840 | 4840 | * @return string |
4841 | 4841 | * @todo, need to make its own tooltip script |
4842 | 4842 | */ |
4843 | - public function widget_field_desc( $args ) { |
|
4843 | + public function widget_field_desc($args) { |
|
4844 | 4844 | |
4845 | 4845 | $description = ''; |
4846 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
4847 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
4848 | - $description = $this->desc_tip( $args['desc'] ); |
|
4846 | + if (isset($args['desc']) && $args['desc']) { |
|
4847 | + if (isset($args['desc_tip']) && $args['desc_tip']) { |
|
4848 | + $description = $this->desc_tip($args['desc']); |
|
4849 | 4849 | } else { |
4850 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
4850 | + $description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>'; |
|
4851 | 4851 | } |
4852 | 4852 | } |
4853 | 4853 | |
@@ -4861,18 +4861,18 @@ discard block |
||
4861 | 4861 | * |
4862 | 4862 | * @return string |
4863 | 4863 | */ |
4864 | - public function widget_field_title( $args ) { |
|
4864 | + public function widget_field_title($args) { |
|
4865 | 4865 | $title = ''; |
4866 | 4866 | |
4867 | - if ( isset( $args['title'] ) && $args['title'] ) { |
|
4868 | - if ( ! empty( $args['device_type'] ) ) { |
|
4867 | + if (isset($args['title']) && $args['title']) { |
|
4868 | + if (!empty($args['device_type'])) { |
|
4869 | 4869 | $args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title. |
4870 | 4870 | } |
4871 | 4871 | |
4872 | - if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
4873 | - $title = self::get_widget_icon( $args['icon'], $args['title'] ); |
|
4872 | + if (isset($args['icon']) && $args['icon']) { |
|
4873 | + $title = self::get_widget_icon($args['icon'], $args['title']); |
|
4874 | 4874 | } else { |
4875 | - $title = esc_attr( $args['title'] ); |
|
4875 | + $title = esc_attr($args['title']); |
|
4876 | 4876 | } |
4877 | 4877 | } |
4878 | 4878 | |
@@ -4887,11 +4887,11 @@ discard block |
||
4887 | 4887 | * |
4888 | 4888 | * @return string |
4889 | 4889 | */ |
4890 | - function desc_tip( $tip, $allow_html = false ) { |
|
4891 | - if ( $allow_html ) { |
|
4892 | - $tip = $this->sanitize_tooltip( $tip ); |
|
4890 | + function desc_tip($tip, $allow_html = false) { |
|
4891 | + if ($allow_html) { |
|
4892 | + $tip = $this->sanitize_tooltip($tip); |
|
4893 | 4893 | } else { |
4894 | - $tip = esc_attr( $tip ); |
|
4894 | + $tip = esc_attr($tip); |
|
4895 | 4895 | } |
4896 | 4896 | |
4897 | 4897 | return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -4904,8 +4904,8 @@ discard block |
||
4904 | 4904 | * |
4905 | 4905 | * @return string |
4906 | 4906 | */ |
4907 | - public function sanitize_tooltip( $var ) { |
|
4908 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
4907 | + public function sanitize_tooltip($var) { |
|
4908 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
4909 | 4909 | 'br' => array(), |
4910 | 4910 | 'em' => array(), |
4911 | 4911 | 'strong' => array(), |
@@ -4915,7 +4915,7 @@ discard block |
||
4915 | 4915 | 'li' => array(), |
4916 | 4916 | 'ol' => array(), |
4917 | 4917 | 'p' => array(), |
4918 | - ) ) ); |
|
4918 | + ))); |
|
4919 | 4919 | } |
4920 | 4920 | |
4921 | 4921 | /** |
@@ -4927,30 +4927,30 @@ discard block |
||
4927 | 4927 | * @return array |
4928 | 4928 | * @todo we should add some sanitation here. |
4929 | 4929 | */ |
4930 | - public function update( $new_instance, $old_instance ) { |
|
4930 | + public function update($new_instance, $old_instance) { |
|
4931 | 4931 | |
4932 | 4932 | //save the widget |
4933 | - $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
4933 | + $instance = array_merge((array) $old_instance, (array) $new_instance); |
|
4934 | 4934 | |
4935 | 4935 | // set widget instance |
4936 | 4936 | $this->instance = $instance; |
4937 | 4937 | |
4938 | - if ( empty( $this->arguments ) ) { |
|
4938 | + if (empty($this->arguments)) { |
|
4939 | 4939 | $this->get_arguments(); |
4940 | 4940 | } |
4941 | 4941 | |
4942 | 4942 | // check for checkboxes |
4943 | - if ( ! empty( $this->arguments ) ) { |
|
4944 | - foreach ( $this->arguments as $argument ) { |
|
4945 | - if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
4946 | - $instance[ $argument['name'] ] = '0'; |
|
4943 | + if (!empty($this->arguments)) { |
|
4944 | + foreach ($this->arguments as $argument) { |
|
4945 | + if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) { |
|
4946 | + $instance[$argument['name']] = '0'; |
|
4947 | 4947 | } |
4948 | 4948 | } |
4949 | 4949 | } |
4950 | 4950 | |
4951 | 4951 | // maybe sanitize widget title |
4952 | - if(!empty($instance['title'])) { |
|
4953 | - $instance['title'] = wp_kses_post( $instance['title'] ); |
|
4952 | + if (!empty($instance['title'])) { |
|
4953 | + $instance['title'] = wp_kses_post($instance['title']); |
|
4954 | 4954 | } |
4955 | 4955 | |
4956 | 4956 | return $instance; |
@@ -4966,7 +4966,7 @@ discard block |
||
4966 | 4966 | */ |
4967 | 4967 | public function is_block_content_call() { |
4968 | 4968 | $result = false; |
4969 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
4969 | + if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') { |
|
4970 | 4970 | $result = true; |
4971 | 4971 | } |
4972 | 4972 | |
@@ -4979,9 +4979,9 @@ discard block |
||
4979 | 4979 | * @return string |
4980 | 4980 | *@since 1.0.20 |
4981 | 4981 | */ |
4982 | - public function get_instance_hash(){ |
|
4983 | - $instance_string = $this->base_id.serialize($this->instance); |
|
4984 | - return hash('crc32b',$instance_string); |
|
4982 | + public function get_instance_hash() { |
|
4983 | + $instance_string = $this->base_id . serialize($this->instance); |
|
4984 | + return hash('crc32b', $instance_string); |
|
4985 | 4985 | } |
4986 | 4986 | |
4987 | 4987 | /** |
@@ -4992,14 +4992,14 @@ discard block |
||
4992 | 4992 | * @return string |
4993 | 4993 | *@since 1.0.20 |
4994 | 4994 | */ |
4995 | - public function get_instance_style($rules = array()){ |
|
4995 | + public function get_instance_style($rules = array()) { |
|
4996 | 4996 | $css = ''; |
4997 | 4997 | |
4998 | - if(!empty($rules)){ |
|
4998 | + if (!empty($rules)) { |
|
4999 | 4999 | $rules = array_unique($rules); |
5000 | 5000 | $instance_hash = $this->get_instance_hash(); |
5001 | 5001 | $css .= "<style>"; |
5002 | - foreach($rules as $rule){ |
|
5002 | + foreach ($rules as $rule) { |
|
5003 | 5003 | $css .= ".sdel-$instance_hash $rule"; |
5004 | 5004 | } |
5005 | 5005 | $css .= "</style>"; |
@@ -5017,9 +5017,9 @@ discard block |
||
5017 | 5017 | *@since 1.0.28 |
5018 | 5018 | * |
5019 | 5019 | */ |
5020 | - public function encode_shortcodes( $content ) { |
|
5020 | + public function encode_shortcodes($content) { |
|
5021 | 5021 | // Avoids existing encoded tags. |
5022 | - $trans = array( |
|
5022 | + $trans = array( |
|
5023 | 5023 | '[' => '[', |
5024 | 5024 | ']' => ']', |
5025 | 5025 | '&#91;' => '[', |
@@ -5030,7 +5030,7 @@ discard block |
||
5030 | 5030 | '&gt;' => '&0gt;', |
5031 | 5031 | ); |
5032 | 5032 | |
5033 | - $content = strtr( $content, $trans ); |
|
5033 | + $content = strtr($content, $trans); |
|
5034 | 5034 | |
5035 | 5035 | $trans = array( |
5036 | 5036 | '[' => '[', |
@@ -5041,7 +5041,7 @@ discard block |
||
5041 | 5041 | "'" => ''', |
5042 | 5042 | ); |
5043 | 5043 | |
5044 | - $content = strtr( $content, $trans ); |
|
5044 | + $content = strtr($content, $trans); |
|
5045 | 5045 | |
5046 | 5046 | return $content; |
5047 | 5047 | } |
@@ -5055,8 +5055,8 @@ discard block |
||
5055 | 5055 | *@since 1.0.28 |
5056 | 5056 | * |
5057 | 5057 | */ |
5058 | - public function decode_shortcodes( $content ) { |
|
5059 | - $trans = array( |
|
5058 | + public function decode_shortcodes($content) { |
|
5059 | + $trans = array( |
|
5060 | 5060 | '[' => '[', |
5061 | 5061 | ']' => ']', |
5062 | 5062 | '&#91;' => '[', |
@@ -5069,7 +5069,7 @@ discard block |
||
5069 | 5069 | ''' => "'", |
5070 | 5070 | ); |
5071 | 5071 | |
5072 | - $content = strtr( $content, $trans ); |
|
5072 | + $content = strtr($content, $trans); |
|
5073 | 5073 | |
5074 | 5074 | $trans = array( |
5075 | 5075 | '[' => '[', |
@@ -5082,31 +5082,31 @@ discard block |
||
5082 | 5082 | '&0gt;' => '>', |
5083 | 5083 | ); |
5084 | 5084 | |
5085 | - $content = strtr( $content, $trans ); |
|
5085 | + $content = strtr($content, $trans); |
|
5086 | 5086 | |
5087 | 5087 | return $content; |
5088 | 5088 | } |
5089 | 5089 | |
5090 | - public function block_visibility_fields( $args ) { |
|
5091 | - $value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : ''; |
|
5090 | + public function block_visibility_fields($args) { |
|
5091 | + $value = !empty($args['value']) ? esc_attr($args['value']) : ''; |
|
5092 | 5092 | $content = '<div class="bs-vc-rule-template d-none">'; |
5093 | 5093 | $content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >'; |
5094 | 5094 | $content .= '<div class="row">'; |
5095 | 5095 | $content .= '<div class="col-sm-12">'; |
5096 | - $content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__( 'Remove Rule', 'ayecode-connect' ) . '"><i class="fas fa-circle-minus fs-6"></i></span></div>'; |
|
5096 | + $content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__('Remove Rule', 'ayecode-connect') . '"><i class="fas fa-circle-minus fs-6"></i></span></div>'; |
|
5097 | 5097 | $content .= aui()->select( |
5098 | 5098 | array( |
5099 | 5099 | 'id' => 'bsvc_rule_BSVCINDEX', |
5100 | 5100 | 'name' => 'bsvc_rule_BSVCINDEX', |
5101 | - 'label' => __( 'Rule', 'ayecode-connect' ), |
|
5102 | - 'placeholder' => __( 'Select Rule...', 'ayecode-connect' ), |
|
5101 | + 'label' => __('Rule', 'ayecode-connect'), |
|
5102 | + 'placeholder' => __('Select Rule...', 'ayecode-connect'), |
|
5103 | 5103 | 'class' => 'bsvc_rule form-select-sm no-select2 mw-100', |
5104 | 5104 | 'options' => sd_visibility_rules_options(), |
5105 | 5105 | 'default' => '', |
5106 | 5106 | 'value' => '', |
5107 | 5107 | 'label_type' => '', |
5108 | 5108 | 'select2' => false, |
5109 | - 'input_group_left' => __( 'Rule:', 'ayecode-connect' ), |
|
5109 | + 'input_group_left' => __('Rule:', 'ayecode-connect'), |
|
5110 | 5110 | 'extra_attributes' => array( |
5111 | 5111 | 'data-minimum-results-for-search' => '-1' |
5112 | 5112 | ) |
@@ -5115,15 +5115,15 @@ discard block |
||
5115 | 5115 | |
5116 | 5116 | $content .= '</div>'; |
5117 | 5117 | |
5118 | - if ( class_exists( 'GeoDirectory' ) ) { |
|
5118 | + if (class_exists('GeoDirectory')) { |
|
5119 | 5119 | $content .= '<div class="col-md-7 col-sm-12">'; |
5120 | 5120 | |
5121 | 5121 | $content .= aui()->select( |
5122 | 5122 | array( |
5123 | 5123 | 'id' => 'bsvc_gd_field_BSVCINDEX', |
5124 | 5124 | 'name' => 'bsvc_gd_field_BSVCINDEX', |
5125 | - 'label' => __( 'FIELD', 'ayecode-connect' ), |
|
5126 | - 'placeholder' => __( 'FIELD', 'ayecode-connect' ), |
|
5125 | + 'label' => __('FIELD', 'ayecode-connect'), |
|
5126 | + 'placeholder' => __('FIELD', 'ayecode-connect'), |
|
5127 | 5127 | 'class' => 'bsvc_gd_field form-select-sm no-select2 mw-100', |
5128 | 5128 | 'options' => sd_visibility_gd_field_options(), |
5129 | 5129 | 'default' => '', |
@@ -5144,8 +5144,8 @@ discard block |
||
5144 | 5144 | array( |
5145 | 5145 | 'id' => 'bsvc_gd_field_condition_BSVCINDEX', |
5146 | 5146 | 'name' => 'bsvc_gd_field_condition_BSVCINDEX', |
5147 | - 'label' => __( 'CONDITION', 'ayecode-connect' ), |
|
5148 | - 'placeholder' => __( 'CONDITION', 'ayecode-connect' ), |
|
5147 | + 'label' => __('CONDITION', 'ayecode-connect'), |
|
5148 | + 'placeholder' => __('CONDITION', 'ayecode-connect'), |
|
5149 | 5149 | 'class' => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100', |
5150 | 5150 | 'options' => sd_visibility_field_condition_options(), |
5151 | 5151 | 'default' => '', |
@@ -5167,9 +5167,9 @@ discard block |
||
5167 | 5167 | 'type' => 'text', |
5168 | 5168 | 'id' => 'bsvc_gd_field_search_BSVCINDEX', |
5169 | 5169 | 'name' => 'bsvc_gd_field_search_BSVCINDEX', |
5170 | - 'label' => __( 'VALUE TO MATCH', 'ayecode-connect' ), |
|
5170 | + 'label' => __('VALUE TO MATCH', 'ayecode-connect'), |
|
5171 | 5171 | 'class' => 'bsvc_gd_field_search form-control-sm', |
5172 | - 'placeholder' => __( 'VALUE TO MATCH', 'ayecode-connect' ), |
|
5172 | + 'placeholder' => __('VALUE TO MATCH', 'ayecode-connect'), |
|
5173 | 5173 | 'label_type' => '', |
5174 | 5174 | 'value' => '', |
5175 | 5175 | 'element_require' => '([%bsvc_rule_BSVCINDEX%]=="gd_field" && [%bsvc_gd_field_condition_BSVCINDEX%] && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_empty" && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_not_empty")' |
@@ -5179,15 +5179,15 @@ discard block |
||
5179 | 5179 | $content .= '</div>'; |
5180 | 5180 | } |
5181 | 5181 | |
5182 | - $content .= apply_filters( 'sd_block_visibility_fields', '', $args ); |
|
5182 | + $content .= apply_filters('sd_block_visibility_fields', '', $args); |
|
5183 | 5183 | |
5184 | 5184 | $content .= '</div>'; |
5185 | 5185 | |
5186 | - $content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __( 'Select User Roles:', 'ayecode-connect' ) . '</label>'; |
|
5186 | + $content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __('Select User Roles:', 'ayecode-connect') . '</label>'; |
|
5187 | 5187 | $role_options = sd_user_roles_options(); |
5188 | 5188 | |
5189 | 5189 | $role_option_i = 0; |
5190 | - foreach ( $role_options as $role_option_key => $role_option_name ) { |
|
5190 | + foreach ($role_options as $role_option_key => $role_option_name) { |
|
5191 | 5191 | $role_option_i++; |
5192 | 5192 | |
5193 | 5193 | $content .= '<div class="col-sm-6">'; |
@@ -5207,19 +5207,19 @@ discard block |
||
5207 | 5207 | $content .= '</div>'; |
5208 | 5208 | } |
5209 | 5209 | $content .= '</div>'; |
5210 | - $content .= '<div class="bs-vc-sep-wrap text-center position-absolute top-0 mt-n3"><div class="bs-vc-sep-cond d-inline-block badge text-dark bg-gray mt-1">' . esc_html__( 'AND', 'ayecode-connect' ) . '</div></div>'; |
|
5210 | + $content .= '<div class="bs-vc-sep-wrap text-center position-absolute top-0 mt-n3"><div class="bs-vc-sep-cond d-inline-block badge text-dark bg-gray mt-1">' . esc_html__('AND', 'ayecode-connect') . '</div></div>'; |
|
5211 | 5211 | $content .= '</div>'; |
5212 | 5212 | $content .= '</div>'; |
5213 | 5213 | $content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">'; |
5214 | 5214 | $content .= '<div class="bs-vc-rule-sets"></div>'; |
5215 | - $content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __( 'Add Rule', 'ayecode-connect' ) . '</button></div></div>'; |
|
5215 | + $content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __('Add Rule', 'ayecode-connect') . '</button></div></div>'; |
|
5216 | 5216 | $content .= '<div class="row"><div class="col-md-6 col-sm-12">'; |
5217 | 5217 | $content .= aui()->select( |
5218 | 5218 | array( |
5219 | 5219 | 'id' => 'bsvc_output', |
5220 | 5220 | 'name' => 'bsvc_output', |
5221 | - 'label' => __( 'What should happen if rules met.', 'ayecode-connect' ), |
|
5222 | - 'placeholder' => __( 'Show Block', 'ayecode-connect' ), |
|
5221 | + 'label' => __('What should happen if rules met.', 'ayecode-connect'), |
|
5222 | + 'placeholder' => __('Show Block', 'ayecode-connect'), |
|
5223 | 5223 | 'class' => 'bsvc_output form-select-sm no-select2 mw-100', |
5224 | 5224 | 'options' => sd_visibility_output_options(), |
5225 | 5225 | 'default' => '', |
@@ -5238,8 +5238,8 @@ discard block |
||
5238 | 5238 | array( |
5239 | 5239 | 'id' => 'bsvc_page', |
5240 | 5240 | 'name' => 'bsvc_page', |
5241 | - 'label' => __( 'Page Content', 'ayecode-connect' ), |
|
5242 | - 'placeholder' => __( 'Select Page ID...', 'ayecode-connect' ), |
|
5241 | + 'label' => __('Page Content', 'ayecode-connect'), |
|
5242 | + 'placeholder' => __('Select Page ID...', 'ayecode-connect'), |
|
5243 | 5243 | 'class' => 'bsvc_page form-select-sm no-select2 mw-100', |
5244 | 5244 | 'options' => sd_template_page_options(), |
5245 | 5245 | 'default' => '', |
@@ -5254,8 +5254,8 @@ discard block |
||
5254 | 5254 | array( |
5255 | 5255 | 'id' => 'bsvc_tmpl_part', |
5256 | 5256 | 'name' => 'bsvc_tmpl_part', |
5257 | - 'label' => __( 'Template Part', 'ayecode-connect' ), |
|
5258 | - 'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ), |
|
5257 | + 'label' => __('Template Part', 'ayecode-connect'), |
|
5258 | + 'placeholder' => __('Select Template Part...', 'ayecode-connect'), |
|
5259 | 5259 | 'class' => 'bsvc_tmpl_part form-select-sm no-select2 mw-100', |
5260 | 5260 | 'options' => sd_template_part_options(), |
5261 | 5261 | 'default' => '', |
@@ -5273,8 +5273,8 @@ discard block |
||
5273 | 5273 | array( |
5274 | 5274 | 'id' => 'bsvc_message_type', |
5275 | 5275 | 'name' => 'bsvc_message_type', |
5276 | - 'label' => __( 'Custom Message Type', 'ayecode-connect' ), |
|
5277 | - 'placeholder' => __( 'Default (none)', 'ayecode-connect' ), |
|
5276 | + 'label' => __('Custom Message Type', 'ayecode-connect'), |
|
5277 | + 'placeholder' => __('Default (none)', 'ayecode-connect'), |
|
5278 | 5278 | 'class' => 'bsvc_message_type form-select-sm no-select2 mw-100', |
5279 | 5279 | 'options' => sd_aui_colors(), |
5280 | 5280 | 'default' => '', |
@@ -5297,7 +5297,7 @@ discard block |
||
5297 | 5297 | 'name' => 'bsvc_message', |
5298 | 5298 | 'label' => '', |
5299 | 5299 | 'class' => 'bsvc_message form-control-sm mb-3', |
5300 | - 'placeholder' => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ), |
|
5300 | + 'placeholder' => __('CUSTOM MESSAGE TO SHOW', 'ayecode-connect'), |
|
5301 | 5301 | 'label_type' => '', |
5302 | 5302 | 'value' => '', |
5303 | 5303 | 'form_group_class' => ' ', |
@@ -5310,8 +5310,8 @@ discard block |
||
5310 | 5310 | array( |
5311 | 5311 | 'id' => 'bsvc_output_n', |
5312 | 5312 | 'name' => 'bsvc_output_n', |
5313 | - 'label' => __( 'What should happen if rules NOT met.', 'ayecode-connect' ), |
|
5314 | - 'placeholder' => __( 'Show Block', 'ayecode-connect' ), |
|
5313 | + 'label' => __('What should happen if rules NOT met.', 'ayecode-connect'), |
|
5314 | + 'placeholder' => __('Show Block', 'ayecode-connect'), |
|
5315 | 5315 | 'class' => 'bsvc_output_n form-select-sm no-select2 mw-100', |
5316 | 5316 | 'options' => sd_visibility_output_options(), |
5317 | 5317 | 'default' => '', |
@@ -5330,8 +5330,8 @@ discard block |
||
5330 | 5330 | array( |
5331 | 5331 | 'id' => 'bsvc_page_n', |
5332 | 5332 | 'name' => 'bsvc_page_n', |
5333 | - 'label' => __( 'Page Content', 'ayecode-connect' ), |
|
5334 | - 'placeholder' => __( 'Select Page ID...', 'ayecode-connect' ), |
|
5333 | + 'label' => __('Page Content', 'ayecode-connect'), |
|
5334 | + 'placeholder' => __('Select Page ID...', 'ayecode-connect'), |
|
5335 | 5335 | 'class' => 'bsvc_page_n form-select-sm no-select2 mw-100', |
5336 | 5336 | 'options' => sd_template_page_options(), |
5337 | 5337 | 'default' => '', |
@@ -5346,8 +5346,8 @@ discard block |
||
5346 | 5346 | array( |
5347 | 5347 | 'id' => 'bsvc_tmpl_part_n', |
5348 | 5348 | 'name' => 'bsvc_tmpl_part_n', |
5349 | - 'label' => __( 'Template Part', 'ayecode-connect' ), |
|
5350 | - 'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ), |
|
5349 | + 'label' => __('Template Part', 'ayecode-connect'), |
|
5350 | + 'placeholder' => __('Select Template Part...', 'ayecode-connect'), |
|
5351 | 5351 | 'class' => 'bsvc_tmpl_part_n form-select-sm no-select2 mw-100', |
5352 | 5352 | 'options' => sd_template_part_options(), |
5353 | 5353 | 'default' => '', |
@@ -5365,8 +5365,8 @@ discard block |
||
5365 | 5365 | array( |
5366 | 5366 | 'id' => 'bsvc_message_type_n', |
5367 | 5367 | 'name' => 'bsvc_message_type_n', |
5368 | - 'label' => __( 'Custom Message Type', 'ayecode-connect' ), |
|
5369 | - 'placeholder' => __( 'Default (none)', 'ayecode-connect' ), |
|
5368 | + 'label' => __('Custom Message Type', 'ayecode-connect'), |
|
5369 | + 'placeholder' => __('Default (none)', 'ayecode-connect'), |
|
5370 | 5370 | 'class' => 'bsvc_message_type_n form-select-sm no-select2 mw-100', |
5371 | 5371 | 'options' => sd_aui_colors(), |
5372 | 5372 | 'default' => '', |
@@ -5389,7 +5389,7 @@ discard block |
||
5389 | 5389 | 'name' => 'bsvc_message_n', |
5390 | 5390 | 'label' => '', |
5391 | 5391 | 'class' => 'bsvc_message_n form-control-sm', |
5392 | - 'placeholder' => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ), |
|
5392 | + 'placeholder' => __('CUSTOM MESSAGE TO SHOW', 'ayecode-connect'), |
|
5393 | 5393 | 'label_type' => '', |
5394 | 5394 | 'value' => '', |
5395 | 5395 | 'form_group_class' => ' ', |
@@ -5411,7 +5411,7 @@ discard block |
||
5411 | 5411 | global $shortcode_insert_button_once; |
5412 | 5412 | |
5413 | 5413 | // Fix conflicts with UpSolution Core in header template edit element. |
5414 | - if ( defined( 'US_CORE_DIR' ) && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html' ) { |
|
5414 | + if (defined('US_CORE_DIR') && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html') { |
|
5415 | 5415 | $shortcode_insert_button_once = true; |
5416 | 5416 | } |
5417 | 5417 | } |