@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | * @package GetPaid |
16 | 16 | */ |
17 | 17 | |
18 | -defined( 'ABSPATH' ) || exit; |
|
18 | +defined('ABSPATH') || exit; |
|
19 | 19 | |
20 | 20 | // Define constants. |
21 | -if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
21 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
22 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
23 | 23 | } |
24 | 24 | |
25 | -if ( ! defined( 'WPINV_VERSION' ) ) { |
|
26 | - define( 'WPINV_VERSION', '2.8.29' ); |
|
25 | +if (!defined('WPINV_VERSION')) { |
|
26 | + define('WPINV_VERSION', '2.8.29'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // Include the main Invoicing class. |
30 | -if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
|
31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
30 | +if (!class_exists('WPInv_Plugin', false)) { |
|
31 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php'; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function getpaid() { |
41 | 41 | |
42 | - if ( empty( $GLOBALS['invoicing'] ) ) { |
|
42 | + if (empty($GLOBALS['invoicing'])) { |
|
43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
44 | 44 | } |
45 | 45 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @since 2.0.8 |
53 | 53 | */ |
54 | 54 | function getpaid_deactivation_hook() { |
55 | - update_option( 'wpinv_flush_permalinks', 1 ); |
|
55 | + update_option('wpinv_flush_permalinks', 1); |
|
56 | 56 | } |
57 | -register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' ); |
|
57 | +register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook'); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @deprecated |
@@ -64,4 +64,4 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | // Kickstart the plugin. |
67 | -add_action( 'plugins_loaded', 'getpaid', 0 ); |
|
67 | +add_action('plugins_loaded', 'getpaid', 0); |
@@ -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 | } |