@@ -19,16 +19,16 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // Define constants. |
| 21 | 21 | if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
| 22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 22 | + define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | if ( ! defined( 'WPINV_VERSION' ) ) { |
| 26 | - define( 'WPINV_VERSION', '2.8.7' ); |
|
| 26 | + define( 'WPINV_VERSION', '2.8.7' ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Include the main Invoicing class. |
| 30 | 30 | if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
| 31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 31 | + require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - return $GLOBALS['invoicing']; |
|
| 46 | + return $GLOBALS['invoicing']; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | - exit; |
|
| 7 | + exit; |
|
| 8 | 8 | } |
| 9 | 9 | add_ThickBox(); |
| 10 | 10 | ?> |
@@ -14,18 +14,18 @@ discard block |
||
| 14 | 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>'; |
|
| 19 | - } |
|
| 20 | - do_action( 'wpi_addons_tabs' ); |
|
| 21 | - ?> |
|
| 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 | + } |
|
| 20 | + do_action( 'wpi_addons_tabs' ); |
|
| 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 | |
| 30 | 30 | <div class="wpi-membership-tab-conatiner"> |
| 31 | 31 | <div class="membership-content"> |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 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 ) ); |
|
| 41 | - ?> |
|
| 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 | + ?> |
|
| 42 | 42 | </p> |
| 43 | 43 | <?php } ?> |
| 44 | 44 | |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | <div class="feature-list"> |
| 49 | 49 | <ul> |
| 50 | 50 | <?php |
| 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>'; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - ?> |
|
| 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>'; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + ?> |
|
| 58 | 58 | </ul> |
| 59 | 59 | |
| 60 | 60 | <div class="feature-cta"> |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 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>'; |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - ?> |
|
| 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 | + } |
|
| 72 | + } |
|
| 73 | + ?> |
|
| 74 | 74 | </ul> |
| 75 | 75 | </div> |
| 76 | 76 | |
@@ -81,8 +81,8 @@ 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__ ) ) ) . '" > '; |
|
| 85 | - ?> |
|
| 84 | + echo '<img src="' . esc_url( plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) ) . '" > '; |
|
| 85 | + ?> |
|
| 86 | 86 | </div> |
| 87 | 87 | <div class="t-content"> |
| 88 | 88 | <p> |
@@ -101,8 +101,8 @@ 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__ ) ) ) . '" > '; |
|
| 105 | - ?> |
|
| 104 | + echo '<img src="' . esc_url( plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) ) . '" > '; |
|
| 105 | + ?> |
|
| 106 | 106 | </div> |
| 107 | 107 | <div class="t-content"> |
| 108 | 108 | <p> |
@@ -126,26 +126,26 @@ discard block |
||
| 126 | 126 | </div> |
| 127 | 127 | </div> |
| 128 | 128 | <?php |
| 129 | - } else { |
|
| 130 | - $installed_plugins = get_plugins(); |
|
| 129 | + } else { |
|
| 130 | + $installed_plugins = get_plugins(); |
|
| 131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
| 132 | - if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
| 133 | - //print_r($addons); |
|
| 134 | - ?> |
|
| 132 | + if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
| 133 | + //print_r($addons); |
|
| 134 | + ?> |
|
| 135 | 135 | <ul class="wpi-products"> |
| 136 | 136 | <?php |
| 137 | 137 | foreach ( $addons as $addon ) : |
| 138 | 138 | if ( 965 == $addon->info->id ) { |
| 139 | 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 ); |
|
| 147 | - } |
|
| 148 | - echo esc_html( $addon->info->title ); |
|
| 145 | + if ( ! empty( $addon->info->excerpt ) ) { |
|
| 146 | + wpi_help_tip( $addon->info->excerpt, false, false, true ); |
|
| 147 | + } |
|
| 148 | + echo esc_html( $addon->info->title ); |
|
| 149 | 149 | ?> |
| 150 | 150 | </h3> |
| 151 | 151 | </div> |
@@ -156,40 +156,40 @@ discard block |
||
| 156 | 156 | <?php |
| 157 | 157 | endif; |
| 158 | 158 | |
| 159 | - if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
| 160 | - $addon->info->slug = 'getpaid-stripe-payments'; |
|
| 161 | - $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
|
| 162 | - } |
|
| 159 | + if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
| 160 | + $addon->info->slug = 'getpaid-stripe-payments'; |
|
| 161 | + $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
|
| 162 | + } |
|
| 163 | 163 | elseif( 'wallet' == $addon->info->slug ){ |
| 164 | - $addon->info->slug = 'getpaid-wallet'; |
|
| 165 | - $addon->info->link = 'https://wordpress.org/plugins/getpaid-wallet/'; |
|
| 166 | - } |
|
| 164 | + $addon->info->slug = 'getpaid-wallet'; |
|
| 165 | + $addon->info->link = 'https://wordpress.org/plugins/getpaid-wallet/'; |
|
| 166 | + } |
|
| 167 | 167 | elseif( 'item-inventory' == $addon->info->slug ){ |
| 168 | - $addon->info->slug = 'getpaid-item-inventory'; |
|
| 169 | - $addon->info->link = 'https://wordpress.org/plugins/getpaid-item-inventory/'; |
|
| 170 | - } |
|
| 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>'; |
|
| 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' ); |
|
| 179 | - } else { |
|
| 180 | - // if installed show activation link |
|
| 181 | - if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
| 182 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
| 183 | - } else { |
|
| 184 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
| 188 | - echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
| 189 | - echo '</a>'; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - ?> |
|
| 168 | + $addon->info->slug = 'getpaid-item-inventory'; |
|
| 169 | + $addon->info->link = 'https://wordpress.org/plugins/getpaid-item-inventory/'; |
|
| 170 | + } |
|
| 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>'; |
|
| 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' ); |
|
| 179 | + } else { |
|
| 180 | + // if installed show activation link |
|
| 181 | + if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
| 182 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
| 183 | + } else { |
|
| 184 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
| 188 | + echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
| 189 | + echo '</a>'; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + ?> |
|
| 193 | 193 | |
| 194 | 194 | </span> |
| 195 | 195 | |
@@ -197,15 +197,15 @@ discard block |
||
| 197 | 197 | <span class="wpi-product-button"> |
| 198 | 198 | <?php |
| 199 | 199 | $addon_obj->output_button( $addon ); |
| 200 | - ?> |
|
| 200 | + ?> |
|
| 201 | 201 | </span> |
| 202 | 202 | |
| 203 | 203 | <span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul> |
| 204 | 204 | <?php |
| 205 | 205 | endif; |
| 206 | - } |
|
| 206 | + } |
|
| 207 | 207 | } |
| 208 | - ?> |
|
| 208 | + ?> |
|
| 209 | 209 | |
| 210 | 210 | |
| 211 | 211 | <div class="clearfix" ></div> |
@@ -224,8 +224,8 @@ discard block |
||
| 224 | 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://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
| 228 | - ?> |
|
| 227 | + printf( esc_html__( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
| 228 | + ?> |
|
| 229 | 229 | </span> |
| 230 | 230 | </div> |
| 231 | 231 | |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * |
| 7 | 7 | */ |
| 8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | - exit; |
|
| 9 | + exit; |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /** |
@@ -15,94 +15,94 @@ discard block |
||
| 15 | 15 | class WPInv_Admin_Addons extends Ayecode_Addons { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Get the extensions page tabs. |
|
| 20 | - * |
|
| 21 | - * @return array of tabs. |
|
| 22 | - */ |
|
| 23 | - public function get_tabs() { |
|
| 24 | - $tabs = array( |
|
| 25 | - 'addons' => __( 'Addons', 'invoicing' ), |
|
| 18 | + /** |
|
| 19 | + * Get the extensions page tabs. |
|
| 20 | + * |
|
| 21 | + * @return array of tabs. |
|
| 22 | + */ |
|
| 23 | + public function get_tabs() { |
|
| 24 | + $tabs = array( |
|
| 25 | + 'addons' => __( 'Addons', 'invoicing' ), |
|
| 26 | 26 | 'gateways' => __( 'Payment Gateways', 'invoicing' ), |
| 27 | 27 | 'recommended_plugins' => __( 'Recommended plugins', 'invoicing' ), |
| 28 | 28 | 'membership' => __( 'Membership', 'invoicing' ), |
| 29 | - ); |
|
| 30 | - |
|
| 31 | - return $tabs; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Get section content for the addons screen. |
|
| 36 | - * |
|
| 37 | - * @param string $section_id |
|
| 38 | - * |
|
| 39 | - * @return array |
|
| 40 | - */ |
|
| 41 | - public function get_section_data( $section_id ) { |
|
| 42 | - $section = self::get_tab( $section_id ); |
|
| 43 | - $api_url = 'https://wpinvoicing.com/edd-api/v2/products/'; |
|
| 44 | - $section_data = new stdClass(); |
|
| 45 | - |
|
| 46 | - if ( $section_id == 'recommended_plugins' ) { |
|
| 47 | - $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
| 48 | - } elseif ( ! empty( $section ) ) { |
|
| 49 | - if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
| 50 | - //if ( 1==1) { |
|
| 51 | - |
|
| 52 | - $query_args = array( |
|
| 53 | - 'category' => $section_id, |
|
| 54 | - 'number' => 100, |
|
| 55 | - ); |
|
| 56 | - $query_args = apply_filters( 'wpeu_edd_api_query_args', $query_args, $api_url, $section_id ); |
|
| 57 | - |
|
| 58 | - $raw_section = wp_safe_remote_get( |
|
| 29 | + ); |
|
| 30 | + |
|
| 31 | + return $tabs; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Get section content for the addons screen. |
|
| 36 | + * |
|
| 37 | + * @param string $section_id |
|
| 38 | + * |
|
| 39 | + * @return array |
|
| 40 | + */ |
|
| 41 | + public function get_section_data( $section_id ) { |
|
| 42 | + $section = self::get_tab( $section_id ); |
|
| 43 | + $api_url = 'https://wpinvoicing.com/edd-api/v2/products/'; |
|
| 44 | + $section_data = new stdClass(); |
|
| 45 | + |
|
| 46 | + if ( $section_id == 'recommended_plugins' ) { |
|
| 47 | + $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
| 48 | + } elseif ( ! empty( $section ) ) { |
|
| 49 | + if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
| 50 | + //if ( 1==1) { |
|
| 51 | + |
|
| 52 | + $query_args = array( |
|
| 53 | + 'category' => $section_id, |
|
| 54 | + 'number' => 100, |
|
| 55 | + ); |
|
| 56 | + $query_args = apply_filters( 'wpeu_edd_api_query_args', $query_args, $api_url, $section_id ); |
|
| 57 | + |
|
| 58 | + $raw_section = wp_safe_remote_get( |
|
| 59 | 59 | esc_url_raw( add_query_arg( $query_args, $api_url ) ), |
| 60 | 60 | array( |
| 61 | - 'user-agent' => 'Invoicing Addons Page', |
|
| 62 | - 'timeout' => 15, |
|
| 61 | + 'user-agent' => 'Invoicing Addons Page', |
|
| 62 | + 'timeout' => 15, |
|
| 63 | 63 | ) |
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | - if ( ! is_wp_error( $raw_section ) ) { |
|
| 67 | - $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
| 66 | + if ( ! is_wp_error( $raw_section ) ) { |
|
| 67 | + $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
| 68 | 68 | |
| 69 | - if ( ! empty( $section_data->products ) ) { |
|
| 70 | - set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - } |
|
| 69 | + if ( ! empty( $section_data->products ) ) { |
|
| 70 | + set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $products = isset( $section_data->products ) ? $section_data->products : array(); |
|
| 77 | - if ( 'addons' == $section_id ) { |
|
| 78 | - |
|
| 79 | - $quotes = new stdClass(); |
|
| 80 | - $quotes->info = new stdClass(); |
|
| 81 | - $quotes->info->id = ''; |
|
| 82 | - $quotes->info->slug = 'invoicing-quotes'; |
|
| 83 | - $quotes->info->title = __( 'Quotes', 'invoicing' ); |
|
| 84 | - $quotes->info->excerpt = __( 'Create quotes and estimates', 'invoicing' ); |
|
| 85 | - $quotes->info->link = 'https://wordpress.org/plugins/invoicing-quotes/'; |
|
| 86 | - $quotes->info->thumbnail = WPINV_PLUGIN_URL . 'assets/images/Quotes-1-768x384.png'; |
|
| 87 | - |
|
| 88 | - $products[] = $quotes; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Outputs a button. |
|
| 96 | - *ccc |
|
| 97 | - * @param string $url |
|
| 98 | - * @param string $text |
|
| 99 | - * @param string $theme |
|
| 100 | - * @param string $plugin |
|
| 101 | - */ |
|
| 102 | - public function output_button( $addon ) { |
|
| 76 | + $products = isset( $section_data->products ) ? $section_data->products : array(); |
|
| 77 | + if ( 'addons' == $section_id ) { |
|
| 78 | + |
|
| 79 | + $quotes = new stdClass(); |
|
| 80 | + $quotes->info = new stdClass(); |
|
| 81 | + $quotes->info->id = ''; |
|
| 82 | + $quotes->info->slug = 'invoicing-quotes'; |
|
| 83 | + $quotes->info->title = __( 'Quotes', 'invoicing' ); |
|
| 84 | + $quotes->info->excerpt = __( 'Create quotes and estimates', 'invoicing' ); |
|
| 85 | + $quotes->info->link = 'https://wordpress.org/plugins/invoicing-quotes/'; |
|
| 86 | + $quotes->info->thumbnail = WPINV_PLUGIN_URL . 'assets/images/Quotes-1-768x384.png'; |
|
| 87 | + |
|
| 88 | + $products[] = $quotes; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Outputs a button. |
|
| 96 | + *ccc |
|
| 97 | + * @param string $url |
|
| 98 | + * @param string $text |
|
| 99 | + * @param string $theme |
|
| 100 | + * @param string $plugin |
|
| 101 | + */ |
|
| 102 | + public function output_button( $addon ) { |
|
| 103 | 103 | |
| 104 | 104 | // print_r($addon); |
| 105 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 105 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 106 | 106 | // $button_text = __('Free','invoicing'); |
| 107 | 107 | // $licensing = false; |
| 108 | 108 | // $installed = false; |
@@ -114,128 +114,128 @@ discard block |
||
| 114 | 114 | // $install_status = 'get'; |
| 115 | 115 | // $onclick = ''; |
| 116 | 116 | |
| 117 | - $wp_org_themes = array( 'supreme-directory', 'directory-starter' ); |
|
| 118 | - |
|
| 119 | - $button_args = array( |
|
| 120 | - 'type' => ($current_tab == 'addons' || $current_tab == 'gateways') ? 'addons' : $current_tab, |
|
| 121 | - 'id' => isset( $addon->info->id ) ? absint( $addon->info->id ) : '', |
|
| 122 | - 'title' => isset( $addon->info->title ) ? $addon->info->title : '', |
|
| 123 | - 'button_text' => __( 'Free', 'invoicing' ), |
|
| 124 | - 'price_text' => __( 'Free', 'invoicing' ), |
|
| 125 | - 'link' => isset( $addon->info->link ) ? $addon->info->link : '', // link to product |
|
| 126 | - 'url' => isset( $addon->info->link ) ? $addon->info->link : '', // button url |
|
| 127 | - 'class' => 'button-primary', |
|
| 128 | - 'install_status' => 'get', |
|
| 129 | - 'installed' => false, |
|
| 130 | - 'price' => '', |
|
| 131 | - 'licensing' => isset( $addon->licensing->enabled ) && $addon->licensing->enabled ? true : false, |
|
| 132 | - 'license' => isset( $addon->licensing->license ) && $addon->licensing->license ? $addon->licensing->license : '', |
|
| 133 | - 'onclick' => '', |
|
| 134 | - 'slug' => isset( $addon->info->slug ) ? $addon->info->slug : '', |
|
| 135 | - 'active' => false, |
|
| 136 | - 'file' => '', |
|
| 137 | - 'update_url' => '', |
|
| 138 | - ); |
|
| 139 | - |
|
| 140 | - if ( 'invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset( $addon->info->slug ) && $addon->info->slug ) ) { |
|
| 141 | - include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
|
| 142 | - $status = install_plugin_install_status( |
|
| 117 | + $wp_org_themes = array( 'supreme-directory', 'directory-starter' ); |
|
| 118 | + |
|
| 119 | + $button_args = array( |
|
| 120 | + 'type' => ($current_tab == 'addons' || $current_tab == 'gateways') ? 'addons' : $current_tab, |
|
| 121 | + 'id' => isset( $addon->info->id ) ? absint( $addon->info->id ) : '', |
|
| 122 | + 'title' => isset( $addon->info->title ) ? $addon->info->title : '', |
|
| 123 | + 'button_text' => __( 'Free', 'invoicing' ), |
|
| 124 | + 'price_text' => __( 'Free', 'invoicing' ), |
|
| 125 | + 'link' => isset( $addon->info->link ) ? $addon->info->link : '', // link to product |
|
| 126 | + 'url' => isset( $addon->info->link ) ? $addon->info->link : '', // button url |
|
| 127 | + 'class' => 'button-primary', |
|
| 128 | + 'install_status' => 'get', |
|
| 129 | + 'installed' => false, |
|
| 130 | + 'price' => '', |
|
| 131 | + 'licensing' => isset( $addon->licensing->enabled ) && $addon->licensing->enabled ? true : false, |
|
| 132 | + 'license' => isset( $addon->licensing->license ) && $addon->licensing->license ? $addon->licensing->license : '', |
|
| 133 | + 'onclick' => '', |
|
| 134 | + 'slug' => isset( $addon->info->slug ) ? $addon->info->slug : '', |
|
| 135 | + 'active' => false, |
|
| 136 | + 'file' => '', |
|
| 137 | + 'update_url' => '', |
|
| 138 | + ); |
|
| 139 | + |
|
| 140 | + if ( 'invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset( $addon->info->slug ) && $addon->info->slug ) ) { |
|
| 141 | + include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
|
| 142 | + $status = install_plugin_install_status( |
|
| 143 | 143 | array( |
| 144 | - 'slug' => $button_args['slug'], |
|
| 145 | - 'version' => '', |
|
| 144 | + 'slug' => $button_args['slug'], |
|
| 145 | + 'version' => '', |
|
| 146 | 146 | ) |
| 147 | 147 | ); |
| 148 | - $button_args['install_status'] = isset( $status['status'] ) ? $status['status'] : 'install'; |
|
| 149 | - $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
| 150 | - } elseif ( ($current_tab == 'addons' || $current_tab == 'gateways') && isset( $addon->info->id ) && $addon->info->id ) { |
|
| 151 | - include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
|
| 152 | - if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
| 148 | + $button_args['install_status'] = isset( $status['status'] ) ? $status['status'] : 'install'; |
|
| 149 | + $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
| 150 | + } elseif ( ($current_tab == 'addons' || $current_tab == 'gateways') && isset( $addon->info->id ) && $addon->info->id ) { |
|
| 151 | + include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
|
| 152 | + if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
| 153 | 153 | $button_args['slug'] = $addon->licensing->edd_slug;} |
| 154 | - $status = self::install_plugin_install_status( $addon ); |
|
| 155 | - $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
| 156 | - if ( isset( $status['status'] ) ) { |
|
| 154 | + $status = self::install_plugin_install_status( $addon ); |
|
| 155 | + $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
| 156 | + if ( isset( $status['status'] ) ) { |
|
| 157 | 157 | $button_args['install_status'] = $status['status'];} |
| 158 | - $button_args['update_url'] = 'https://wpinvoicing.com'; |
|
| 159 | - } elseif ( $current_tab == 'themes' && isset( $addon->info->id ) && $addon->info->id ) { |
|
| 160 | - if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
| 158 | + $button_args['update_url'] = 'https://wpinvoicing.com'; |
|
| 159 | + } elseif ( $current_tab == 'themes' && isset( $addon->info->id ) && $addon->info->id ) { |
|
| 160 | + if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
| 161 | 161 | $button_args['slug'] = $addon->licensing->edd_slug;} |
| 162 | - $button_args['installed'] = self::is_theme_installed( $addon ); |
|
| 163 | - if ( ! in_array( $button_args['slug'], $wp_org_themes ) ) { |
|
| 164 | - $button_args['update_url'] = 'https://wpinvoicing.com'; |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // set price |
|
| 169 | - if ( isset( $addon->pricing ) && ! empty( $addon->pricing ) ) { |
|
| 170 | - if ( is_object( $addon->pricing ) ) { |
|
| 171 | - $prices = (array)$addon->pricing; |
|
| 172 | - $button_args['price'] = reset( $prices ); |
|
| 173 | - } elseif ( isset( $addon->pricing ) ) { |
|
| 174 | - $button_args['price'] = $addon->pricing; |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - // set price text |
|
| 179 | - if ( $button_args['price'] && $button_args['price'] != '0.00' ) { |
|
| 180 | - $button_args['price_text'] = sprintf( __( 'From: $%d', 'invoicing' ), $button_args['price'] ); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - // set if installed |
|
| 184 | - if ( in_array( $button_args['install_status'], array( 'installed', 'latest_installed', 'update_available', 'newer_installed' ) ) ) { |
|
| 185 | - $button_args['installed'] = true; |
|
| 186 | - } |
|
| 162 | + $button_args['installed'] = self::is_theme_installed( $addon ); |
|
| 163 | + if ( ! in_array( $button_args['slug'], $wp_org_themes ) ) { |
|
| 164 | + $button_args['update_url'] = 'https://wpinvoicing.com'; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // set price |
|
| 169 | + if ( isset( $addon->pricing ) && ! empty( $addon->pricing ) ) { |
|
| 170 | + if ( is_object( $addon->pricing ) ) { |
|
| 171 | + $prices = (array)$addon->pricing; |
|
| 172 | + $button_args['price'] = reset( $prices ); |
|
| 173 | + } elseif ( isset( $addon->pricing ) ) { |
|
| 174 | + $button_args['price'] = $addon->pricing; |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + // set price text |
|
| 179 | + if ( $button_args['price'] && $button_args['price'] != '0.00' ) { |
|
| 180 | + $button_args['price_text'] = sprintf( __( 'From: $%d', 'invoicing' ), $button_args['price'] ); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + // set if installed |
|
| 184 | + if ( in_array( $button_args['install_status'], array( 'installed', 'latest_installed', 'update_available', 'newer_installed' ) ) ) { |
|
| 185 | + $button_args['installed'] = true; |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | // print_r($button_args); |
| 189 | - // set if active |
|
| 190 | - if ( $button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes') ) { |
|
| 191 | - if ( $button_args['type'] != 'themes' ) { |
|
| 192 | - $button_args['active'] = is_plugin_active( $button_args['file'] ); |
|
| 193 | - } else { |
|
| 194 | - $button_args['active'] = self::is_theme_active( $addon ); |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - // set button text and class |
|
| 199 | - if ( $button_args['active'] ) { |
|
| 200 | - $button_args['button_text'] = __( 'Active', 'invoicing' ); |
|
| 201 | - $button_args['class'] = ' button-secondary disabled '; |
|
| 202 | - } elseif ( $button_args['installed'] ) { |
|
| 203 | - $button_args['button_text'] = __( 'Activate', 'invoicing' ); |
|
| 204 | - |
|
| 205 | - if ( $button_args['type'] != 'themes' ) { |
|
| 206 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 207 | - $button_args['url'] = wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $button_args['file'] ), 'activate-plugin_' . $button_args['file'] ); |
|
| 208 | - } else { |
|
| 209 | - $button_args['url'] = '#'; |
|
| 210 | - } |
|
| 211 | - } else { |
|
| 212 | - if ( current_user_can( 'switch_themes' ) ) { |
|
| 213 | - $button_args['url'] = self::get_theme_activation_url( $addon ); |
|
| 214 | - } else { |
|
| 215 | - $button_args['url'] = '#'; |
|
| 216 | - } |
|
| 217 | - } |
|
| 189 | + // set if active |
|
| 190 | + if ( $button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes') ) { |
|
| 191 | + if ( $button_args['type'] != 'themes' ) { |
|
| 192 | + $button_args['active'] = is_plugin_active( $button_args['file'] ); |
|
| 193 | + } else { |
|
| 194 | + $button_args['active'] = self::is_theme_active( $addon ); |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + // set button text and class |
|
| 199 | + if ( $button_args['active'] ) { |
|
| 200 | + $button_args['button_text'] = __( 'Active', 'invoicing' ); |
|
| 201 | + $button_args['class'] = ' button-secondary disabled '; |
|
| 202 | + } elseif ( $button_args['installed'] ) { |
|
| 203 | + $button_args['button_text'] = __( 'Activate', 'invoicing' ); |
|
| 204 | + |
|
| 205 | + if ( $button_args['type'] != 'themes' ) { |
|
| 206 | + if ( current_user_can( 'manage_options' ) ) { |
|
| 207 | + $button_args['url'] = wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $button_args['file'] ), 'activate-plugin_' . $button_args['file'] ); |
|
| 208 | + } else { |
|
| 209 | + $button_args['url'] = '#'; |
|
| 210 | + } |
|
| 211 | + } else { |
|
| 212 | + if ( current_user_can( 'switch_themes' ) ) { |
|
| 213 | + $button_args['url'] = self::get_theme_activation_url( $addon ); |
|
| 214 | + } else { |
|
| 215 | + $button_args['url'] = '#'; |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | 218 | } else { |
| 219 | - if ( $button_args['type'] == 'recommended_plugins' ) { |
|
| 220 | - $button_args['button_text'] = __( 'Install', 'invoicing' ); |
|
| 221 | - } else { |
|
| 222 | - $button_args['button_text'] = __( 'Get it', 'invoicing' ); |
|
| 219 | + if ( $button_args['type'] == 'recommended_plugins' ) { |
|
| 220 | + $button_args['button_text'] = __( 'Install', 'invoicing' ); |
|
| 221 | + } else { |
|
| 222 | + $button_args['button_text'] = __( 'Get it', 'invoicing' ); |
|
| 223 | 223 | |
| 224 | - /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
| 224 | + /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
| 225 | 225 | $button_args['button_text'] = __('Install','invoicing'); |
| 226 | 226 | $button_args['url'] = self::get_theme_install_url($button_args['slug']); |
| 227 | 227 | $button_args['onclick'] = 'gd_set_button_installing(this);'; |
| 228 | 228 | }*/ |
| 229 | 229 | |
| 230 | - } |
|
| 231 | - } |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - // filter the button arguments |
|
| 234 | - $button_args = apply_filters( 'edd_api_button_args', $button_args ); |
|
| 233 | + // filter the button arguments |
|
| 234 | + $button_args = apply_filters( 'edd_api_button_args', $button_args ); |
|
| 235 | 235 | // print_r($button_args); |
| 236 | - // set price text |
|
| 237 | - if ( isset( $button_args['price_text'] ) ) { |
|
| 238 | - ?> |
|
| 236 | + // set price text |
|
| 237 | + if ( isset( $button_args['price_text'] ) ) { |
|
| 238 | + ?> |
|
| 239 | 239 | <a |
| 240 | 240 | target="_blank" |
| 241 | 241 | class="addons-price-text" |
@@ -243,9 +243,9 @@ discard block |
||
| 243 | 243 | <?php echo esc_html( $button_args['price_text'] ); ?> |
| 244 | 244 | </a> |
| 245 | 245 | <?php |
| 246 | - } |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - ?> |
|
| 248 | + ?> |
|
| 249 | 249 | <a |
| 250 | 250 | data-licence="<?php echo esc_attr( $button_args['license'] ); ?>" |
| 251 | 251 | data-licensing="<?php echo $button_args['licensing'] ? 1 : 0; ?>" |
@@ -269,33 +269,33 @@ discard block |
||
| 269 | 269 | </a> |
| 270 | 270 | <?php |
| 271 | 271 | |
| 272 | - } |
|
| 273 | - |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * Handles output of the addons page in admin. |
|
| 277 | - */ |
|
| 278 | - public function output() { |
|
| 279 | - $tabs = self::get_tabs(); |
|
| 280 | - $sections = self::get_sections(); |
|
| 281 | - $theme = wp_get_theme(); |
|
| 282 | - $section_keys = array_keys( $sections ); |
|
| 283 | - $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
| 284 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 285 | - include_once WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php'; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * A list of recommended wp.org plugins. |
|
| 290 | - * @return array |
|
| 291 | - */ |
|
| 292 | - public function get_recommend_wp_plugins() { |
|
| 293 | - $plugins = array( |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * Handles output of the addons page in admin. |
|
| 277 | + */ |
|
| 278 | + public function output() { |
|
| 279 | + $tabs = self::get_tabs(); |
|
| 280 | + $sections = self::get_sections(); |
|
| 281 | + $theme = wp_get_theme(); |
|
| 282 | + $section_keys = array_keys( $sections ); |
|
| 283 | + $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
| 284 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 285 | + include_once WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php'; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * A list of recommended wp.org plugins. |
|
| 290 | + * @return array |
|
| 291 | + */ |
|
| 292 | + public function get_recommend_wp_plugins() { |
|
| 293 | + $plugins = array( |
|
| 294 | 294 | 'invoicing-quotes' => array( |
| 295 | 295 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
| 296 | 296 | 'slug' => 'invoicing-quotes', |
| 297 | - 'name' => 'Quotes', |
|
| 298 | - 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png', |
|
| 297 | + 'name' => 'Quotes', |
|
| 298 | + 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png', |
|
| 299 | 299 | 'desc' => __( 'Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing' ), |
| 300 | 300 | ), |
| 301 | 301 | 'geodirectory' => array( |
@@ -310,8 +310,8 @@ discard block |
||
| 310 | 310 | 'name' => 'UsersWP', |
| 311 | 311 | 'desc' => __( 'Allow frontend user login and registration as well as have slick profile pages.', 'invoicing' ), |
| 312 | 312 | ), |
| 313 | - ); |
|
| 313 | + ); |
|
| 314 | 314 | |
| 315 | - return $plugins; |
|
| 316 | - } |
|
| 315 | + return $plugins; |
|
| 316 | + } |
|
| 317 | 317 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | - exit; // Exit if accessed directly |
|
| 4 | + exit; // Exit if accessed directly |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -11,299 +11,299 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | class AUI { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Holds the class instance. |
|
| 16 | - * |
|
| 17 | - * @since 1.0.0 |
|
| 18 | - * @var null |
|
| 19 | - */ |
|
| 20 | - private static $instance = null; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Holds the current AUI version number. |
|
| 24 | - * |
|
| 25 | - * @var string $ver The current version number. |
|
| 26 | - */ |
|
| 27 | - public static $ver = '0.1.72'; |
|
| 28 | - |
|
| 29 | - public static $options = null; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * There can be only one. |
|
| 33 | - * |
|
| 34 | - * @since 1.0.0 |
|
| 35 | - * @return AUI|null |
|
| 36 | - */ |
|
| 37 | - public static function instance() { |
|
| 38 | - if ( self::$instance == null ) { |
|
| 39 | - self::$instance = new AUI(); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - return self::$instance; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * AUI constructor. |
|
| 47 | - * |
|
| 48 | - * @since 1.0.0 |
|
| 49 | - */ |
|
| 50 | - private function __construct() { |
|
| 51 | - if ( function_exists( "__autoload" ) ) { |
|
| 52 | - spl_autoload_register( "__autoload" ); |
|
| 53 | - } |
|
| 54 | - spl_autoload_register( array( $this, 'autoload' ) ); |
|
| 55 | - |
|
| 56 | - // load options |
|
| 57 | - self::$options = get_option('aui_options'); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Autoload any components on the fly. |
|
| 62 | - * |
|
| 63 | - * @since 1.0.0 |
|
| 64 | - * |
|
| 65 | - * @param $classname |
|
| 66 | - */ |
|
| 67 | - private function autoload( $classname ) { |
|
| 68 | - $class = str_replace( '_', '-', strtolower( $classname ) ); |
|
| 69 | - $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php'; |
|
| 70 | - if ( $file_path && is_readable( $file_path ) ) { |
|
| 71 | - include_once( $file_path ); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Get the AUI options. |
|
| 77 | - * |
|
| 78 | - * @param $option |
|
| 79 | - * |
|
| 80 | - * @return string|void |
|
| 81 | - */ |
|
| 82 | - public function get_option( $option ){ |
|
| 83 | - $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : ''; |
|
| 84 | - |
|
| 85 | - if ( ! $result && $option) { |
|
| 86 | - if( $option == 'color_primary' ){ |
|
| 87 | - $result = AUI_PRIMARY_COLOR; |
|
| 88 | - }elseif( $option == 'color_secondary' ){ |
|
| 89 | - $result = AUI_SECONDARY_COLOR; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - return $result; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function render( $items = array(), $echo = false ) { |
|
| 96 | - $output = ''; |
|
| 97 | - |
|
| 98 | - if ( ! empty( $items ) ) { |
|
| 99 | - foreach ( $items as $args ) { |
|
| 100 | - $render = isset( $args['render'] ) ? $args['render'] : ''; |
|
| 101 | - if ( $render && method_exists( __CLASS__, $render ) ) { |
|
| 102 | - $output .= $this->$render( $args ); |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if ( $echo ) { |
|
| 108 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 109 | - }else{ |
|
| 110 | - return $output; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Render and return a bootstrap alert component. |
|
| 117 | - * |
|
| 118 | - * @since 1.0.0 |
|
| 119 | - * |
|
| 120 | - * @param array $args The function arguments. |
|
| 121 | - * @param bool $echo If we should return or echo. |
|
| 122 | - * |
|
| 123 | - * @return string The rendered component. |
|
| 124 | - */ |
|
| 125 | - public function alert( $args = array(), $echo = false ) { |
|
| 126 | - $output = AUI_Component_Alert::get( $args ); |
|
| 127 | - |
|
| 128 | - if ( $echo ) { |
|
| 129 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 130 | - }else{ |
|
| 131 | - return $output; |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Render and return a bootstrap input component. |
|
| 137 | - * |
|
| 138 | - * @since 1.0.0 |
|
| 139 | - * |
|
| 140 | - * @param array $args The function arguments. |
|
| 141 | - * @param bool $echo If we should return or echo. |
|
| 142 | - * |
|
| 143 | - * @return string The rendered component. |
|
| 144 | - */ |
|
| 145 | - public function input( $args = array(), $echo = false ) { |
|
| 146 | - $output = AUI_Component_Input::input( $args ); |
|
| 147 | - |
|
| 148 | - if ( $echo ) { |
|
| 149 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 150 | - }else{ |
|
| 151 | - return $output; |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Render and return a bootstrap textarea component. |
|
| 157 | - * |
|
| 158 | - * @since 1.0.0 |
|
| 159 | - * |
|
| 160 | - * @param array $args The function arguments. |
|
| 161 | - * @param bool $echo If we should return or echo. |
|
| 162 | - * |
|
| 163 | - * @return string The rendered component. |
|
| 164 | - */ |
|
| 165 | - public function textarea( $args = array(), $echo = false ) { |
|
| 166 | - $output = AUI_Component_Input::textarea( $args ); |
|
| 167 | - |
|
| 168 | - if ( $echo ) { |
|
| 169 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 170 | - }else{ |
|
| 171 | - return $output; |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Render and return a bootstrap button component. |
|
| 177 | - * |
|
| 178 | - * @since 1.0.0 |
|
| 179 | - * |
|
| 180 | - * @param array $args The function arguments. |
|
| 181 | - * @param bool $echo If we should return or echo. |
|
| 182 | - * |
|
| 183 | - * @return string The rendered component. |
|
| 184 | - */ |
|
| 185 | - public function button( $args = array(), $echo = false ) { |
|
| 186 | - $output = AUI_Component_Button::get( $args ); |
|
| 187 | - |
|
| 188 | - if ( $echo ) { |
|
| 189 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 190 | - }else{ |
|
| 191 | - return $output; |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Render and return a bootstrap button component. |
|
| 197 | - * |
|
| 198 | - * @since 1.0.0 |
|
| 199 | - * |
|
| 200 | - * @param array $args The function arguments. |
|
| 201 | - * @param bool $echo If we should return or echo. |
|
| 202 | - * |
|
| 203 | - * @return string The rendered component. |
|
| 204 | - */ |
|
| 205 | - public function badge( $args = array(), $echo = false ) { |
|
| 206 | - $defaults = array( |
|
| 207 | - 'class' => 'badge badge-primary align-middle', |
|
| 208 | - ); |
|
| 209 | - |
|
| 210 | - // maybe set type. |
|
| 211 | - if ( empty( $args['href'] ) ) { |
|
| 212 | - $defaults['type'] = 'badge'; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 217 | - */ |
|
| 218 | - $args = wp_parse_args( $args, $defaults ); |
|
| 219 | - |
|
| 220 | - $output = AUI_Component_Button::get( $args ); |
|
| 221 | - |
|
| 222 | - if ( $echo ) { |
|
| 223 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 224 | - }else{ |
|
| 225 | - return $output; |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * Render and return a bootstrap dropdown component. |
|
| 231 | - * |
|
| 232 | - * @since 1.0.0 |
|
| 233 | - * |
|
| 234 | - * @param array $args The function arguments. |
|
| 235 | - * @param bool $echo If we should return or echo. |
|
| 236 | - * |
|
| 237 | - * @return string The rendered component. |
|
| 238 | - */ |
|
| 239 | - public function dropdown( $args = array(), $echo = false ) { |
|
| 240 | - $output = AUI_Component_Dropdown::get( $args ); |
|
| 241 | - |
|
| 242 | - if ( $echo ) { |
|
| 243 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 244 | - }else{ |
|
| 245 | - return $output; |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * Render and return a bootstrap select component. |
|
| 251 | - * |
|
| 252 | - * @since 1.0.0 |
|
| 253 | - * |
|
| 254 | - * @param array $args The function arguments. |
|
| 255 | - * @param bool $echo If we should return or echo. |
|
| 256 | - * |
|
| 257 | - * @return string The rendered component. |
|
| 258 | - */ |
|
| 259 | - public function select( $args = array(), $echo = false ) { |
|
| 260 | - $output = AUI_Component_Input::select( $args ); |
|
| 261 | - |
|
| 262 | - if ( $echo ) { |
|
| 263 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 264 | - }else{ |
|
| 265 | - return $output; |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * Render and return a bootstrap radio component. |
|
| 271 | - * |
|
| 272 | - * @since 1.0.0 |
|
| 273 | - * |
|
| 274 | - * @param array $args The function arguments. |
|
| 275 | - * @param bool $echo If we should return or echo. |
|
| 276 | - * |
|
| 277 | - * @return string The rendered component. |
|
| 278 | - */ |
|
| 279 | - public function radio( $args = array(), $echo = false ) { |
|
| 280 | - $output = AUI_Component_Input::radio( $args ); |
|
| 281 | - |
|
| 282 | - if ( $echo ) { |
|
| 283 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 284 | - }else{ |
|
| 285 | - return $output; |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * Render and return a bootstrap pagination component. |
|
| 291 | - * |
|
| 292 | - * @since 1.0.0 |
|
| 293 | - * |
|
| 294 | - * @param array $args The function arguments. |
|
| 295 | - * @param bool $echo If we should return or echo. |
|
| 296 | - * |
|
| 297 | - * @return string The rendered component. |
|
| 298 | - */ |
|
| 299 | - public function pagination( $args = array(), $echo = false ) { |
|
| 300 | - $output = AUI_Component_Pagination::get( $args ); |
|
| 301 | - |
|
| 302 | - if ( $echo ) { |
|
| 303 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 304 | - }else{ |
|
| 305 | - return $output; |
|
| 306 | - } |
|
| 307 | - } |
|
| 14 | + /** |
|
| 15 | + * Holds the class instance. |
|
| 16 | + * |
|
| 17 | + * @since 1.0.0 |
|
| 18 | + * @var null |
|
| 19 | + */ |
|
| 20 | + private static $instance = null; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Holds the current AUI version number. |
|
| 24 | + * |
|
| 25 | + * @var string $ver The current version number. |
|
| 26 | + */ |
|
| 27 | + public static $ver = '0.1.72'; |
|
| 28 | + |
|
| 29 | + public static $options = null; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * There can be only one. |
|
| 33 | + * |
|
| 34 | + * @since 1.0.0 |
|
| 35 | + * @return AUI|null |
|
| 36 | + */ |
|
| 37 | + public static function instance() { |
|
| 38 | + if ( self::$instance == null ) { |
|
| 39 | + self::$instance = new AUI(); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + return self::$instance; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * AUI constructor. |
|
| 47 | + * |
|
| 48 | + * @since 1.0.0 |
|
| 49 | + */ |
|
| 50 | + private function __construct() { |
|
| 51 | + if ( function_exists( "__autoload" ) ) { |
|
| 52 | + spl_autoload_register( "__autoload" ); |
|
| 53 | + } |
|
| 54 | + spl_autoload_register( array( $this, 'autoload' ) ); |
|
| 55 | + |
|
| 56 | + // load options |
|
| 57 | + self::$options = get_option('aui_options'); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Autoload any components on the fly. |
|
| 62 | + * |
|
| 63 | + * @since 1.0.0 |
|
| 64 | + * |
|
| 65 | + * @param $classname |
|
| 66 | + */ |
|
| 67 | + private function autoload( $classname ) { |
|
| 68 | + $class = str_replace( '_', '-', strtolower( $classname ) ); |
|
| 69 | + $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php'; |
|
| 70 | + if ( $file_path && is_readable( $file_path ) ) { |
|
| 71 | + include_once( $file_path ); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Get the AUI options. |
|
| 77 | + * |
|
| 78 | + * @param $option |
|
| 79 | + * |
|
| 80 | + * @return string|void |
|
| 81 | + */ |
|
| 82 | + public function get_option( $option ){ |
|
| 83 | + $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : ''; |
|
| 84 | + |
|
| 85 | + if ( ! $result && $option) { |
|
| 86 | + if( $option == 'color_primary' ){ |
|
| 87 | + $result = AUI_PRIMARY_COLOR; |
|
| 88 | + }elseif( $option == 'color_secondary' ){ |
|
| 89 | + $result = AUI_SECONDARY_COLOR; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + return $result; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function render( $items = array(), $echo = false ) { |
|
| 96 | + $output = ''; |
|
| 97 | + |
|
| 98 | + if ( ! empty( $items ) ) { |
|
| 99 | + foreach ( $items as $args ) { |
|
| 100 | + $render = isset( $args['render'] ) ? $args['render'] : ''; |
|
| 101 | + if ( $render && method_exists( __CLASS__, $render ) ) { |
|
| 102 | + $output .= $this->$render( $args ); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + if ( $echo ) { |
|
| 108 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 109 | + }else{ |
|
| 110 | + return $output; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Render and return a bootstrap alert component. |
|
| 117 | + * |
|
| 118 | + * @since 1.0.0 |
|
| 119 | + * |
|
| 120 | + * @param array $args The function arguments. |
|
| 121 | + * @param bool $echo If we should return or echo. |
|
| 122 | + * |
|
| 123 | + * @return string The rendered component. |
|
| 124 | + */ |
|
| 125 | + public function alert( $args = array(), $echo = false ) { |
|
| 126 | + $output = AUI_Component_Alert::get( $args ); |
|
| 127 | + |
|
| 128 | + if ( $echo ) { |
|
| 129 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 130 | + }else{ |
|
| 131 | + return $output; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Render and return a bootstrap input component. |
|
| 137 | + * |
|
| 138 | + * @since 1.0.0 |
|
| 139 | + * |
|
| 140 | + * @param array $args The function arguments. |
|
| 141 | + * @param bool $echo If we should return or echo. |
|
| 142 | + * |
|
| 143 | + * @return string The rendered component. |
|
| 144 | + */ |
|
| 145 | + public function input( $args = array(), $echo = false ) { |
|
| 146 | + $output = AUI_Component_Input::input( $args ); |
|
| 147 | + |
|
| 148 | + if ( $echo ) { |
|
| 149 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 150 | + }else{ |
|
| 151 | + return $output; |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Render and return a bootstrap textarea component. |
|
| 157 | + * |
|
| 158 | + * @since 1.0.0 |
|
| 159 | + * |
|
| 160 | + * @param array $args The function arguments. |
|
| 161 | + * @param bool $echo If we should return or echo. |
|
| 162 | + * |
|
| 163 | + * @return string The rendered component. |
|
| 164 | + */ |
|
| 165 | + public function textarea( $args = array(), $echo = false ) { |
|
| 166 | + $output = AUI_Component_Input::textarea( $args ); |
|
| 167 | + |
|
| 168 | + if ( $echo ) { |
|
| 169 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 170 | + }else{ |
|
| 171 | + return $output; |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Render and return a bootstrap button component. |
|
| 177 | + * |
|
| 178 | + * @since 1.0.0 |
|
| 179 | + * |
|
| 180 | + * @param array $args The function arguments. |
|
| 181 | + * @param bool $echo If we should return or echo. |
|
| 182 | + * |
|
| 183 | + * @return string The rendered component. |
|
| 184 | + */ |
|
| 185 | + public function button( $args = array(), $echo = false ) { |
|
| 186 | + $output = AUI_Component_Button::get( $args ); |
|
| 187 | + |
|
| 188 | + if ( $echo ) { |
|
| 189 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 190 | + }else{ |
|
| 191 | + return $output; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Render and return a bootstrap button component. |
|
| 197 | + * |
|
| 198 | + * @since 1.0.0 |
|
| 199 | + * |
|
| 200 | + * @param array $args The function arguments. |
|
| 201 | + * @param bool $echo If we should return or echo. |
|
| 202 | + * |
|
| 203 | + * @return string The rendered component. |
|
| 204 | + */ |
|
| 205 | + public function badge( $args = array(), $echo = false ) { |
|
| 206 | + $defaults = array( |
|
| 207 | + 'class' => 'badge badge-primary align-middle', |
|
| 208 | + ); |
|
| 209 | + |
|
| 210 | + // maybe set type. |
|
| 211 | + if ( empty( $args['href'] ) ) { |
|
| 212 | + $defaults['type'] = 'badge'; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 217 | + */ |
|
| 218 | + $args = wp_parse_args( $args, $defaults ); |
|
| 219 | + |
|
| 220 | + $output = AUI_Component_Button::get( $args ); |
|
| 221 | + |
|
| 222 | + if ( $echo ) { |
|
| 223 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 224 | + }else{ |
|
| 225 | + return $output; |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * Render and return a bootstrap dropdown component. |
|
| 231 | + * |
|
| 232 | + * @since 1.0.0 |
|
| 233 | + * |
|
| 234 | + * @param array $args The function arguments. |
|
| 235 | + * @param bool $echo If we should return or echo. |
|
| 236 | + * |
|
| 237 | + * @return string The rendered component. |
|
| 238 | + */ |
|
| 239 | + public function dropdown( $args = array(), $echo = false ) { |
|
| 240 | + $output = AUI_Component_Dropdown::get( $args ); |
|
| 241 | + |
|
| 242 | + if ( $echo ) { |
|
| 243 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 244 | + }else{ |
|
| 245 | + return $output; |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * Render and return a bootstrap select component. |
|
| 251 | + * |
|
| 252 | + * @since 1.0.0 |
|
| 253 | + * |
|
| 254 | + * @param array $args The function arguments. |
|
| 255 | + * @param bool $echo If we should return or echo. |
|
| 256 | + * |
|
| 257 | + * @return string The rendered component. |
|
| 258 | + */ |
|
| 259 | + public function select( $args = array(), $echo = false ) { |
|
| 260 | + $output = AUI_Component_Input::select( $args ); |
|
| 261 | + |
|
| 262 | + if ( $echo ) { |
|
| 263 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 264 | + }else{ |
|
| 265 | + return $output; |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * Render and return a bootstrap radio component. |
|
| 271 | + * |
|
| 272 | + * @since 1.0.0 |
|
| 273 | + * |
|
| 274 | + * @param array $args The function arguments. |
|
| 275 | + * @param bool $echo If we should return or echo. |
|
| 276 | + * |
|
| 277 | + * @return string The rendered component. |
|
| 278 | + */ |
|
| 279 | + public function radio( $args = array(), $echo = false ) { |
|
| 280 | + $output = AUI_Component_Input::radio( $args ); |
|
| 281 | + |
|
| 282 | + if ( $echo ) { |
|
| 283 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 284 | + }else{ |
|
| 285 | + return $output; |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * Render and return a bootstrap pagination component. |
|
| 291 | + * |
|
| 292 | + * @since 1.0.0 |
|
| 293 | + * |
|
| 294 | + * @param array $args The function arguments. |
|
| 295 | + * @param bool $echo If we should return or echo. |
|
| 296 | + * |
|
| 297 | + * @return string The rendered component. |
|
| 298 | + */ |
|
| 299 | + public function pagination( $args = array(), $echo = false ) { |
|
| 300 | + $output = AUI_Component_Pagination::get( $args ); |
|
| 301 | + |
|
| 302 | + if ( $echo ) { |
|
| 303 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 304 | + }else{ |
|
| 305 | + return $output; |
|
| 306 | + } |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | 309 | } |
| 310 | 310 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * Bail if we are not in WP. |
| 14 | 14 | */ |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | - exit; |
|
| 16 | + exit; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -21,480 +21,480 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * A Class to be able to change settings for Font Awesome. |
|
| 26 | - * |
|
| 27 | - * Class AyeCode_UI_Settings |
|
| 28 | - * @ver 1.0.0 |
|
| 29 | - * @todo decide how to implement textdomain |
|
| 30 | - */ |
|
| 31 | - class AyeCode_UI_Settings { |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Class version version. |
|
| 35 | - * |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - public $version = '0.2.9'; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Class textdomain. |
|
| 42 | - * |
|
| 43 | - * @var string |
|
| 44 | - */ |
|
| 45 | - public $textdomain = 'aui'; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Latest version of Bootstrap at time of publish published. |
|
| 49 | - * |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - public $latest = "5.2.2"; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Current version of select2 being used. |
|
| 56 | - * |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 59 | - public $select2_version = "4.0.11"; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * The title. |
|
| 63 | - * |
|
| 64 | - * @var string |
|
| 65 | - */ |
|
| 66 | - public $name = 'AyeCode UI'; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * The relative url to the assets. |
|
| 70 | - * |
|
| 71 | - * @var string |
|
| 72 | - */ |
|
| 73 | - public $url = ''; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Holds the settings values. |
|
| 77 | - * |
|
| 78 | - * @var array |
|
| 79 | - */ |
|
| 80 | - private $settings; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * AyeCode_UI_Settings instance. |
|
| 84 | - * |
|
| 85 | - * @access private |
|
| 86 | - * @since 1.0.0 |
|
| 87 | - * @var AyeCode_UI_Settings There can be only one! |
|
| 88 | - */ |
|
| 89 | - private static $instance = null; |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Main AyeCode_UI_Settings Instance. |
|
| 94 | - * |
|
| 95 | - * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
| 96 | - * |
|
| 97 | - * @since 1.0.0 |
|
| 98 | - * @static |
|
| 99 | - * @return AyeCode_UI_Settings - Main instance. |
|
| 100 | - */ |
|
| 101 | - public static function instance() { |
|
| 102 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 103 | - |
|
| 104 | - self::$instance = new AyeCode_UI_Settings; |
|
| 105 | - |
|
| 106 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 107 | - |
|
| 108 | - if ( is_admin() ) { |
|
| 109 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 110 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 111 | - |
|
| 112 | - // Maybe show example page |
|
| 113 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 114 | - |
|
| 115 | - if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 116 | - add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 ); |
|
| 117 | - } |
|
| 118 | - } |
|
| 24 | + /** |
|
| 25 | + * A Class to be able to change settings for Font Awesome. |
|
| 26 | + * |
|
| 27 | + * Class AyeCode_UI_Settings |
|
| 28 | + * @ver 1.0.0 |
|
| 29 | + * @todo decide how to implement textdomain |
|
| 30 | + */ |
|
| 31 | + class AyeCode_UI_Settings { |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Class version version. |
|
| 35 | + * |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + public $version = '0.2.9'; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Class textdomain. |
|
| 42 | + * |
|
| 43 | + * @var string |
|
| 44 | + */ |
|
| 45 | + public $textdomain = 'aui'; |
|
| 119 | 46 | |
| 120 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 47 | + /** |
|
| 48 | + * Latest version of Bootstrap at time of publish published. |
|
| 49 | + * |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + public $latest = "5.2.2"; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Current version of select2 being used. |
|
| 56 | + * |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | + public $select2_version = "4.0.11"; |
|
| 121 | 60 | |
| 122 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
| 123 | - } |
|
| 61 | + /** |
|
| 62 | + * The title. |
|
| 63 | + * |
|
| 64 | + * @var string |
|
| 65 | + */ |
|
| 66 | + public $name = 'AyeCode UI'; |
|
| 124 | 67 | |
| 125 | - return self::$instance; |
|
| 126 | - } |
|
| 68 | + /** |
|
| 69 | + * The relative url to the assets. |
|
| 70 | + * |
|
| 71 | + * @var string |
|
| 72 | + */ |
|
| 73 | + public $url = ''; |
|
| 127 | 74 | |
| 128 | - /** |
|
| 129 | - * Add custom colors to the color selector. |
|
| 130 | - * |
|
| 131 | - * @param $theme_colors |
|
| 132 | - * @param $include_outlines |
|
| 133 | - * @param $include_branding |
|
| 134 | - * |
|
| 135 | - * @return mixed |
|
| 136 | - */ |
|
| 137 | - public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){ |
|
| 75 | + /** |
|
| 76 | + * Holds the settings values. |
|
| 77 | + * |
|
| 78 | + * @var array |
|
| 79 | + */ |
|
| 80 | + private $settings; |
|
| 138 | 81 | |
| 82 | + /** |
|
| 83 | + * AyeCode_UI_Settings instance. |
|
| 84 | + * |
|
| 85 | + * @access private |
|
| 86 | + * @since 1.0.0 |
|
| 87 | + * @var AyeCode_UI_Settings There can be only one! |
|
| 88 | + */ |
|
| 89 | + private static $instance = null; |
|
| 139 | 90 | |
| 140 | - $setting = wp_get_global_settings(); |
|
| 141 | 91 | |
| 142 | - if(!empty($setting['color']['palette']['custom'])){ |
|
| 143 | - foreach($setting['color']['palette']['custom'] as $color){ |
|
| 144 | - $theme_colors[$color['slug']] = esc_attr($color['name']); |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - return $theme_colors; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Setup some constants. |
|
| 153 | - */ |
|
| 154 | - public function constants(){ |
|
| 155 | - define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" ); |
|
| 156 | - define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' ); |
|
| 157 | - define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' ); |
|
| 158 | - define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' ); |
|
| 159 | - define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' ); |
|
| 160 | - define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' ); |
|
| 161 | - define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' ); |
|
| 162 | - define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' ); |
|
| 163 | - define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' ); |
|
| 164 | - define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' ); |
|
| 165 | - define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' ); |
|
| 166 | - define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' ); |
|
| 167 | - define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' ); |
|
| 168 | - define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' ); |
|
| 169 | - define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' ); |
|
| 170 | - define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' ); |
|
| 171 | - |
|
| 172 | - if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 173 | - define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL ); |
|
| 174 | - } |
|
| 175 | - if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) { |
|
| 176 | - define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL ); |
|
| 177 | - } |
|
| 178 | - if ( ! defined( 'AUI_INFO_COLOR' ) ) { |
|
| 179 | - define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL ); |
|
| 180 | - } |
|
| 181 | - if ( ! defined( 'AUI_WARNING_COLOR' ) ) { |
|
| 182 | - define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL ); |
|
| 183 | - } |
|
| 184 | - if ( ! defined( 'AUI_DANGER_COLOR' ) ) { |
|
| 185 | - define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL ); |
|
| 186 | - } |
|
| 187 | - if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) { |
|
| 188 | - define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL ); |
|
| 189 | - } |
|
| 190 | - if ( ! defined( 'AUI_LIGHT_COLOR' ) ) { |
|
| 191 | - define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL ); |
|
| 192 | - } |
|
| 193 | - if ( ! defined( 'AUI_DARK_COLOR' ) ) { |
|
| 194 | - define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL ); |
|
| 195 | - } |
|
| 196 | - if ( ! defined( 'AUI_WHITE_COLOR' ) ) { |
|
| 197 | - define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL ); |
|
| 198 | - } |
|
| 199 | - if ( ! defined( 'AUI_PURPLE_COLOR' ) ) { |
|
| 200 | - define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL ); |
|
| 201 | - } |
|
| 202 | - if ( ! defined( 'AUI_SALMON_COLOR' ) ) { |
|
| 203 | - define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL ); |
|
| 204 | - } |
|
| 205 | - if ( ! defined( 'AUI_CYAN_COLOR' ) ) { |
|
| 206 | - define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL ); |
|
| 207 | - } |
|
| 208 | - if ( ! defined( 'AUI_GRAY_COLOR' ) ) { |
|
| 209 | - define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL ); |
|
| 210 | - } |
|
| 211 | - if ( ! defined( 'AUI_INDIGO_COLOR' ) ) { |
|
| 212 | - define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL ); |
|
| 213 | - } |
|
| 214 | - if ( ! defined( 'AUI_ORANGE_COLOR' ) ) { |
|
| 215 | - define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL ); |
|
| 216 | - } |
|
| 217 | - if ( ! defined( 'AUI_BLACK_COLOR' ) ) { |
|
| 218 | - define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL ); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - public static function get_colors( $original = false){ |
|
| 224 | - |
|
| 225 | - if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 226 | - return array(); |
|
| 227 | - } |
|
| 228 | - if ( $original ) { |
|
| 229 | - return array( |
|
| 230 | - 'primary' => AUI_PRIMARY_COLOR_ORIGINAL, |
|
| 231 | - 'secondary' => AUI_SECONDARY_COLOR_ORIGINAL, |
|
| 232 | - 'info' => AUI_INFO_COLOR_ORIGINAL, |
|
| 233 | - 'warning' => AUI_WARNING_COLOR_ORIGINAL, |
|
| 234 | - 'danger' => AUI_DANGER_COLOR_ORIGINAL, |
|
| 235 | - 'success' => AUI_SUCCESS_COLOR_ORIGINAL, |
|
| 236 | - 'light' => AUI_LIGHT_COLOR_ORIGINAL, |
|
| 237 | - 'dark' => AUI_DARK_COLOR_ORIGINAL, |
|
| 238 | - 'white' => AUI_WHITE_COLOR_ORIGINAL, |
|
| 239 | - 'purple' => AUI_PURPLE_COLOR_ORIGINAL, |
|
| 240 | - 'salmon' => AUI_SALMON_COLOR_ORIGINAL, |
|
| 241 | - 'cyan' => AUI_CYAN_COLOR_ORIGINAL, |
|
| 242 | - 'gray' => AUI_GRAY_COLOR_ORIGINAL, |
|
| 243 | - 'indigo' => AUI_INDIGO_COLOR_ORIGINAL, |
|
| 244 | - 'orange' => AUI_ORANGE_COLOR_ORIGINAL, |
|
| 245 | - 'black' => AUI_BLACK_COLOR_ORIGINAL, |
|
| 246 | - ); |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - return array( |
|
| 250 | - 'primary' => AUI_PRIMARY_COLOR, |
|
| 251 | - 'secondary' => AUI_SECONDARY_COLOR, |
|
| 252 | - 'info' => AUI_INFO_COLOR, |
|
| 253 | - 'warning' => AUI_WARNING_COLOR, |
|
| 254 | - 'danger' => AUI_DANGER_COLOR, |
|
| 255 | - 'success' => AUI_SUCCESS_COLOR, |
|
| 256 | - 'light' => AUI_LIGHT_COLOR, |
|
| 257 | - 'dark' => AUI_DARK_COLOR, |
|
| 258 | - 'white' => AUI_WHITE_COLOR, |
|
| 259 | - 'purple' => AUI_PURPLE_COLOR, |
|
| 260 | - 'salmon' => AUI_SALMON_COLOR, |
|
| 261 | - 'cyan' => AUI_CYAN_COLOR, |
|
| 262 | - 'gray' => AUI_GRAY_COLOR, |
|
| 263 | - 'indigo' => AUI_INDIGO_COLOR, |
|
| 264 | - 'orange' => AUI_ORANGE_COLOR, |
|
| 265 | - 'black' => AUI_BLACK_COLOR, |
|
| 266 | - ); |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * Add admin body class to show when BS5 is active. |
|
| 271 | - * |
|
| 272 | - * @param $classes |
|
| 273 | - * |
|
| 274 | - * @return mixed |
|
| 275 | - */ |
|
| 276 | - public function add_bs5_admin_body_class( $classes = '' ) { |
|
| 277 | - $classes .= ' aui_bs5'; |
|
| 278 | - |
|
| 279 | - return $classes; |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * Add a body class to show when BS5 is active. |
|
| 284 | - * |
|
| 285 | - * @param $classes |
|
| 286 | - * |
|
| 287 | - * @return mixed |
|
| 288 | - */ |
|
| 289 | - public function add_bs5_body_class( $classes ) { |
|
| 290 | - $classes[] = 'aui_bs5'; |
|
| 291 | - |
|
| 292 | - return $classes; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * Initiate the settings and add the required action hooks. |
|
| 297 | - */ |
|
| 298 | - public function init() { |
|
| 92 | + /** |
|
| 93 | + * Main AyeCode_UI_Settings Instance. |
|
| 94 | + * |
|
| 95 | + * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
| 96 | + * |
|
| 97 | + * @since 1.0.0 |
|
| 98 | + * @static |
|
| 99 | + * @return AyeCode_UI_Settings - Main instance. |
|
| 100 | + */ |
|
| 101 | + public static function instance() { |
|
| 102 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 103 | + |
|
| 104 | + self::$instance = new AyeCode_UI_Settings; |
|
| 105 | + |
|
| 106 | + add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 107 | + |
|
| 108 | + if ( is_admin() ) { |
|
| 109 | + add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 110 | + add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 111 | + |
|
| 112 | + // Maybe show example page |
|
| 113 | + add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 114 | + |
|
| 115 | + if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 116 | + add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 ); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 121 | + |
|
| 122 | + do_action( 'ayecode_ui_settings_loaded' ); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + return self::$instance; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * Add custom colors to the color selector. |
|
| 130 | + * |
|
| 131 | + * @param $theme_colors |
|
| 132 | + * @param $include_outlines |
|
| 133 | + * @param $include_branding |
|
| 134 | + * |
|
| 135 | + * @return mixed |
|
| 136 | + */ |
|
| 137 | + public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){ |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + $setting = wp_get_global_settings(); |
|
| 141 | + |
|
| 142 | + if(!empty($setting['color']['palette']['custom'])){ |
|
| 143 | + foreach($setting['color']['palette']['custom'] as $color){ |
|
| 144 | + $theme_colors[$color['slug']] = esc_attr($color['name']); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + return $theme_colors; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Setup some constants. |
|
| 153 | + */ |
|
| 154 | + public function constants(){ |
|
| 155 | + define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" ); |
|
| 156 | + define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' ); |
|
| 157 | + define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' ); |
|
| 158 | + define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' ); |
|
| 159 | + define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' ); |
|
| 160 | + define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' ); |
|
| 161 | + define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' ); |
|
| 162 | + define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' ); |
|
| 163 | + define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' ); |
|
| 164 | + define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' ); |
|
| 165 | + define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' ); |
|
| 166 | + define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' ); |
|
| 167 | + define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' ); |
|
| 168 | + define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' ); |
|
| 169 | + define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' ); |
|
| 170 | + define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' ); |
|
| 171 | + |
|
| 172 | + if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 173 | + define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL ); |
|
| 174 | + } |
|
| 175 | + if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) { |
|
| 176 | + define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL ); |
|
| 177 | + } |
|
| 178 | + if ( ! defined( 'AUI_INFO_COLOR' ) ) { |
|
| 179 | + define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL ); |
|
| 180 | + } |
|
| 181 | + if ( ! defined( 'AUI_WARNING_COLOR' ) ) { |
|
| 182 | + define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL ); |
|
| 183 | + } |
|
| 184 | + if ( ! defined( 'AUI_DANGER_COLOR' ) ) { |
|
| 185 | + define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL ); |
|
| 186 | + } |
|
| 187 | + if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) { |
|
| 188 | + define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL ); |
|
| 189 | + } |
|
| 190 | + if ( ! defined( 'AUI_LIGHT_COLOR' ) ) { |
|
| 191 | + define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL ); |
|
| 192 | + } |
|
| 193 | + if ( ! defined( 'AUI_DARK_COLOR' ) ) { |
|
| 194 | + define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL ); |
|
| 195 | + } |
|
| 196 | + if ( ! defined( 'AUI_WHITE_COLOR' ) ) { |
|
| 197 | + define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL ); |
|
| 198 | + } |
|
| 199 | + if ( ! defined( 'AUI_PURPLE_COLOR' ) ) { |
|
| 200 | + define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL ); |
|
| 201 | + } |
|
| 202 | + if ( ! defined( 'AUI_SALMON_COLOR' ) ) { |
|
| 203 | + define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL ); |
|
| 204 | + } |
|
| 205 | + if ( ! defined( 'AUI_CYAN_COLOR' ) ) { |
|
| 206 | + define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL ); |
|
| 207 | + } |
|
| 208 | + if ( ! defined( 'AUI_GRAY_COLOR' ) ) { |
|
| 209 | + define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL ); |
|
| 210 | + } |
|
| 211 | + if ( ! defined( 'AUI_INDIGO_COLOR' ) ) { |
|
| 212 | + define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL ); |
|
| 213 | + } |
|
| 214 | + if ( ! defined( 'AUI_ORANGE_COLOR' ) ) { |
|
| 215 | + define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL ); |
|
| 216 | + } |
|
| 217 | + if ( ! defined( 'AUI_BLACK_COLOR' ) ) { |
|
| 218 | + define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL ); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + public static function get_colors( $original = false){ |
|
| 224 | + |
|
| 225 | + if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 226 | + return array(); |
|
| 227 | + } |
|
| 228 | + if ( $original ) { |
|
| 229 | + return array( |
|
| 230 | + 'primary' => AUI_PRIMARY_COLOR_ORIGINAL, |
|
| 231 | + 'secondary' => AUI_SECONDARY_COLOR_ORIGINAL, |
|
| 232 | + 'info' => AUI_INFO_COLOR_ORIGINAL, |
|
| 233 | + 'warning' => AUI_WARNING_COLOR_ORIGINAL, |
|
| 234 | + 'danger' => AUI_DANGER_COLOR_ORIGINAL, |
|
| 235 | + 'success' => AUI_SUCCESS_COLOR_ORIGINAL, |
|
| 236 | + 'light' => AUI_LIGHT_COLOR_ORIGINAL, |
|
| 237 | + 'dark' => AUI_DARK_COLOR_ORIGINAL, |
|
| 238 | + 'white' => AUI_WHITE_COLOR_ORIGINAL, |
|
| 239 | + 'purple' => AUI_PURPLE_COLOR_ORIGINAL, |
|
| 240 | + 'salmon' => AUI_SALMON_COLOR_ORIGINAL, |
|
| 241 | + 'cyan' => AUI_CYAN_COLOR_ORIGINAL, |
|
| 242 | + 'gray' => AUI_GRAY_COLOR_ORIGINAL, |
|
| 243 | + 'indigo' => AUI_INDIGO_COLOR_ORIGINAL, |
|
| 244 | + 'orange' => AUI_ORANGE_COLOR_ORIGINAL, |
|
| 245 | + 'black' => AUI_BLACK_COLOR_ORIGINAL, |
|
| 246 | + ); |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + return array( |
|
| 250 | + 'primary' => AUI_PRIMARY_COLOR, |
|
| 251 | + 'secondary' => AUI_SECONDARY_COLOR, |
|
| 252 | + 'info' => AUI_INFO_COLOR, |
|
| 253 | + 'warning' => AUI_WARNING_COLOR, |
|
| 254 | + 'danger' => AUI_DANGER_COLOR, |
|
| 255 | + 'success' => AUI_SUCCESS_COLOR, |
|
| 256 | + 'light' => AUI_LIGHT_COLOR, |
|
| 257 | + 'dark' => AUI_DARK_COLOR, |
|
| 258 | + 'white' => AUI_WHITE_COLOR, |
|
| 259 | + 'purple' => AUI_PURPLE_COLOR, |
|
| 260 | + 'salmon' => AUI_SALMON_COLOR, |
|
| 261 | + 'cyan' => AUI_CYAN_COLOR, |
|
| 262 | + 'gray' => AUI_GRAY_COLOR, |
|
| 263 | + 'indigo' => AUI_INDIGO_COLOR, |
|
| 264 | + 'orange' => AUI_ORANGE_COLOR, |
|
| 265 | + 'black' => AUI_BLACK_COLOR, |
|
| 266 | + ); |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * Add admin body class to show when BS5 is active. |
|
| 271 | + * |
|
| 272 | + * @param $classes |
|
| 273 | + * |
|
| 274 | + * @return mixed |
|
| 275 | + */ |
|
| 276 | + public function add_bs5_admin_body_class( $classes = '' ) { |
|
| 277 | + $classes .= ' aui_bs5'; |
|
| 278 | + |
|
| 279 | + return $classes; |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * Add a body class to show when BS5 is active. |
|
| 284 | + * |
|
| 285 | + * @param $classes |
|
| 286 | + * |
|
| 287 | + * @return mixed |
|
| 288 | + */ |
|
| 289 | + public function add_bs5_body_class( $classes ) { |
|
| 290 | + $classes[] = 'aui_bs5'; |
|
| 291 | + |
|
| 292 | + return $classes; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * Initiate the settings and add the required action hooks. |
|
| 297 | + */ |
|
| 298 | + public function init() { |
|
| 299 | 299 | global $aui_bs5; |
| 300 | 300 | |
| 301 | - // Maybe fix settings |
|
| 302 | - if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { |
|
| 303 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 304 | - if ( ! empty( $db_settings ) ) { |
|
| 305 | - $db_settings['css_backend'] = 'compatibility'; |
|
| 306 | - $db_settings['js_backend'] = 'core-popper'; |
|
| 307 | - update_option( 'ayecode-ui-settings', $db_settings ); |
|
| 308 | - wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); |
|
| 309 | - } |
|
| 310 | - } |
|
| 301 | + // Maybe fix settings |
|
| 302 | + if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { |
|
| 303 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 304 | + if ( ! empty( $db_settings ) ) { |
|
| 305 | + $db_settings['css_backend'] = 'compatibility'; |
|
| 306 | + $db_settings['js_backend'] = 'core-popper'; |
|
| 307 | + update_option( 'ayecode-ui-settings', $db_settings ); |
|
| 308 | + wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - $this->constants(); |
|
| 313 | - $this->settings = $this->get_settings(); |
|
| 314 | - $this->url = $this->get_url(); |
|
| 312 | + $this->constants(); |
|
| 313 | + $this->settings = $this->get_settings(); |
|
| 314 | + $this->url = $this->get_url(); |
|
| 315 | 315 | |
| 316 | 316 | // define the version |
| 317 | - $aui_bs5 = $this->settings['bs_ver'] === '5'; |
|
| 318 | - |
|
| 319 | - if ( $aui_bs5 ) { |
|
| 320 | - include_once( dirname( __FILE__ ) . '/inc/bs-conversion.php' ); |
|
| 321 | - add_filter( 'admin_body_class', array( $this, 'add_bs5_admin_body_class' ), 99, 1 ); |
|
| 322 | - add_filter( 'body_class', array( $this, 'add_bs5_body_class' ) ); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * Maybe load CSS |
|
| 327 | - * |
|
| 328 | - * We load super early in case there is a theme version that might change the colors |
|
| 329 | - */ |
|
| 330 | - if ( $this->settings['css'] ) { |
|
| 331 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 317 | + $aui_bs5 = $this->settings['bs_ver'] === '5'; |
|
| 318 | + |
|
| 319 | + if ( $aui_bs5 ) { |
|
| 320 | + include_once( dirname( __FILE__ ) . '/inc/bs-conversion.php' ); |
|
| 321 | + add_filter( 'admin_body_class', array( $this, 'add_bs5_admin_body_class' ), 99, 1 ); |
|
| 322 | + add_filter( 'body_class', array( $this, 'add_bs5_body_class' ) ); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * Maybe load CSS |
|
| 327 | + * |
|
| 328 | + * We load super early in case there is a theme version that might change the colors |
|
| 329 | + */ |
|
| 330 | + if ( $this->settings['css'] ) { |
|
| 331 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 332 | 332 | $priority = $aui_bs5 ? 10 : $priority; |
| 333 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); |
|
| 334 | - } |
|
| 335 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 336 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - // maybe load JS |
|
| 340 | - if ( $this->settings['js'] ) { |
|
| 341 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 342 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 343 | - } |
|
| 344 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 345 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - // Maybe set the HTML font size |
|
| 349 | - if ( $this->settings['html_font_size'] ) { |
|
| 350 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - // Maybe show backend style error |
|
| 354 | - if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ |
|
| 355 | - add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * Show admin notice if backend scripts not loaded. |
|
| 362 | - */ |
|
| 363 | - public function show_admin_style_notice(){ |
|
| 364 | - $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); |
|
| 365 | - $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>'; |
|
| 366 | - $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button; |
|
| 367 | - echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>'; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - /** |
|
| 371 | - * Check if we should load the admin scripts or not. |
|
| 372 | - * |
|
| 373 | - * @return bool |
|
| 374 | - */ |
|
| 375 | - public function load_admin_scripts(){ |
|
| 376 | - $result = true; |
|
| 377 | - |
|
| 378 | - // check if specifically disabled |
|
| 379 | - if(!empty($this->settings['disable_admin'])){ |
|
| 380 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 381 | - foreach($url_parts as $part){ |
|
| 382 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 383 | - return false; // return early, no point checking further |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - return $result; |
|
| 389 | - } |
|
| 390 | - |
|
| 391 | - /** |
|
| 392 | - * Add a html font size to the footer. |
|
| 393 | - */ |
|
| 394 | - public function html_font_size(){ |
|
| 395 | - $this->settings = $this->get_settings(); |
|
| 396 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - /** |
|
| 400 | - * Check if the current admin screen should load scripts. |
|
| 401 | - * |
|
| 402 | - * @return bool |
|
| 403 | - */ |
|
| 404 | - public function is_aui_screen(){ |
|
| 333 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); |
|
| 334 | + } |
|
| 335 | + if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 336 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + // maybe load JS |
|
| 340 | + if ( $this->settings['js'] ) { |
|
| 341 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 342 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 343 | + } |
|
| 344 | + if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 345 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + // Maybe set the HTML font size |
|
| 349 | + if ( $this->settings['html_font_size'] ) { |
|
| 350 | + add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + // Maybe show backend style error |
|
| 354 | + if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ |
|
| 355 | + add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * Show admin notice if backend scripts not loaded. |
|
| 362 | + */ |
|
| 363 | + public function show_admin_style_notice(){ |
|
| 364 | + $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); |
|
| 365 | + $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>'; |
|
| 366 | + $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button; |
|
| 367 | + echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>'; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + /** |
|
| 371 | + * Check if we should load the admin scripts or not. |
|
| 372 | + * |
|
| 373 | + * @return bool |
|
| 374 | + */ |
|
| 375 | + public function load_admin_scripts(){ |
|
| 376 | + $result = true; |
|
| 377 | + |
|
| 378 | + // check if specifically disabled |
|
| 379 | + if(!empty($this->settings['disable_admin'])){ |
|
| 380 | + $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 381 | + foreach($url_parts as $part){ |
|
| 382 | + if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 383 | + return false; // return early, no point checking further |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + return $result; |
|
| 389 | + } |
|
| 390 | + |
|
| 391 | + /** |
|
| 392 | + * Add a html font size to the footer. |
|
| 393 | + */ |
|
| 394 | + public function html_font_size(){ |
|
| 395 | + $this->settings = $this->get_settings(); |
|
| 396 | + echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + /** |
|
| 400 | + * Check if the current admin screen should load scripts. |
|
| 401 | + * |
|
| 402 | + * @return bool |
|
| 403 | + */ |
|
| 404 | + public function is_aui_screen(){ |
|
| 405 | 405 | // echo '###';exit; |
| 406 | - $load = false; |
|
| 407 | - // check if we should load or not |
|
| 408 | - if ( is_admin() ) { |
|
| 409 | - // Only enable on set pages |
|
| 410 | - $aui_screens = array( |
|
| 411 | - 'page', |
|
| 406 | + $load = false; |
|
| 407 | + // check if we should load or not |
|
| 408 | + if ( is_admin() ) { |
|
| 409 | + // Only enable on set pages |
|
| 410 | + $aui_screens = array( |
|
| 411 | + 'page', |
|
| 412 | 412 | //'docs', |
| 413 | - 'post', |
|
| 414 | - 'settings_page_ayecode-ui-settings', |
|
| 415 | - 'appearance_page_gutenberg-widgets', |
|
| 416 | - 'widgets', |
|
| 417 | - 'ayecode-ui-settings', |
|
| 418 | - 'site-editor' |
|
| 419 | - ); |
|
| 420 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 413 | + 'post', |
|
| 414 | + 'settings_page_ayecode-ui-settings', |
|
| 415 | + 'appearance_page_gutenberg-widgets', |
|
| 416 | + 'widgets', |
|
| 417 | + 'ayecode-ui-settings', |
|
| 418 | + 'site-editor' |
|
| 419 | + ); |
|
| 420 | + $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 421 | 421 | |
| 422 | - $screen = get_current_screen(); |
|
| 422 | + $screen = get_current_screen(); |
|
| 423 | 423 | |
| 424 | 424 | // echo '###'.$screen->id; |
| 425 | 425 | |
| 426 | - // check if we are on a AUI screen |
|
| 427 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 428 | - $load = true; |
|
| 429 | - } |
|
| 426 | + // check if we are on a AUI screen |
|
| 427 | + if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 428 | + $load = true; |
|
| 429 | + } |
|
| 430 | 430 | |
| 431 | - //load for widget previews in WP 5.8 |
|
| 432 | - if( !empty($_REQUEST['legacy-widget-preview'])){ |
|
| 433 | - $load = true; |
|
| 434 | - } |
|
| 435 | - } |
|
| 431 | + //load for widget previews in WP 5.8 |
|
| 432 | + if( !empty($_REQUEST['legacy-widget-preview'])){ |
|
| 433 | + $load = true; |
|
| 434 | + } |
|
| 435 | + } |
|
| 436 | 436 | |
| 437 | 437 | |
| 438 | 438 | |
| 439 | - return apply_filters( 'aui_load_on_admin' , $load ); |
|
| 440 | - } |
|
| 439 | + return apply_filters( 'aui_load_on_admin' , $load ); |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | - /** |
|
| 443 | - * Check if the current theme is a block theme. |
|
| 444 | - * |
|
| 445 | - * @return bool |
|
| 446 | - */ |
|
| 447 | - public static function is_block_theme() { |
|
| 448 | - if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) { |
|
| 449 | - return true; |
|
| 450 | - } |
|
| 442 | + /** |
|
| 443 | + * Check if the current theme is a block theme. |
|
| 444 | + * |
|
| 445 | + * @return bool |
|
| 446 | + */ |
|
| 447 | + public static function is_block_theme() { |
|
| 448 | + if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) { |
|
| 449 | + return true; |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | - return false; |
|
| 453 | - } |
|
| 452 | + return false; |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | - /** |
|
| 456 | - * Adds the styles. |
|
| 457 | - */ |
|
| 458 | - public function enqueue_style() { |
|
| 455 | + /** |
|
| 456 | + * Adds the styles. |
|
| 457 | + */ |
|
| 458 | + public function enqueue_style() { |
|
| 459 | 459 | global $aui_bs5; |
| 460 | 460 | |
| 461 | 461 | $load_fse = false; |
| 462 | 462 | |
| 463 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 464 | - // don't add wp-admin scripts if not requested to |
|
| 465 | - }else{ |
|
| 466 | - $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 463 | + if( is_admin() && !$this->is_aui_screen()){ |
|
| 464 | + // don't add wp-admin scripts if not requested to |
|
| 465 | + }else{ |
|
| 466 | + $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 467 | 467 | |
| 468 | - $rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : ''; |
|
| 468 | + $rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : ''; |
|
| 469 | 469 | |
| 470 | 470 | $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : ''; |
| 471 | 471 | |
| 472 | - if($this->settings[$css_setting]){ |
|
| 473 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 474 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets'.$bs_ver.'/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets'.$bs_ver.'/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 472 | + if($this->settings[$css_setting]){ |
|
| 473 | + $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 474 | + $url = $this->settings[$css_setting]=='core' ? $this->url.'assets'.$bs_ver.'/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets'.$bs_ver.'/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 475 | 475 | |
| 476 | 476 | |
| 477 | 477 | |
| 478 | - wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
| 479 | - wp_enqueue_style( 'ayecode-ui' ); |
|
| 478 | + wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
| 479 | + wp_enqueue_style( 'ayecode-ui' ); |
|
| 480 | 480 | |
| 481 | - $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : ''; |
|
| 481 | + $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : ''; |
|
| 482 | 482 | |
| 483 | 483 | // if ( is_admin() && !empty($_REQUEST['postType']) ) { |
| 484 | - if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) ) ) { |
|
| 485 | - $url = $this->url.'assets'.$bs_ver.'/css/ayecode-ui-fse.css'; |
|
| 486 | - wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version ); |
|
| 487 | - wp_enqueue_style( 'ayecode-ui-fse' ); |
|
| 488 | - $load_fse = true; |
|
| 489 | - } |
|
| 484 | + if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) ) ) { |
|
| 485 | + $url = $this->url.'assets'.$bs_ver.'/css/ayecode-ui-fse.css'; |
|
| 486 | + wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version ); |
|
| 487 | + wp_enqueue_style( 'ayecode-ui-fse' ); |
|
| 488 | + $load_fse = true; |
|
| 489 | + } |
|
| 490 | 490 | |
| 491 | 491 | |
| 492 | - // flatpickr |
|
| 493 | - wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version ); |
|
| 492 | + // flatpickr |
|
| 493 | + wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version ); |
|
| 494 | 494 | |
| 495 | - // fix some wp-admin issues |
|
| 496 | - if(is_admin()){ |
|
| 497 | - $custom_css = " |
|
| 495 | + // fix some wp-admin issues |
|
| 496 | + if(is_admin()){ |
|
| 497 | + $custom_css = " |
|
| 498 | 498 | body{ |
| 499 | 499 | background-color: #f1f1f1; |
| 500 | 500 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
@@ -535,67 +535,67 @@ discard block |
||
| 535 | 535 | } |
| 536 | 536 | "; |
| 537 | 537 | |
| 538 | - // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 539 | - $custom_css .= " |
|
| 538 | + // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 539 | + $custom_css .= " |
|
| 540 | 540 | .edit-post-sidebar input[type=color].components-text-control__input{ |
| 541 | 541 | padding: 0; |
| 542 | 542 | } |
| 543 | 543 | "; |
| 544 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 545 | - } |
|
| 544 | + wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | - // custom changes |
|
| 548 | - if ( $load_fse ) { |
|
| 549 | - wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) ); |
|
| 550 | - }else{ |
|
| 551 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 547 | + // custom changes |
|
| 548 | + if ( $load_fse ) { |
|
| 549 | + wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) ); |
|
| 550 | + }else{ |
|
| 551 | + wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 552 | 552 | |
| 553 | - } |
|
| 553 | + } |
|
| 554 | 554 | |
| 555 | - } |
|
| 556 | - } |
|
| 555 | + } |
|
| 556 | + } |
|
| 557 | 557 | |
| 558 | 558 | |
| 559 | - } |
|
| 559 | + } |
|
| 560 | 560 | |
| 561 | - /** |
|
| 562 | - * Get inline script used if bootstrap enqueued |
|
| 563 | - * |
|
| 564 | - * If this remains small then its best to use this than to add another JS file. |
|
| 565 | - */ |
|
| 566 | - public function inline_script() { |
|
| 561 | + /** |
|
| 562 | + * Get inline script used if bootstrap enqueued |
|
| 563 | + * |
|
| 564 | + * If this remains small then its best to use this than to add another JS file. |
|
| 565 | + */ |
|
| 566 | + public function inline_script() { |
|
| 567 | 567 | global $aui_bs5; |
| 568 | - // Flatpickr calendar locale |
|
| 569 | - $flatpickr_locale = self::flatpickr_locale(); |
|
| 570 | - |
|
| 571 | - ob_start(); |
|
| 572 | - if ( $aui_bs5 ) { |
|
| 573 | - include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' ); |
|
| 574 | - }else{ |
|
| 575 | - include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' ); |
|
| 568 | + // Flatpickr calendar locale |
|
| 569 | + $flatpickr_locale = self::flatpickr_locale(); |
|
| 570 | + |
|
| 571 | + ob_start(); |
|
| 572 | + if ( $aui_bs5 ) { |
|
| 573 | + include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' ); |
|
| 574 | + }else{ |
|
| 575 | + include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' ); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - $output = ob_get_clean(); |
|
| 578 | + $output = ob_get_clean(); |
|
| 579 | 579 | |
| 580 | - /* |
|
| 580 | + /* |
|
| 581 | 581 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 582 | 582 | */ |
| 583 | - return str_replace( array( |
|
| 584 | - '<script>', |
|
| 585 | - '</script>' |
|
| 586 | - ), '', self::minify_js($output) ); |
|
| 587 | - } |
|
| 588 | - |
|
| 589 | - |
|
| 590 | - /** |
|
| 591 | - * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 592 | - * |
|
| 593 | - * @TODO we may need this when other conflicts arrise. |
|
| 594 | - * @return mixed |
|
| 595 | - */ |
|
| 596 | - public static function bs3_compat_js() { |
|
| 597 | - ob_start(); |
|
| 598 | - ?> |
|
| 583 | + return str_replace( array( |
|
| 584 | + '<script>', |
|
| 585 | + '</script>' |
|
| 586 | + ), '', self::minify_js($output) ); |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + |
|
| 590 | + /** |
|
| 591 | + * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 592 | + * |
|
| 593 | + * @TODO we may need this when other conflicts arrise. |
|
| 594 | + * @return mixed |
|
| 595 | + */ |
|
| 596 | + public static function bs3_compat_js() { |
|
| 597 | + ob_start(); |
|
| 598 | + ?> |
|
| 599 | 599 | <script> |
| 600 | 600 | <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
| 601 | 601 | /* With Avada builder */ |
@@ -603,20 +603,20 @@ discard block |
||
| 603 | 603 | <?php } ?> |
| 604 | 604 | </script> |
| 605 | 605 | <?php |
| 606 | - return str_replace( array( |
|
| 607 | - '<script>', |
|
| 608 | - '</script>' |
|
| 609 | - ), '', ob_get_clean()); |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - /** |
|
| 613 | - * Get inline script used if bootstrap file browser enqueued. |
|
| 614 | - * |
|
| 615 | - * If this remains small then its best to use this than to add another JS file. |
|
| 616 | - */ |
|
| 617 | - public function inline_script_file_browser(){ |
|
| 618 | - ob_start(); |
|
| 619 | - ?> |
|
| 606 | + return str_replace( array( |
|
| 607 | + '<script>', |
|
| 608 | + '</script>' |
|
| 609 | + ), '', ob_get_clean()); |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + /** |
|
| 613 | + * Get inline script used if bootstrap file browser enqueued. |
|
| 614 | + * |
|
| 615 | + * If this remains small then its best to use this than to add another JS file. |
|
| 616 | + */ |
|
| 617 | + public function inline_script_file_browser(){ |
|
| 618 | + ob_start(); |
|
| 619 | + ?> |
|
| 620 | 620 | <script> |
| 621 | 621 | // run on doc ready |
| 622 | 622 | jQuery(document).ready(function () { |
@@ -624,282 +624,282 @@ discard block |
||
| 624 | 624 | }); |
| 625 | 625 | </script> |
| 626 | 626 | <?php |
| 627 | - $output = ob_get_clean(); |
|
| 627 | + $output = ob_get_clean(); |
|
| 628 | 628 | |
| 629 | - /* |
|
| 629 | + /* |
|
| 630 | 630 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 631 | 631 | */ |
| 632 | - return str_replace( array( |
|
| 633 | - '<script>', |
|
| 634 | - '</script>' |
|
| 635 | - ), '', $output ); |
|
| 636 | - } |
|
| 632 | + return str_replace( array( |
|
| 633 | + '<script>', |
|
| 634 | + '</script>' |
|
| 635 | + ), '', $output ); |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | - /** |
|
| 639 | - * Adds the Font Awesome JS. |
|
| 640 | - */ |
|
| 641 | - public function enqueue_scripts() { |
|
| 638 | + /** |
|
| 639 | + * Adds the Font Awesome JS. |
|
| 640 | + */ |
|
| 641 | + public function enqueue_scripts() { |
|
| 642 | 642 | |
| 643 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 644 | - // don't add wp-admin scripts if not requested to |
|
| 645 | - }else { |
|
| 643 | + if( is_admin() && !$this->is_aui_screen()){ |
|
| 644 | + // don't add wp-admin scripts if not requested to |
|
| 645 | + }else { |
|
| 646 | 646 | |
| 647 | - $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 647 | + $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 648 | 648 | |
| 649 | - $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : ''; |
|
| 649 | + $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : ''; |
|
| 650 | 650 | |
| 651 | - // select2 |
|
| 652 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 651 | + // select2 |
|
| 652 | + wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 653 | 653 | |
| 654 | - // flatpickr |
|
| 655 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
| 654 | + // flatpickr |
|
| 655 | + wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
| 656 | 656 | |
| 657 | - // iconpicker |
|
| 658 | - if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) { |
|
| 659 | - wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version ); |
|
| 660 | - }else{ |
|
| 661 | - wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
| 662 | - } |
|
| 657 | + // iconpicker |
|
| 658 | + if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) { |
|
| 659 | + wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version ); |
|
| 660 | + }else{ |
|
| 661 | + wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | - // Bootstrap file browser |
|
| 665 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 666 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 667 | - |
|
| 668 | - $load_inline = false; |
|
| 669 | - |
|
| 670 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 671 | - // Bootstrap bundle |
|
| 672 | - $url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js'; |
|
| 673 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 674 | - 'select2', |
|
| 675 | - 'jquery' |
|
| 676 | - ), $this->version, $this->is_bs3_compat() ); |
|
| 677 | - // if in admin then add to footer for compatibility. |
|
| 678 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 679 | - $script = $this->inline_script(); |
|
| 680 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 681 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 682 | - $url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5 |
|
| 683 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version ); |
|
| 684 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 685 | - $load_inline = true; |
|
| 686 | - } else { |
|
| 687 | - $load_inline = true; |
|
| 688 | - } |
|
| 664 | + // Bootstrap file browser |
|
| 665 | + wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 666 | + wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 667 | + |
|
| 668 | + $load_inline = false; |
|
| 669 | + |
|
| 670 | + if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 671 | + // Bootstrap bundle |
|
| 672 | + $url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js'; |
|
| 673 | + wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 674 | + 'select2', |
|
| 675 | + 'jquery' |
|
| 676 | + ), $this->version, $this->is_bs3_compat() ); |
|
| 677 | + // if in admin then add to footer for compatibility. |
|
| 678 | + is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 679 | + $script = $this->inline_script(); |
|
| 680 | + wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 681 | + } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 682 | + $url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5 |
|
| 683 | + wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version ); |
|
| 684 | + wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 685 | + $load_inline = true; |
|
| 686 | + } else { |
|
| 687 | + $load_inline = true; |
|
| 688 | + } |
|
| 689 | 689 | |
| 690 | - // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 691 | - if ( $load_inline ) { |
|
| 692 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 693 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 694 | - $script = $this->inline_script(); |
|
| 695 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 696 | - } |
|
| 697 | - } |
|
| 698 | - |
|
| 699 | - } |
|
| 700 | - |
|
| 701 | - /** |
|
| 702 | - * Enqueue flatpickr if called. |
|
| 703 | - */ |
|
| 704 | - public function enqueue_flatpickr(){ |
|
| 705 | - wp_enqueue_style( 'flatpickr' ); |
|
| 706 | - wp_enqueue_script( 'flatpickr' ); |
|
| 707 | - } |
|
| 708 | - |
|
| 709 | - /** |
|
| 710 | - * Enqueue iconpicker if called. |
|
| 711 | - */ |
|
| 712 | - public function enqueue_iconpicker(){ |
|
| 713 | - wp_enqueue_style( 'iconpicker' ); |
|
| 714 | - wp_enqueue_script( 'iconpicker' ); |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - /** |
|
| 718 | - * Get the url path to the current folder. |
|
| 719 | - * |
|
| 720 | - * @return string |
|
| 721 | - */ |
|
| 722 | - public function get_url() { |
|
| 723 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 724 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 725 | - |
|
| 726 | - // Replace http:// to https://. |
|
| 727 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 728 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 729 | - } |
|
| 730 | - |
|
| 731 | - // Check if we are inside a plugin |
|
| 732 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 733 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 734 | - |
|
| 735 | - return trailingslashit( $url ); |
|
| 736 | - } |
|
| 737 | - |
|
| 738 | - /** |
|
| 739 | - * Get the url path to the current folder. |
|
| 740 | - * |
|
| 741 | - * @return string |
|
| 742 | - */ |
|
| 743 | - public function get_url_old() { |
|
| 744 | - |
|
| 745 | - $url = ''; |
|
| 746 | - // check if we are inside a plugin |
|
| 747 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 748 | - |
|
| 749 | - // add check in-case user has changed wp-content dir name. |
|
| 750 | - $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 751 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 752 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 753 | - |
|
| 754 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 755 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 756 | - } |
|
| 757 | - |
|
| 758 | - return $url; |
|
| 759 | - } |
|
| 760 | - |
|
| 761 | - /** |
|
| 762 | - * Register the database settings with WordPress. |
|
| 763 | - */ |
|
| 764 | - public function register_settings() { |
|
| 765 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 766 | - } |
|
| 767 | - |
|
| 768 | - /** |
|
| 769 | - * Add the WordPress settings menu item. |
|
| 770 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 771 | - */ |
|
| 772 | - public function menu_item() { |
|
| 773 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 774 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 775 | - $this, |
|
| 776 | - 'settings_page' |
|
| 777 | - ) ); |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - /** |
|
| 781 | - * Get a list of themes and their default JS settings. |
|
| 782 | - * |
|
| 783 | - * @return array |
|
| 784 | - */ |
|
| 785 | - public function theme_js_settings(){ |
|
| 786 | - return array( |
|
| 787 | - 'ayetheme' => 'popper', |
|
| 788 | - 'listimia' => 'required', |
|
| 789 | - 'listimia_backend' => 'core-popper', |
|
| 790 | - //'avada' => 'required', // removed as we now add compatibility |
|
| 791 | - ); |
|
| 792 | - } |
|
| 793 | - |
|
| 794 | - /** |
|
| 690 | + // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 691 | + if ( $load_inline ) { |
|
| 692 | + wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 693 | + wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 694 | + $script = $this->inline_script(); |
|
| 695 | + wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 696 | + } |
|
| 697 | + } |
|
| 698 | + |
|
| 699 | + } |
|
| 700 | + |
|
| 701 | + /** |
|
| 702 | + * Enqueue flatpickr if called. |
|
| 703 | + */ |
|
| 704 | + public function enqueue_flatpickr(){ |
|
| 705 | + wp_enqueue_style( 'flatpickr' ); |
|
| 706 | + wp_enqueue_script( 'flatpickr' ); |
|
| 707 | + } |
|
| 708 | + |
|
| 709 | + /** |
|
| 710 | + * Enqueue iconpicker if called. |
|
| 711 | + */ |
|
| 712 | + public function enqueue_iconpicker(){ |
|
| 713 | + wp_enqueue_style( 'iconpicker' ); |
|
| 714 | + wp_enqueue_script( 'iconpicker' ); |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + /** |
|
| 718 | + * Get the url path to the current folder. |
|
| 719 | + * |
|
| 720 | + * @return string |
|
| 721 | + */ |
|
| 722 | + public function get_url() { |
|
| 723 | + $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 724 | + $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 725 | + |
|
| 726 | + // Replace http:// to https://. |
|
| 727 | + if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 728 | + $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 729 | + } |
|
| 730 | + |
|
| 731 | + // Check if we are inside a plugin |
|
| 732 | + $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 733 | + $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 734 | + |
|
| 735 | + return trailingslashit( $url ); |
|
| 736 | + } |
|
| 737 | + |
|
| 738 | + /** |
|
| 739 | + * Get the url path to the current folder. |
|
| 740 | + * |
|
| 741 | + * @return string |
|
| 742 | + */ |
|
| 743 | + public function get_url_old() { |
|
| 744 | + |
|
| 745 | + $url = ''; |
|
| 746 | + // check if we are inside a plugin |
|
| 747 | + $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 748 | + |
|
| 749 | + // add check in-case user has changed wp-content dir name. |
|
| 750 | + $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 751 | + $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 752 | + $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 753 | + |
|
| 754 | + if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 755 | + $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 756 | + } |
|
| 757 | + |
|
| 758 | + return $url; |
|
| 759 | + } |
|
| 760 | + |
|
| 761 | + /** |
|
| 762 | + * Register the database settings with WordPress. |
|
| 763 | + */ |
|
| 764 | + public function register_settings() { |
|
| 765 | + register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 766 | + } |
|
| 767 | + |
|
| 768 | + /** |
|
| 769 | + * Add the WordPress settings menu item. |
|
| 770 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 771 | + */ |
|
| 772 | + public function menu_item() { |
|
| 773 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 774 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 775 | + $this, |
|
| 776 | + 'settings_page' |
|
| 777 | + ) ); |
|
| 778 | + } |
|
| 779 | + |
|
| 780 | + /** |
|
| 781 | + * Get a list of themes and their default JS settings. |
|
| 782 | + * |
|
| 783 | + * @return array |
|
| 784 | + */ |
|
| 785 | + public function theme_js_settings(){ |
|
| 786 | + return array( |
|
| 787 | + 'ayetheme' => 'popper', |
|
| 788 | + 'listimia' => 'required', |
|
| 789 | + 'listimia_backend' => 'core-popper', |
|
| 790 | + //'avada' => 'required', // removed as we now add compatibility |
|
| 791 | + ); |
|
| 792 | + } |
|
| 793 | + |
|
| 794 | + /** |
|
| 795 | 795 | * Get the date the site was installed. |
| 796 | 796 | * |
| 797 | - * @return false|string |
|
| 798 | - */ |
|
| 797 | + * @return false|string |
|
| 798 | + */ |
|
| 799 | 799 | public function get_site_install_date() { |
| 800 | - global $wpdb; // This gives you access to the WordPress database object |
|
| 800 | + global $wpdb; // This gives you access to the WordPress database object |
|
| 801 | + |
|
| 802 | + // Prepare the SQL query to get the oldest registration date |
|
| 803 | + $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}"; |
|
| 801 | 804 | |
| 802 | - // Prepare the SQL query to get the oldest registration date |
|
| 803 | - $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}"; |
|
| 805 | + // Execute the query |
|
| 806 | + $date = $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
|
| 804 | 807 | |
| 805 | - // Execute the query |
|
| 806 | - $date = $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
|
| 808 | + return $date ? $date : false; |
|
| 809 | + } |
|
| 807 | 810 | |
| 808 | - return $date ? $date : false; |
|
| 811 | + /** |
|
| 812 | + * Show admin notice if backend scripts not loaded. |
|
| 813 | + */ |
|
| 814 | + public function show_admin_version_notice(){ |
|
| 815 | + $fix_url = admin_url("options-general.php?page=ayecode-ui-settings" ); |
|
| 816 | + $button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>'; |
|
| 817 | + $message = __( '<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)')." " .$button; |
|
| 818 | + echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>'; |
|
| 809 | 819 | } |
| 810 | 820 | |
| 811 | - /** |
|
| 812 | - * Show admin notice if backend scripts not loaded. |
|
| 813 | - */ |
|
| 814 | - public function show_admin_version_notice(){ |
|
| 815 | - $fix_url = admin_url("options-general.php?page=ayecode-ui-settings" ); |
|
| 816 | - $button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>'; |
|
| 817 | - $message = __( '<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)')." " .$button; |
|
| 818 | - echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>'; |
|
| 819 | - } |
|
| 820 | - |
|
| 821 | - /** |
|
| 822 | - * Get the current Font Awesome output settings. |
|
| 823 | - * |
|
| 824 | - * @return array The array of settings. |
|
| 825 | - */ |
|
| 826 | - public function get_settings() { |
|
| 827 | - |
|
| 828 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 821 | + /** |
|
| 822 | + * Get the current Font Awesome output settings. |
|
| 823 | + * |
|
| 824 | + * @return array The array of settings. |
|
| 825 | + */ |
|
| 826 | + public function get_settings() { |
|
| 827 | + |
|
| 828 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 829 | 829 | |
| 830 | 830 | // Maybe show default version notice |
| 831 | - $site_install_date = new DateTime( self::get_site_install_date() ); |
|
| 832 | - $switch_over_date = new DateTime("2024-02-01"); |
|
| 833 | - if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) { |
|
| 834 | - add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) ); |
|
| 835 | - } |
|
| 836 | - |
|
| 837 | - $js_default = 'core-popper'; |
|
| 838 | - $js_default_backend = $js_default; |
|
| 839 | - |
|
| 840 | - // maybe set defaults (if no settings set) |
|
| 841 | - if(empty($db_settings)){ |
|
| 842 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 843 | - $theme_js_settings = self::theme_js_settings(); |
|
| 844 | - if(isset($theme_js_settings[$active_theme])){ |
|
| 845 | - $js_default = $theme_js_settings[$active_theme]; |
|
| 846 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 847 | - } |
|
| 848 | - } |
|
| 831 | + $site_install_date = new DateTime( self::get_site_install_date() ); |
|
| 832 | + $switch_over_date = new DateTime("2024-02-01"); |
|
| 833 | + if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) { |
|
| 834 | + add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) ); |
|
| 835 | + } |
|
| 849 | 836 | |
| 850 | - /** |
|
| 851 | - * Filter the default settings. |
|
| 852 | - */ |
|
| 853 | - $defaults = apply_filters( 'ayecode-ui-default-settings', array( |
|
| 854 | - 'css' => 'compatibility', // core, compatibility |
|
| 855 | - 'js' => $js_default, // js to load, core-popper, popper |
|
| 856 | - 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 857 | - 'css_backend' => 'compatibility', // core, compatibility |
|
| 858 | - 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 859 | - 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 837 | + $js_default = 'core-popper'; |
|
| 838 | + $js_default_backend = $js_default; |
|
| 839 | + |
|
| 840 | + // maybe set defaults (if no settings set) |
|
| 841 | + if(empty($db_settings)){ |
|
| 842 | + $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 843 | + $theme_js_settings = self::theme_js_settings(); |
|
| 844 | + if(isset($theme_js_settings[$active_theme])){ |
|
| 845 | + $js_default = $theme_js_settings[$active_theme]; |
|
| 846 | + $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 847 | + } |
|
| 848 | + } |
|
| 849 | + |
|
| 850 | + /** |
|
| 851 | + * Filter the default settings. |
|
| 852 | + */ |
|
| 853 | + $defaults = apply_filters( 'ayecode-ui-default-settings', array( |
|
| 854 | + 'css' => 'compatibility', // core, compatibility |
|
| 855 | + 'js' => $js_default, // js to load, core-popper, popper |
|
| 856 | + 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 857 | + 'css_backend' => 'compatibility', // core, compatibility |
|
| 858 | + 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 859 | + 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 860 | 860 | 'bs_ver' => '5', // The default bootstrap version to sue by default |
| 861 | - ), $db_settings ); |
|
| 861 | + ), $db_settings ); |
|
| 862 | 862 | |
| 863 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 863 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 864 | 864 | |
| 865 | - /** |
|
| 866 | - * Filter the Bootstrap settings. |
|
| 867 | - * |
|
| 868 | - * @todo if we add this filer people might use it and then it defeats the purpose of this class :/ |
|
| 869 | - */ |
|
| 870 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 871 | - } |
|
| 865 | + /** |
|
| 866 | + * Filter the Bootstrap settings. |
|
| 867 | + * |
|
| 868 | + * @todo if we add this filer people might use it and then it defeats the purpose of this class :/ |
|
| 869 | + */ |
|
| 870 | + return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 871 | + } |
|
| 872 | 872 | |
| 873 | 873 | |
| 874 | - /** |
|
| 875 | - * The settings page html output. |
|
| 876 | - */ |
|
| 877 | - public function settings_page() { |
|
| 878 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 879 | - wp_die( esc_attr__( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) ); |
|
| 880 | - } |
|
| 874 | + /** |
|
| 875 | + * The settings page html output. |
|
| 876 | + */ |
|
| 877 | + public function settings_page() { |
|
| 878 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 879 | + wp_die( esc_attr__( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) ); |
|
| 880 | + } |
|
| 881 | 881 | $overrides = apply_filters( 'ayecode-ui-settings', array(), array(), array() ); |
| 882 | 882 | |
| 883 | - ?> |
|
| 883 | + ?> |
|
| 884 | 884 | <div class="wrap"> |
| 885 | 885 | <h1><?php echo esc_attr( $this->name ); ?></h1> |
| 886 | 886 | <p><?php echo esc_html( apply_filters( 'ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.", 'ayecode-connect' ) ) );?></p> |
| 887 | 887 | <form method="post" action="options.php"> |
| 888 | 888 | <?php |
| 889 | - settings_fields( 'ayecode-ui-settings' ); |
|
| 890 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
| 891 | - ?> |
|
| 889 | + settings_fields( 'ayecode-ui-settings' ); |
|
| 890 | + do_settings_sections( 'ayecode-ui-settings' ); |
|
| 891 | + ?> |
|
| 892 | 892 | |
| 893 | 893 | <h2><?php esc_html_e( 'BootStrap Version', 'ayecode-connect' ); ?></h2> |
| 894 | 894 | <p><?php echo esc_html( apply_filters( 'ayecode-ui-version-settings-message', __("V5 is recommended, however if you have another plugin installed using v4, you may need to use v4 also.", 'ayecode-connect' ) ) );?></p> |
| 895 | 895 | <div class="bsui"><?php |
| 896 | - if ( ! empty( $overrides ) ) { |
|
| 897 | - echo aui()->alert(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 898 | - 'type'=> 'info', |
|
| 899 | - 'content'=> esc_attr__("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' ) |
|
| 900 | - )); |
|
| 901 | - } |
|
| 902 | - ?> |
|
| 896 | + if ( ! empty( $overrides ) ) { |
|
| 897 | + echo aui()->alert(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 898 | + 'type'=> 'info', |
|
| 899 | + 'content'=> esc_attr__("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' ) |
|
| 900 | + )); |
|
| 901 | + } |
|
| 902 | + ?> |
|
| 903 | 903 | </div> |
| 904 | 904 | <table class="form-table wpbs-table-version-settings"> |
| 905 | 905 | <tr valign="top"> |
@@ -983,77 +983,77 @@ discard block |
||
| 983 | 983 | </table> |
| 984 | 984 | |
| 985 | 985 | <?php |
| 986 | - submit_button(); |
|
| 987 | - ?> |
|
| 986 | + submit_button(); |
|
| 987 | + ?> |
|
| 988 | 988 | </form> |
| 989 | 989 | <div id="wpbs-version" data-aui-source="<?php echo esc_attr( $this->get_load_source() ); ?>"><?php echo esc_html( $this->version ); ?></div> |
| 990 | 990 | </div> |
| 991 | 991 | <?php |
| 992 | - } |
|
| 992 | + } |
|
| 993 | 993 | |
| 994 | 994 | public function get_load_source(){ |
| 995 | - $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) ); |
|
| 996 | - $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) ); |
|
| 997 | - |
|
| 998 | - // Find source plugin/theme of SD |
|
| 999 | - $source = array(); |
|
| 1000 | - if ( strpos( $file, $plugins_dir ) !== false ) { |
|
| 1001 | - $source = explode( "/", plugin_basename( $file ) ); |
|
| 1002 | - } else if ( function_exists( 'get_theme_root' ) ) { |
|
| 1003 | - $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) ); |
|
| 1004 | - |
|
| 1005 | - if ( strpos( $file, $themes_dir ) !== false ) { |
|
| 1006 | - $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) ); |
|
| 1007 | - } |
|
| 1008 | - } |
|
| 995 | + $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) ); |
|
| 996 | + $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) ); |
|
| 997 | + |
|
| 998 | + // Find source plugin/theme of SD |
|
| 999 | + $source = array(); |
|
| 1000 | + if ( strpos( $file, $plugins_dir ) !== false ) { |
|
| 1001 | + $source = explode( "/", plugin_basename( $file ) ); |
|
| 1002 | + } else if ( function_exists( 'get_theme_root' ) ) { |
|
| 1003 | + $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) ); |
|
| 1004 | + |
|
| 1005 | + if ( strpos( $file, $themes_dir ) !== false ) { |
|
| 1006 | + $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) ); |
|
| 1007 | + } |
|
| 1008 | + } |
|
| 1009 | 1009 | |
| 1010 | 1010 | return isset($source[0]) ? esc_attr($source[0]) : ''; |
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | - public function customizer_settings($wp_customize){ |
|
| 1014 | - $wp_customize->add_section('aui_settings', array( |
|
| 1015 | - 'title' => __('AyeCode UI', 'ayecode-connect' ), |
|
| 1016 | - 'priority' => 120, |
|
| 1017 | - )); |
|
| 1018 | - |
|
| 1019 | - // ============================= |
|
| 1020 | - // = Color Picker = |
|
| 1021 | - // ============================= |
|
| 1022 | - $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1023 | - 'default' => AUI_PRIMARY_COLOR, |
|
| 1024 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1025 | - 'capability' => 'edit_theme_options', |
|
| 1026 | - 'type' => 'option', |
|
| 1027 | - 'transport' => 'refresh', |
|
| 1028 | - )); |
|
| 1029 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1030 | - 'label' => __('Primary Color', 'ayecode-connect' ), |
|
| 1031 | - 'section' => 'aui_settings', |
|
| 1032 | - 'settings' => 'aui_options[color_primary]', |
|
| 1033 | - ))); |
|
| 1034 | - |
|
| 1035 | - $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1036 | - 'default' => '#6c757d', |
|
| 1037 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1038 | - 'capability' => 'edit_theme_options', |
|
| 1039 | - 'type' => 'option', |
|
| 1040 | - 'transport' => 'refresh', |
|
| 1041 | - )); |
|
| 1042 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1043 | - 'label' => __('Secondary Color', 'ayecode-connect' ), |
|
| 1044 | - 'section' => 'aui_settings', |
|
| 1045 | - 'settings' => 'aui_options[color_secondary]', |
|
| 1046 | - ))); |
|
| 1047 | - } |
|
| 1048 | - |
|
| 1049 | - /** |
|
| 1050 | - * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1051 | - * |
|
| 1052 | - * @return mixed |
|
| 1053 | - */ |
|
| 1054 | - public static function bs3_compat_css() { |
|
| 1055 | - ob_start(); |
|
| 1056 | - ?> |
|
| 1013 | + public function customizer_settings($wp_customize){ |
|
| 1014 | + $wp_customize->add_section('aui_settings', array( |
|
| 1015 | + 'title' => __('AyeCode UI', 'ayecode-connect' ), |
|
| 1016 | + 'priority' => 120, |
|
| 1017 | + )); |
|
| 1018 | + |
|
| 1019 | + // ============================= |
|
| 1020 | + // = Color Picker = |
|
| 1021 | + // ============================= |
|
| 1022 | + $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1023 | + 'default' => AUI_PRIMARY_COLOR, |
|
| 1024 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1025 | + 'capability' => 'edit_theme_options', |
|
| 1026 | + 'type' => 'option', |
|
| 1027 | + 'transport' => 'refresh', |
|
| 1028 | + )); |
|
| 1029 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1030 | + 'label' => __('Primary Color', 'ayecode-connect' ), |
|
| 1031 | + 'section' => 'aui_settings', |
|
| 1032 | + 'settings' => 'aui_options[color_primary]', |
|
| 1033 | + ))); |
|
| 1034 | + |
|
| 1035 | + $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1036 | + 'default' => '#6c757d', |
|
| 1037 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1038 | + 'capability' => 'edit_theme_options', |
|
| 1039 | + 'type' => 'option', |
|
| 1040 | + 'transport' => 'refresh', |
|
| 1041 | + )); |
|
| 1042 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1043 | + 'label' => __('Secondary Color', 'ayecode-connect' ), |
|
| 1044 | + 'section' => 'aui_settings', |
|
| 1045 | + 'settings' => 'aui_options[color_secondary]', |
|
| 1046 | + ))); |
|
| 1047 | + } |
|
| 1048 | + |
|
| 1049 | + /** |
|
| 1050 | + * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1051 | + * |
|
| 1052 | + * @return mixed |
|
| 1053 | + */ |
|
| 1054 | + public static function bs3_compat_css() { |
|
| 1055 | + ob_start(); |
|
| 1056 | + ?> |
|
| 1057 | 1057 | <style> |
| 1058 | 1058 | /* Bootstrap 3 compatibility */ |
| 1059 | 1059 | body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;} |
@@ -1082,55 +1082,55 @@ discard block |
||
| 1082 | 1082 | <?php } ?> |
| 1083 | 1083 | </style> |
| 1084 | 1084 | <?php |
| 1085 | - return str_replace( array( |
|
| 1086 | - '<style>', |
|
| 1087 | - '</style>' |
|
| 1088 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1089 | - } |
|
| 1085 | + return str_replace( array( |
|
| 1086 | + '<style>', |
|
| 1087 | + '</style>' |
|
| 1088 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1089 | + } |
|
| 1090 | 1090 | |
| 1091 | 1091 | |
| 1092 | - public static function custom_css($compatibility = true) { |
|
| 1092 | + public static function custom_css($compatibility = true) { |
|
| 1093 | 1093 | global $aui_bs5; |
| 1094 | 1094 | |
| 1095 | - $colors = array(); |
|
| 1096 | - if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 1095 | + $colors = array(); |
|
| 1096 | + if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 1097 | 1097 | |
| 1098 | 1098 | |
| 1099 | - $setting = wp_get_global_settings(); |
|
| 1099 | + $setting = wp_get_global_settings(); |
|
| 1100 | 1100 | |
| 1101 | 1101 | // print_r(wp_get_global_styles());//exit; |
| 1102 | 1102 | // print_r(get_default_block_editor_settings());exit; |
| 1103 | 1103 | |
| 1104 | 1104 | // print_r($setting);echo '###';exit; |
| 1105 | - if(!empty($setting['color']['palette']['theme'])){ |
|
| 1106 | - foreach($setting['color']['palette']['theme'] as $color){ |
|
| 1107 | - $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1108 | - } |
|
| 1109 | - } |
|
| 1105 | + if(!empty($setting['color']['palette']['theme'])){ |
|
| 1106 | + foreach($setting['color']['palette']['theme'] as $color){ |
|
| 1107 | + $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1108 | + } |
|
| 1109 | + } |
|
| 1110 | 1110 | |
| 1111 | - if(!empty($setting['color']['palette']['custom'])){ |
|
| 1112 | - foreach($setting['color']['palette']['custom'] as $color){ |
|
| 1113 | - $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1114 | - } |
|
| 1115 | - } |
|
| 1116 | - }else{ |
|
| 1117 | - $settings = get_option('aui_options'); |
|
| 1118 | - $colors = array( |
|
| 1119 | - 'primary' => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, |
|
| 1120 | - 'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR |
|
| 1121 | - ); |
|
| 1122 | - } |
|
| 1111 | + if(!empty($setting['color']['palette']['custom'])){ |
|
| 1112 | + foreach($setting['color']['palette']['custom'] as $color){ |
|
| 1113 | + $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1114 | + } |
|
| 1115 | + } |
|
| 1116 | + }else{ |
|
| 1117 | + $settings = get_option('aui_options'); |
|
| 1118 | + $colors = array( |
|
| 1119 | + 'primary' => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, |
|
| 1120 | + 'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR |
|
| 1121 | + ); |
|
| 1122 | + } |
|
| 1123 | 1123 | |
| 1124 | - ob_start(); |
|
| 1124 | + ob_start(); |
|
| 1125 | 1125 | |
| 1126 | - ?> |
|
| 1126 | + ?> |
|
| 1127 | 1127 | <style> |
| 1128 | 1128 | <?php |
| 1129 | 1129 | |
| 1130 | - // BS v3 compat |
|
| 1131 | - if( self::is_bs3_compat() ){ |
|
| 1132 | - echo self::bs3_compat_css(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 1133 | - } |
|
| 1130 | + // BS v3 compat |
|
| 1131 | + if( self::is_bs3_compat() ){ |
|
| 1132 | + echo self::bs3_compat_css(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 1133 | + } |
|
| 1134 | 1134 | |
| 1135 | 1135 | $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : ''; |
| 1136 | 1136 | $is_fse = false; |
@@ -1138,26 +1138,26 @@ discard block |
||
| 1138 | 1138 | $is_fse = true; |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | - if(!empty($colors)){ |
|
| 1142 | - $d_colors = self::get_colors(true); |
|
| 1141 | + if(!empty($colors)){ |
|
| 1142 | + $d_colors = self::get_colors(true); |
|
| 1143 | 1143 | |
| 1144 | 1144 | // $is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'; |
| 1145 | - foreach($colors as $key => $color ){ |
|
| 1146 | - if((empty( $d_colors[$key]) || $d_colors[$key] != $color) || $is_fse ) { |
|
| 1147 | - $var = $is_fse ? "var(--wp--preset--color--$key)" : $color; |
|
| 1148 | - $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility; |
|
| 1149 | - echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 1150 | - } |
|
| 1151 | - } |
|
| 1152 | - // exit; |
|
| 1153 | - } |
|
| 1145 | + foreach($colors as $key => $color ){ |
|
| 1146 | + if((empty( $d_colors[$key]) || $d_colors[$key] != $color) || $is_fse ) { |
|
| 1147 | + $var = $is_fse ? "var(--wp--preset--color--$key)" : $color; |
|
| 1148 | + $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility; |
|
| 1149 | + echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 1150 | + } |
|
| 1151 | + } |
|
| 1152 | + // exit; |
|
| 1153 | + } |
|
| 1154 | 1154 | |
| 1155 | - // Set admin bar z-index lower when modal is open. |
|
| 1156 | - echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
|
| 1155 | + // Set admin bar z-index lower when modal is open. |
|
| 1156 | + echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
|
| 1157 | 1157 | |
| 1158 | - if(is_admin()){ |
|
| 1159 | - echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
|
| 1160 | - } |
|
| 1158 | + if(is_admin()){ |
|
| 1159 | + echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
|
| 1160 | + } |
|
| 1161 | 1161 | |
| 1162 | 1162 | if( $aui_bs5 && defined( 'BLOCKSTRAP_VERSION' ) ){ |
| 1163 | 1163 | $css = ''; |
@@ -1177,28 +1177,28 @@ discard block |
||
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | // line height |
| 1180 | - if( !empty( $theme_settings['typography']['lineHeight'] ) ){ |
|
| 1180 | + if( !empty( $theme_settings['typography']['lineHeight'] ) ){ |
|
| 1181 | 1181 | $css .= '--bs-body-line-height: ' . esc_attr( $theme_settings['typography']['lineHeight'] ) . ';'; |
| 1182 | 1182 | } |
| 1183 | 1183 | |
| 1184 | 1184 | |
| 1185 | - // font weight |
|
| 1186 | - if( !empty( $theme_settings['typography']['fontWeight'] ) ){ |
|
| 1185 | + // font weight |
|
| 1186 | + if( !empty( $theme_settings['typography']['fontWeight'] ) ){ |
|
| 1187 | 1187 | $css .= '--bs-body-font-weight: ' . esc_attr( $theme_settings['typography']['fontWeight'] ) . ';'; |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | 1190 | // Background |
| 1191 | - if( !empty( $theme_settings['color']['background'] ) ){ |
|
| 1191 | + if( !empty( $theme_settings['color']['background'] ) ){ |
|
| 1192 | 1192 | $css .= '--bs-body-bg: ' . esc_attr( $theme_settings['color']['background'] ) . ';'; |
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | - // Background Gradient |
|
| 1196 | - if( !empty( $theme_settings['color']['gradient'] ) ){ |
|
| 1195 | + // Background Gradient |
|
| 1196 | + if( !empty( $theme_settings['color']['gradient'] ) ){ |
|
| 1197 | 1197 | $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';'; |
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | - // Background Gradient |
|
| 1201 | - if( !empty( $theme_settings['color']['gradient'] ) ){ |
|
| 1200 | + // Background Gradient |
|
| 1201 | + if( !empty( $theme_settings['color']['gradient'] ) ){ |
|
| 1202 | 1202 | $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';'; |
| 1203 | 1203 | } |
| 1204 | 1204 | |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | $headings_css .= 'background: ' . esc_attr( $theme_settings['elements']['heading']['color']['background'] ) . ';'; |
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | - // heading font family |
|
| 1239 | + // heading font family |
|
| 1240 | 1240 | if( !empty( $theme_settings['elements']['heading']['typography']['fontFamily'] ) ){ |
| 1241 | 1241 | $headings_css .= 'font-family: ' . esc_attr( $theme_settings['elements']['heading']['typography']['fontFamily'] ) . ';'; |
| 1242 | 1242 | } |
@@ -1249,189 +1249,189 @@ discard block |
||
| 1249 | 1249 | |
| 1250 | 1250 | foreach($hs as $hn){ |
| 1251 | 1251 | $h_css = ''; |
| 1252 | - if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){ |
|
| 1252 | + if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){ |
|
| 1253 | 1253 | $h_css .= 'color: ' . esc_attr( $theme_settings['elements'][$hn]['color']['text'] ) . ';'; |
| 1254 | - } |
|
| 1254 | + } |
|
| 1255 | 1255 | |
| 1256 | - if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){ |
|
| 1256 | + if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){ |
|
| 1257 | 1257 | $h_css .= 'font-size: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontSize'] ) . ';'; |
| 1258 | - } |
|
| 1258 | + } |
|
| 1259 | 1259 | |
| 1260 | - if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){ |
|
| 1260 | + if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){ |
|
| 1261 | 1261 | $h_css .= 'font-family: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) . ';'; |
| 1262 | - } |
|
| 1262 | + } |
|
| 1263 | 1263 | |
| 1264 | - if($h_css){ |
|
| 1264 | + if($h_css){ |
|
| 1265 | 1265 | echo esc_attr( $bep . $hn ) . '{'.esc_attr( $h_css ).'}'; |
| 1266 | - } |
|
| 1266 | + } |
|
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | } |
| 1270 | - ?> |
|
| 1270 | + ?> |
|
| 1271 | 1271 | </style> |
| 1272 | 1272 | <?php |
| 1273 | 1273 | |
| 1274 | 1274 | |
| 1275 | - /* |
|
| 1275 | + /* |
|
| 1276 | 1276 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1277 | 1277 | */ |
| 1278 | - return str_replace( array( |
|
| 1279 | - '<style>', |
|
| 1280 | - '</style>' |
|
| 1281 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1282 | - } |
|
| 1283 | - |
|
| 1284 | - |
|
| 1285 | - |
|
| 1286 | - /** |
|
| 1287 | - * Check if we should add booststrap 3 compatibility changes. |
|
| 1288 | - * |
|
| 1289 | - * @return bool |
|
| 1290 | - */ |
|
| 1291 | - public static function is_bs3_compat(){ |
|
| 1292 | - return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
| 1293 | - } |
|
| 1294 | - |
|
| 1295 | - public static function hex_to_rgb($hex) { |
|
| 1296 | - // Remove '#' if present |
|
| 1297 | - $hex = str_replace('#', '', $hex); |
|
| 1298 | - |
|
| 1299 | - // Convert 3-digit hex to 6-digit hex |
|
| 1300 | - if(strlen($hex) == 3) { |
|
| 1301 | - $hex = str_repeat(substr($hex, 0, 1), 2) . str_repeat(substr($hex, 1, 1), 2) . str_repeat(substr($hex, 2, 1), 2); |
|
| 1302 | - } |
|
| 1303 | - |
|
| 1304 | - // Convert hex to RGB |
|
| 1305 | - $r = hexdec(substr($hex, 0, 2)); |
|
| 1306 | - $g = hexdec(substr($hex, 2, 2)); |
|
| 1307 | - $b = hexdec(substr($hex, 4, 2)); |
|
| 1308 | - |
|
| 1309 | - // Return RGB values as an array |
|
| 1310 | - return $r . ',' . $g . ',' . $b; |
|
| 1311 | - } |
|
| 1312 | - |
|
| 1313 | - /** |
|
| 1314 | - * Build the CSS to overwrite a bootstrap color variable. |
|
| 1315 | - * |
|
| 1316 | - * @param $type |
|
| 1317 | - * @param $color_code |
|
| 1318 | - * @param $compatibility |
|
| 1319 | - * |
|
| 1320 | - * @return string |
|
| 1321 | - */ |
|
| 1322 | - public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){ |
|
| 1323 | - global $aui_bs5; |
|
| 1324 | - |
|
| 1325 | - $is_var = false; |
|
| 1326 | - $is_custom = strpos($type, 'custom-') !== false ? true : false; |
|
| 1327 | - if(!$color_code){return '';} |
|
| 1328 | - if(strpos($color_code, 'var') !== false){ |
|
| 1329 | - //if(!sanitize_hex_color($color_code)){ |
|
| 1330 | - $color_code = esc_attr($color_code); |
|
| 1331 | - $is_var = true; |
|
| 1278 | + return str_replace( array( |
|
| 1279 | + '<style>', |
|
| 1280 | + '</style>' |
|
| 1281 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1282 | + } |
|
| 1283 | + |
|
| 1284 | + |
|
| 1285 | + |
|
| 1286 | + /** |
|
| 1287 | + * Check if we should add booststrap 3 compatibility changes. |
|
| 1288 | + * |
|
| 1289 | + * @return bool |
|
| 1290 | + */ |
|
| 1291 | + public static function is_bs3_compat(){ |
|
| 1292 | + return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
| 1293 | + } |
|
| 1294 | + |
|
| 1295 | + public static function hex_to_rgb($hex) { |
|
| 1296 | + // Remove '#' if present |
|
| 1297 | + $hex = str_replace('#', '', $hex); |
|
| 1298 | + |
|
| 1299 | + // Convert 3-digit hex to 6-digit hex |
|
| 1300 | + if(strlen($hex) == 3) { |
|
| 1301 | + $hex = str_repeat(substr($hex, 0, 1), 2) . str_repeat(substr($hex, 1, 1), 2) . str_repeat(substr($hex, 2, 1), 2); |
|
| 1302 | + } |
|
| 1303 | + |
|
| 1304 | + // Convert hex to RGB |
|
| 1305 | + $r = hexdec(substr($hex, 0, 2)); |
|
| 1306 | + $g = hexdec(substr($hex, 2, 2)); |
|
| 1307 | + $b = hexdec(substr($hex, 4, 2)); |
|
| 1308 | + |
|
| 1309 | + // Return RGB values as an array |
|
| 1310 | + return $r . ',' . $g . ',' . $b; |
|
| 1311 | + } |
|
| 1312 | + |
|
| 1313 | + /** |
|
| 1314 | + * Build the CSS to overwrite a bootstrap color variable. |
|
| 1315 | + * |
|
| 1316 | + * @param $type |
|
| 1317 | + * @param $color_code |
|
| 1318 | + * @param $compatibility |
|
| 1319 | + * |
|
| 1320 | + * @return string |
|
| 1321 | + */ |
|
| 1322 | + public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){ |
|
| 1323 | + global $aui_bs5; |
|
| 1324 | + |
|
| 1325 | + $is_var = false; |
|
| 1326 | + $is_custom = strpos($type, 'custom-') !== false ? true : false; |
|
| 1327 | + if(!$color_code){return '';} |
|
| 1328 | + if(strpos($color_code, 'var') !== false){ |
|
| 1329 | + //if(!sanitize_hex_color($color_code)){ |
|
| 1330 | + $color_code = esc_attr($color_code); |
|
| 1331 | + $is_var = true; |
|
| 1332 | 1332 | // $color_code = "rgba($color_code, 0.5)"; |
| 1333 | 1333 | // echo '###1'.$color_code.'###';//exit; |
| 1334 | - } |
|
| 1334 | + } |
|
| 1335 | 1335 | |
| 1336 | 1336 | // echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit; |
| 1337 | 1337 | |
| 1338 | - if(!$color_code){return '';} |
|
| 1338 | + if(!$color_code){return '';} |
|
| 1339 | 1339 | |
| 1340 | - $rgb = self::hex_to_rgb($hex); |
|
| 1340 | + $rgb = self::hex_to_rgb($hex); |
|
| 1341 | 1341 | |
| 1342 | - if($compatibility===true || $compatibility===1){ |
|
| 1343 | - $compatibility = '.bsui'; |
|
| 1344 | - }elseif(!$compatibility){ |
|
| 1345 | - $compatibility = ''; |
|
| 1346 | - }else{ |
|
| 1347 | - $compatibility = esc_attr($compatibility); |
|
| 1348 | - } |
|
| 1342 | + if($compatibility===true || $compatibility===1){ |
|
| 1343 | + $compatibility = '.bsui'; |
|
| 1344 | + }elseif(!$compatibility){ |
|
| 1345 | + $compatibility = ''; |
|
| 1346 | + }else{ |
|
| 1347 | + $compatibility = esc_attr($compatibility); |
|
| 1348 | + } |
|
| 1349 | 1349 | |
| 1350 | - $prefix = $compatibility ? $compatibility . " " : ""; |
|
| 1350 | + $prefix = $compatibility ? $compatibility . " " : ""; |
|
| 1351 | 1351 | |
| 1352 | 1352 | |
| 1353 | 1353 | $output = ''; |
| 1354 | 1354 | |
| 1355 | 1355 | // echo '####'.$color_code;exit; |
| 1356 | 1356 | |
| 1357 | - $type = sanitize_html_class($type); |
|
| 1357 | + $type = sanitize_html_class($type); |
|
| 1358 | + |
|
| 1359 | + /** |
|
| 1360 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1361 | + */ |
|
| 1362 | + $selectors = array( |
|
| 1363 | + ".btn-{$type}" => array( 'b', 'o' ), |
|
| 1364 | + ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
| 1365 | + ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
| 1366 | + ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
| 1367 | + ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
| 1368 | + ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
| 1369 | + ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
| 1370 | + ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
| 1371 | + ".badge-{$type}" => array( 'b' ), |
|
| 1372 | + ".alert-{$type}" => array( 'b', 'o' ), |
|
| 1373 | + ".bg-{$type}" => array( 'b', 'f' ), |
|
| 1374 | + ".btn-link.btn-{$type}" => array( 'c' ), |
|
| 1375 | + ".text-{$type}" => array( 'c' ), |
|
| 1376 | + ); |
|
| 1377 | + |
|
| 1378 | + if ( $aui_bs5 ) { |
|
| 1379 | + unset($selectors[".alert-{$type}" ]); |
|
| 1380 | + } |
|
| 1358 | 1381 | |
| 1359 | - /** |
|
| 1360 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1361 | - */ |
|
| 1362 | - $selectors = array( |
|
| 1363 | - ".btn-{$type}" => array( 'b', 'o' ), |
|
| 1364 | - ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
| 1365 | - ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
| 1366 | - ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
| 1367 | - ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
| 1368 | - ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
| 1369 | - ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
| 1370 | - ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
| 1371 | - ".badge-{$type}" => array( 'b' ), |
|
| 1372 | - ".alert-{$type}" => array( 'b', 'o' ), |
|
| 1373 | - ".bg-{$type}" => array( 'b', 'f' ), |
|
| 1374 | - ".btn-link.btn-{$type}" => array( 'c' ), |
|
| 1375 | - ".text-{$type}" => array( 'c' ), |
|
| 1376 | - ); |
|
| 1377 | - |
|
| 1378 | - if ( $aui_bs5 ) { |
|
| 1379 | - unset($selectors[".alert-{$type}" ]); |
|
| 1380 | - } |
|
| 1381 | - |
|
| 1382 | - if ( $type == 'primary' ) { |
|
| 1383 | - $selectors = $selectors + array( |
|
| 1384 | - 'a' => array( 'c' ), |
|
| 1385 | - '.btn-link' => array( 'c' ), |
|
| 1386 | - '.dropdown-item.active' => array( 'b' ), |
|
| 1387 | - '.custom-control-input:checked~.custom-control-label::before' => array( |
|
| 1388 | - 'b', |
|
| 1389 | - 'o' |
|
| 1390 | - ), |
|
| 1391 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
| 1392 | - 'b', |
|
| 1393 | - 'o' |
|
| 1394 | - ), |
|
| 1395 | - '.nav-pills .nav-link.active' => array( 'b' ), |
|
| 1396 | - '.nav-pills .show>.nav-link' => array( 'b' ), |
|
| 1397 | - '.page-link' => array( 'c' ), |
|
| 1398 | - '.page-item.active .page-link' => array( |
|
| 1399 | - 'b', |
|
| 1400 | - 'o' |
|
| 1401 | - ), |
|
| 1402 | - '.progress-bar' => array( 'b' ), |
|
| 1403 | - '.list-group-item.active' => array( |
|
| 1404 | - 'b', |
|
| 1405 | - 'o' |
|
| 1406 | - ), |
|
| 1407 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
| 1408 | - ); |
|
| 1409 | - } |
|
| 1382 | + if ( $type == 'primary' ) { |
|
| 1383 | + $selectors = $selectors + array( |
|
| 1384 | + 'a' => array( 'c' ), |
|
| 1385 | + '.btn-link' => array( 'c' ), |
|
| 1386 | + '.dropdown-item.active' => array( 'b' ), |
|
| 1387 | + '.custom-control-input:checked~.custom-control-label::before' => array( |
|
| 1388 | + 'b', |
|
| 1389 | + 'o' |
|
| 1390 | + ), |
|
| 1391 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
| 1392 | + 'b', |
|
| 1393 | + 'o' |
|
| 1394 | + ), |
|
| 1395 | + '.nav-pills .nav-link.active' => array( 'b' ), |
|
| 1396 | + '.nav-pills .show>.nav-link' => array( 'b' ), |
|
| 1397 | + '.page-link' => array( 'c' ), |
|
| 1398 | + '.page-item.active .page-link' => array( |
|
| 1399 | + 'b', |
|
| 1400 | + 'o' |
|
| 1401 | + ), |
|
| 1402 | + '.progress-bar' => array( 'b' ), |
|
| 1403 | + '.list-group-item.active' => array( |
|
| 1404 | + 'b', |
|
| 1405 | + 'o' |
|
| 1406 | + ), |
|
| 1407 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
| 1408 | + ); |
|
| 1409 | + } |
|
| 1410 | 1410 | |
| 1411 | 1411 | |
| 1412 | 1412 | |
| 1413 | 1413 | // link |
| 1414 | - if ( $type === 'primary' ) { |
|
| 1415 | - $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }'; |
|
| 1416 | - $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).'; }'; |
|
| 1417 | - $output .= $prefix . ' .navbar { --bs-nav-link-hover-color: '.esc_attr($color_code).'; --bs-navbar-hover-color: '.esc_attr($color_code).'; --bs-navbar-active-color: '.esc_attr($color_code).'; }'; |
|
| 1414 | + if ( $type === 'primary' ) { |
|
| 1415 | + $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }'; |
|
| 1416 | + $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).'; }'; |
|
| 1417 | + $output .= $prefix . ' .navbar { --bs-nav-link-hover-color: '.esc_attr($color_code).'; --bs-navbar-hover-color: '.esc_attr($color_code).'; --bs-navbar-active-color: '.esc_attr($color_code).'; }'; |
|
| 1418 | 1418 | |
| 1419 | - $output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}'; |
|
| 1420 | - $output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}'; |
|
| 1419 | + $output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}'; |
|
| 1420 | + $output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}'; |
|
| 1421 | 1421 | |
| 1422 | 1422 | // dropdown |
| 1423 | - $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}'; |
|
| 1423 | + $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}'; |
|
| 1424 | 1424 | |
| 1425 | 1425 | // pagination |
| 1426 | - $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}'; |
|
| 1426 | + $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}'; |
|
| 1427 | 1427 | |
| 1428 | - } |
|
| 1428 | + } |
|
| 1429 | 1429 | |
| 1430 | - $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}'; |
|
| 1430 | + $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}'; |
|
| 1431 | 1431 | |
| 1432 | - // buttons |
|
| 1433 | - $output .= $prefix . ' .btn-'.esc_attr($type).'{'; |
|
| 1434 | - $output .= ' |
|
| 1432 | + // buttons |
|
| 1433 | + $output .= $prefix . ' .btn-'.esc_attr($type).'{'; |
|
| 1434 | + $output .= ' |
|
| 1435 | 1435 | --bs-btn-bg: '.esc_attr($color_code).'; |
| 1436 | 1436 | --bs-btn-border-color: '.esc_attr($color_code).'; |
| 1437 | 1437 | --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
@@ -1449,11 +1449,11 @@ discard block |
||
| 1449 | 1449 | // --bs-btn-active-color: #fff; |
| 1450 | 1450 | // --bs-btn-disabled-color: #fff; |
| 1451 | 1451 | // '; |
| 1452 | - $output .= '}'; |
|
| 1452 | + $output .= '}'; |
|
| 1453 | 1453 | |
| 1454 | - // buttons outline |
|
| 1455 | - $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{'; |
|
| 1456 | - $output .= ' |
|
| 1454 | + // buttons outline |
|
| 1455 | + $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{'; |
|
| 1456 | + $output .= ' |
|
| 1457 | 1457 | --bs-btn-border-color: '.esc_attr($color_code).'; |
| 1458 | 1458 | --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
| 1459 | 1459 | --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
@@ -1470,37 +1470,37 @@ discard block |
||
| 1470 | 1470 | // --bs-btn-active-color: #fff; |
| 1471 | 1471 | // --bs-btn-disabled-color: #fff; |
| 1472 | 1472 | // '; |
| 1473 | - $output .= '}'; |
|
| 1473 | + $output .= '}'; |
|
| 1474 | 1474 | |
| 1475 | 1475 | |
| 1476 | 1476 | // button hover |
| 1477 | - $output .= $prefix . ' .btn-'.esc_attr($type).':hover{'; |
|
| 1478 | - $output .= ' |
|
| 1477 | + $output .= $prefix . ' .btn-'.esc_attr($type).':hover{'; |
|
| 1478 | + $output .= ' |
|
| 1479 | 1479 | box-shadow: 0 0.25rem 0.25rem 0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb), .1), 0 0.375rem 0.75rem -0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb) , .4); |
| 1480 | 1480 | } |
| 1481 | 1481 | '; |
| 1482 | 1482 | |
| 1483 | 1483 | |
| 1484 | - if ( $aui_bs5 ) { |
|
| 1484 | + if ( $aui_bs5 ) { |
|
| 1485 | 1485 | // $output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }'; |
| 1486 | - $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }'; |
|
| 1487 | - $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
| 1488 | - } |
|
| 1486 | + $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }'; |
|
| 1487 | + $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
| 1488 | + } |
|
| 1489 | 1489 | |
| 1490 | 1490 | |
| 1491 | - if ( $is_custom ) { |
|
| 1491 | + if ( $is_custom ) { |
|
| 1492 | 1492 | |
| 1493 | 1493 | // echo '###'.$type;exit; |
| 1494 | 1494 | |
| 1495 | - // build rules into each type |
|
| 1496 | - foreach($selectors as $selector => $types){ |
|
| 1497 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 1498 | - $types = array_combine($types,$types); |
|
| 1499 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1500 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1501 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1502 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1503 | - } |
|
| 1495 | + // build rules into each type |
|
| 1496 | + foreach($selectors as $selector => $types){ |
|
| 1497 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 1498 | + $types = array_combine($types,$types); |
|
| 1499 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 1500 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 1501 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 1502 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 1503 | + } |
|
| 1504 | 1504 | |
| 1505 | 1505 | // // build rules into each type |
| 1506 | 1506 | // foreach($important_selectors as $selector => $types){ |
@@ -1512,67 +1512,67 @@ discard block |
||
| 1512 | 1512 | // if(isset($types['f'])){$fill_i[] = $selector;} |
| 1513 | 1513 | // } |
| 1514 | 1514 | |
| 1515 | - // add any color rules |
|
| 1516 | - if(!empty($color)){ |
|
| 1517 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1518 | - } |
|
| 1519 | - if(!empty($color_i)){ |
|
| 1520 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1521 | - } |
|
| 1515 | + // add any color rules |
|
| 1516 | + if(!empty($color)){ |
|
| 1517 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1518 | + } |
|
| 1519 | + if(!empty($color_i)){ |
|
| 1520 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1521 | + } |
|
| 1522 | 1522 | |
| 1523 | - // add any background color rules |
|
| 1524 | - if(!empty($background)){ |
|
| 1525 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1526 | - } |
|
| 1527 | - if(!empty($background_i)){ |
|
| 1528 | - $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1523 | + // add any background color rules |
|
| 1524 | + if(!empty($background)){ |
|
| 1525 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1526 | + } |
|
| 1527 | + if(!empty($background_i)){ |
|
| 1528 | + $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1529 | 1529 | // $output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} "; |
| 1530 | - } |
|
| 1530 | + } |
|
| 1531 | 1531 | |
| 1532 | - // add any border color rules |
|
| 1533 | - if(!empty($border)){ |
|
| 1534 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1535 | - } |
|
| 1536 | - if(!empty($border_i)){ |
|
| 1537 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1538 | - } |
|
| 1532 | + // add any border color rules |
|
| 1533 | + if(!empty($border)){ |
|
| 1534 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1535 | + } |
|
| 1536 | + if(!empty($border_i)){ |
|
| 1537 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1538 | + } |
|
| 1539 | 1539 | |
| 1540 | - // add any fill color rules |
|
| 1541 | - if(!empty($fill)){ |
|
| 1542 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1543 | - } |
|
| 1544 | - if(!empty($fill_i)){ |
|
| 1545 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1546 | - } |
|
| 1540 | + // add any fill color rules |
|
| 1541 | + if(!empty($fill)){ |
|
| 1542 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1543 | + } |
|
| 1544 | + if(!empty($fill_i)){ |
|
| 1545 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1546 | + } |
|
| 1547 | 1547 | |
| 1548 | - } |
|
| 1548 | + } |
|
| 1549 | 1549 | |
| 1550 | 1550 | |
| 1551 | 1551 | |
| 1552 | 1552 | |
| 1553 | - $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : ''; |
|
| 1554 | - // darken |
|
| 1555 | - $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1556 | - $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1557 | - $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1558 | - $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
| 1553 | + $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : ''; |
|
| 1554 | + // darken |
|
| 1555 | + $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1556 | + $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1557 | + $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1558 | + $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
| 1559 | 1559 | |
| 1560 | - // lighten |
|
| 1561 | - $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1560 | + // lighten |
|
| 1561 | + $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1562 | 1562 | |
| 1563 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1564 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1563 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1564 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 1565 | 1565 | |
| 1566 | 1566 | |
| 1567 | - // button states |
|
| 1568 | - $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
| 1569 | - $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1567 | + // button states |
|
| 1568 | + $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
| 1569 | + $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1570 | 1570 | // $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
| 1571 | - $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1572 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1573 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1571 | + $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1572 | + $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1573 | + $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1574 | 1574 | |
| 1575 | - // text |
|
| 1575 | + // text |
|
| 1576 | 1576 | // $output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} "; |
| 1577 | 1577 | |
| 1578 | 1578 | |
@@ -1587,773 +1587,773 @@ discard block |
||
| 1587 | 1587 | // $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
| 1588 | 1588 | // } |
| 1589 | 1589 | |
| 1590 | - // alerts |
|
| 1591 | - if ( $aui_bs5 ) { |
|
| 1590 | + // alerts |
|
| 1591 | + if ( $aui_bs5 ) { |
|
| 1592 | 1592 | // $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} "; |
| 1593 | - $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} "; |
|
| 1594 | - } |
|
| 1595 | - |
|
| 1596 | - return $output; |
|
| 1597 | - } |
|
| 1598 | - |
|
| 1599 | - /** |
|
| 1600 | - * Build the CSS to overwrite a bootstrap color variable. |
|
| 1601 | - * |
|
| 1602 | - * @param $type |
|
| 1603 | - * @param $color_code |
|
| 1604 | - * @param $compatibility |
|
| 1605 | - * |
|
| 1606 | - * @return string |
|
| 1607 | - */ |
|
| 1608 | - public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){ |
|
| 1593 | + $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} "; |
|
| 1594 | + } |
|
| 1595 | + |
|
| 1596 | + return $output; |
|
| 1597 | + } |
|
| 1598 | + |
|
| 1599 | + /** |
|
| 1600 | + * Build the CSS to overwrite a bootstrap color variable. |
|
| 1601 | + * |
|
| 1602 | + * @param $type |
|
| 1603 | + * @param $color_code |
|
| 1604 | + * @param $compatibility |
|
| 1605 | + * |
|
| 1606 | + * @return string |
|
| 1607 | + */ |
|
| 1608 | + public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){ |
|
| 1609 | 1609 | global $aui_bs5; |
| 1610 | 1610 | |
| 1611 | - $is_var = false; |
|
| 1612 | - if(!$color_code){return '';} |
|
| 1613 | - if(strpos($color_code, 'var') !== false){ |
|
| 1614 | - //if(!sanitize_hex_color($color_code)){ |
|
| 1615 | - $color_code = esc_attr($color_code); |
|
| 1616 | - $is_var = true; |
|
| 1611 | + $is_var = false; |
|
| 1612 | + if(!$color_code){return '';} |
|
| 1613 | + if(strpos($color_code, 'var') !== false){ |
|
| 1614 | + //if(!sanitize_hex_color($color_code)){ |
|
| 1615 | + $color_code = esc_attr($color_code); |
|
| 1616 | + $is_var = true; |
|
| 1617 | 1617 | // $color_code = "rgba($color_code, 0.5)"; |
| 1618 | 1618 | // echo '###1'.$color_code.'###';//exit; |
| 1619 | - } |
|
| 1619 | + } |
|
| 1620 | 1620 | |
| 1621 | 1621 | // echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit; |
| 1622 | 1622 | |
| 1623 | - if(!$color_code){return '';} |
|
| 1623 | + if(!$color_code){return '';} |
|
| 1624 | 1624 | |
| 1625 | 1625 | $rgb = self::hex_to_rgb($hex); |
| 1626 | 1626 | |
| 1627 | - if($compatibility===true || $compatibility===1){ |
|
| 1628 | - $compatibility = '.bsui'; |
|
| 1629 | - }elseif(!$compatibility){ |
|
| 1630 | - $compatibility = ''; |
|
| 1631 | - }else{ |
|
| 1632 | - $compatibility = esc_attr($compatibility); |
|
| 1633 | - } |
|
| 1627 | + if($compatibility===true || $compatibility===1){ |
|
| 1628 | + $compatibility = '.bsui'; |
|
| 1629 | + }elseif(!$compatibility){ |
|
| 1630 | + $compatibility = ''; |
|
| 1631 | + }else{ |
|
| 1632 | + $compatibility = esc_attr($compatibility); |
|
| 1633 | + } |
|
| 1634 | 1634 | |
| 1635 | 1635 | |
| 1636 | 1636 | |
| 1637 | 1637 | // echo '####'.$color_code;exit; |
| 1638 | 1638 | |
| 1639 | - $type = sanitize_html_class($type); |
|
| 1640 | - |
|
| 1641 | - /** |
|
| 1642 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1643 | - */ |
|
| 1644 | - $selectors = array( |
|
| 1645 | - ".btn-{$type}" => array( 'b', 'o' ), |
|
| 1646 | - ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
| 1647 | - ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
| 1648 | - ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
| 1649 | - ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
| 1650 | - ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
| 1651 | - ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
| 1652 | - ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
| 1653 | - ".badge-{$type}" => array( 'b' ), |
|
| 1654 | - ".alert-{$type}" => array( 'b', 'o' ), |
|
| 1655 | - ".bg-{$type}" => array( 'b', 'f' ), |
|
| 1656 | - ".btn-link.btn-{$type}" => array( 'c' ), |
|
| 1657 | - ); |
|
| 1658 | - |
|
| 1659 | - if ( $aui_bs5 ) { |
|
| 1639 | + $type = sanitize_html_class($type); |
|
| 1640 | + |
|
| 1641 | + /** |
|
| 1642 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1643 | + */ |
|
| 1644 | + $selectors = array( |
|
| 1645 | + ".btn-{$type}" => array( 'b', 'o' ), |
|
| 1646 | + ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
| 1647 | + ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
| 1648 | + ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
| 1649 | + ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
| 1650 | + ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
| 1651 | + ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
| 1652 | + ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
| 1653 | + ".badge-{$type}" => array( 'b' ), |
|
| 1654 | + ".alert-{$type}" => array( 'b', 'o' ), |
|
| 1655 | + ".bg-{$type}" => array( 'b', 'f' ), |
|
| 1656 | + ".btn-link.btn-{$type}" => array( 'c' ), |
|
| 1657 | + ); |
|
| 1658 | + |
|
| 1659 | + if ( $aui_bs5 ) { |
|
| 1660 | 1660 | unset($selectors[".alert-{$type}" ]); |
| 1661 | - } |
|
| 1662 | - |
|
| 1663 | - if ( $type == 'primary' ) { |
|
| 1664 | - $selectors = $selectors + array( |
|
| 1665 | - 'a' => array( 'c' ), |
|
| 1666 | - '.btn-link' => array( 'c' ), |
|
| 1667 | - '.dropdown-item.active' => array( 'b' ), |
|
| 1668 | - '.custom-control-input:checked~.custom-control-label::before' => array( |
|
| 1669 | - 'b', |
|
| 1670 | - 'o' |
|
| 1671 | - ), |
|
| 1672 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
| 1673 | - 'b', |
|
| 1674 | - 'o' |
|
| 1675 | - ), |
|
| 1676 | - '.nav-pills .nav-link.active' => array( 'b' ), |
|
| 1677 | - '.nav-pills .show>.nav-link' => array( 'b' ), |
|
| 1678 | - '.page-link' => array( 'c' ), |
|
| 1679 | - '.page-item.active .page-link' => array( |
|
| 1680 | - 'b', |
|
| 1681 | - 'o' |
|
| 1682 | - ), |
|
| 1683 | - '.progress-bar' => array( 'b' ), |
|
| 1684 | - '.list-group-item.active' => array( |
|
| 1685 | - 'b', |
|
| 1686 | - 'o' |
|
| 1687 | - ), |
|
| 1688 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
| 1661 | + } |
|
| 1662 | + |
|
| 1663 | + if ( $type == 'primary' ) { |
|
| 1664 | + $selectors = $selectors + array( |
|
| 1665 | + 'a' => array( 'c' ), |
|
| 1666 | + '.btn-link' => array( 'c' ), |
|
| 1667 | + '.dropdown-item.active' => array( 'b' ), |
|
| 1668 | + '.custom-control-input:checked~.custom-control-label::before' => array( |
|
| 1669 | + 'b', |
|
| 1670 | + 'o' |
|
| 1671 | + ), |
|
| 1672 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
| 1673 | + 'b', |
|
| 1674 | + 'o' |
|
| 1675 | + ), |
|
| 1676 | + '.nav-pills .nav-link.active' => array( 'b' ), |
|
| 1677 | + '.nav-pills .show>.nav-link' => array( 'b' ), |
|
| 1678 | + '.page-link' => array( 'c' ), |
|
| 1679 | + '.page-item.active .page-link' => array( |
|
| 1680 | + 'b', |
|
| 1681 | + 'o' |
|
| 1682 | + ), |
|
| 1683 | + '.progress-bar' => array( 'b' ), |
|
| 1684 | + '.list-group-item.active' => array( |
|
| 1685 | + 'b', |
|
| 1686 | + 'o' |
|
| 1687 | + ), |
|
| 1688 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
| 1689 | 1689 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 1690 | 1690 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 1691 | 1691 | // '.custom-range::-ms-thumb' => array('b'), |
| 1692 | - ); |
|
| 1693 | - } |
|
| 1694 | - |
|
| 1695 | - $important_selectors = array( |
|
| 1696 | - ".bg-{$type}" => array('b','f'), |
|
| 1697 | - ".border-{$type}" => array('o'), |
|
| 1698 | - ".text-{$type}" => array('c'), |
|
| 1699 | - ); |
|
| 1700 | - |
|
| 1701 | - $color = array(); |
|
| 1702 | - $color_i = array(); |
|
| 1703 | - $background = array(); |
|
| 1704 | - $background_i = array(); |
|
| 1705 | - $border = array(); |
|
| 1706 | - $border_i = array(); |
|
| 1707 | - $fill = array(); |
|
| 1708 | - $fill_i = array(); |
|
| 1709 | - |
|
| 1710 | - $output = ''; |
|
| 1711 | - |
|
| 1712 | - if ( $aui_bs5 ) { |
|
| 1692 | + ); |
|
| 1693 | + } |
|
| 1694 | + |
|
| 1695 | + $important_selectors = array( |
|
| 1696 | + ".bg-{$type}" => array('b','f'), |
|
| 1697 | + ".border-{$type}" => array('o'), |
|
| 1698 | + ".text-{$type}" => array('c'), |
|
| 1699 | + ); |
|
| 1700 | + |
|
| 1701 | + $color = array(); |
|
| 1702 | + $color_i = array(); |
|
| 1703 | + $background = array(); |
|
| 1704 | + $background_i = array(); |
|
| 1705 | + $border = array(); |
|
| 1706 | + $border_i = array(); |
|
| 1707 | + $fill = array(); |
|
| 1708 | + $fill_i = array(); |
|
| 1709 | + |
|
| 1710 | + $output = ''; |
|
| 1711 | + |
|
| 1712 | + if ( $aui_bs5 ) { |
|
| 1713 | 1713 | // $output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }'; |
| 1714 | - $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
| 1715 | - } |
|
| 1716 | - |
|
| 1717 | - // build rules into each type |
|
| 1718 | - foreach($selectors as $selector => $types){ |
|
| 1719 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 1720 | - $types = array_combine($types,$types); |
|
| 1721 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1722 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1723 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1724 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1725 | - } |
|
| 1726 | - |
|
| 1727 | - // build rules into each type |
|
| 1728 | - foreach($important_selectors as $selector => $types){ |
|
| 1729 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 1730 | - $types = array_combine($types,$types); |
|
| 1731 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1732 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1733 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1734 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1735 | - } |
|
| 1736 | - |
|
| 1737 | - // add any color rules |
|
| 1738 | - if(!empty($color)){ |
|
| 1739 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1740 | - } |
|
| 1741 | - if(!empty($color_i)){ |
|
| 1742 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1743 | - } |
|
| 1744 | - |
|
| 1745 | - // add any background color rules |
|
| 1746 | - if(!empty($background)){ |
|
| 1747 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1748 | - } |
|
| 1749 | - if(!empty($background_i)){ |
|
| 1750 | - $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1714 | + $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
| 1715 | + } |
|
| 1716 | + |
|
| 1717 | + // build rules into each type |
|
| 1718 | + foreach($selectors as $selector => $types){ |
|
| 1719 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 1720 | + $types = array_combine($types,$types); |
|
| 1721 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 1722 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 1723 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 1724 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 1725 | + } |
|
| 1726 | + |
|
| 1727 | + // build rules into each type |
|
| 1728 | + foreach($important_selectors as $selector => $types){ |
|
| 1729 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 1730 | + $types = array_combine($types,$types); |
|
| 1731 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1732 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1733 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1734 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1735 | + } |
|
| 1736 | + |
|
| 1737 | + // add any color rules |
|
| 1738 | + if(!empty($color)){ |
|
| 1739 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1740 | + } |
|
| 1741 | + if(!empty($color_i)){ |
|
| 1742 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1743 | + } |
|
| 1744 | + |
|
| 1745 | + // add any background color rules |
|
| 1746 | + if(!empty($background)){ |
|
| 1747 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1748 | + } |
|
| 1749 | + if(!empty($background_i)){ |
|
| 1750 | + $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1751 | 1751 | // $output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} "; |
| 1752 | - } |
|
| 1752 | + } |
|
| 1753 | 1753 | |
| 1754 | - // add any border color rules |
|
| 1755 | - if(!empty($border)){ |
|
| 1756 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1757 | - } |
|
| 1758 | - if(!empty($border_i)){ |
|
| 1759 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1760 | - } |
|
| 1754 | + // add any border color rules |
|
| 1755 | + if(!empty($border)){ |
|
| 1756 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1757 | + } |
|
| 1758 | + if(!empty($border_i)){ |
|
| 1759 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1760 | + } |
|
| 1761 | 1761 | |
| 1762 | - // add any fill color rules |
|
| 1763 | - if(!empty($fill)){ |
|
| 1764 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1765 | - } |
|
| 1766 | - if(!empty($fill_i)){ |
|
| 1767 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1768 | - } |
|
| 1762 | + // add any fill color rules |
|
| 1763 | + if(!empty($fill)){ |
|
| 1764 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1765 | + } |
|
| 1766 | + if(!empty($fill_i)){ |
|
| 1767 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1768 | + } |
|
| 1769 | 1769 | |
| 1770 | 1770 | |
| 1771 | - $prefix = $compatibility ? $compatibility . " " : ""; |
|
| 1771 | + $prefix = $compatibility ? $compatibility . " " : ""; |
|
| 1772 | 1772 | |
| 1773 | - $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : ''; |
|
| 1774 | - // darken |
|
| 1775 | - $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1776 | - $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1777 | - $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1778 | - $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
| 1773 | + $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : ''; |
|
| 1774 | + // darken |
|
| 1775 | + $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1776 | + $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1777 | + $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1778 | + $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
| 1779 | 1779 | |
| 1780 | - // lighten |
|
| 1781 | - $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1780 | + // lighten |
|
| 1781 | + $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1782 | 1782 | |
| 1783 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1784 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1783 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1784 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 1785 | 1785 | |
| 1786 | 1786 | |
| 1787 | - // button states |
|
| 1788 | - $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
| 1789 | - $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1787 | + // button states |
|
| 1788 | + $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
| 1789 | + $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1790 | 1790 | // $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
| 1791 | - $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1792 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1793 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1791 | + $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1792 | + $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1793 | + $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1794 | 1794 | |
| 1795 | - if ( $type == 'primary' ) { |
|
| 1796 | - // dropdown's |
|
| 1797 | - $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1795 | + if ( $type == 'primary' ) { |
|
| 1796 | + // dropdown's |
|
| 1797 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1798 | 1798 | |
| 1799 | - // input states |
|
| 1800 | - $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1799 | + // input states |
|
| 1800 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1801 | 1801 | |
| 1802 | - // page link |
|
| 1803 | - $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1804 | - } |
|
| 1802 | + // page link |
|
| 1803 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1804 | + } |
|
| 1805 | 1805 | |
| 1806 | 1806 | // alerts |
| 1807 | - if ( $aui_bs5 ) { |
|
| 1807 | + if ( $aui_bs5 ) { |
|
| 1808 | 1808 | // $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} "; |
| 1809 | - $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} "; |
|
| 1810 | - } |
|
| 1811 | - |
|
| 1812 | - return $output; |
|
| 1813 | - } |
|
| 1814 | - |
|
| 1815 | - /** |
|
| 1816 | - * |
|
| 1817 | - * @deprecated 0.1.76 Use css_overwrite() |
|
| 1818 | - * |
|
| 1819 | - * @param $color_code |
|
| 1820 | - * @param $compatibility |
|
| 1821 | - * @param $use_variable |
|
| 1822 | - * |
|
| 1823 | - * @return string |
|
| 1824 | - */ |
|
| 1825 | - public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
| 1826 | - |
|
| 1827 | - if(!$use_variable){ |
|
| 1828 | - $color_code = sanitize_hex_color($color_code); |
|
| 1829 | - if(!$color_code){return '';} |
|
| 1830 | - } |
|
| 1831 | - |
|
| 1832 | - /** |
|
| 1833 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1834 | - */ |
|
| 1835 | - $selectors = array( |
|
| 1836 | - 'a' => array('c'), |
|
| 1837 | - '.btn-primary' => array('b','o'), |
|
| 1838 | - '.btn-primary.disabled' => array('b','o'), |
|
| 1839 | - '.btn-primary:disabled' => array('b','o'), |
|
| 1840 | - '.btn-outline-primary' => array('c','o'), |
|
| 1841 | - '.btn-outline-primary:hover' => array('b','o'), |
|
| 1842 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1843 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1844 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 1845 | - '.btn-link' => array('c'), |
|
| 1846 | - '.dropdown-item.active' => array('b'), |
|
| 1847 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 1848 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 1809 | + $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} "; |
|
| 1810 | + } |
|
| 1811 | + |
|
| 1812 | + return $output; |
|
| 1813 | + } |
|
| 1814 | + |
|
| 1815 | + /** |
|
| 1816 | + * |
|
| 1817 | + * @deprecated 0.1.76 Use css_overwrite() |
|
| 1818 | + * |
|
| 1819 | + * @param $color_code |
|
| 1820 | + * @param $compatibility |
|
| 1821 | + * @param $use_variable |
|
| 1822 | + * |
|
| 1823 | + * @return string |
|
| 1824 | + */ |
|
| 1825 | + public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
| 1826 | + |
|
| 1827 | + if(!$use_variable){ |
|
| 1828 | + $color_code = sanitize_hex_color($color_code); |
|
| 1829 | + if(!$color_code){return '';} |
|
| 1830 | + } |
|
| 1831 | + |
|
| 1832 | + /** |
|
| 1833 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1834 | + */ |
|
| 1835 | + $selectors = array( |
|
| 1836 | + 'a' => array('c'), |
|
| 1837 | + '.btn-primary' => array('b','o'), |
|
| 1838 | + '.btn-primary.disabled' => array('b','o'), |
|
| 1839 | + '.btn-primary:disabled' => array('b','o'), |
|
| 1840 | + '.btn-outline-primary' => array('c','o'), |
|
| 1841 | + '.btn-outline-primary:hover' => array('b','o'), |
|
| 1842 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1843 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1844 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 1845 | + '.btn-link' => array('c'), |
|
| 1846 | + '.dropdown-item.active' => array('b'), |
|
| 1847 | + '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 1848 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 1849 | 1849 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 1850 | 1850 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 1851 | 1851 | // '.custom-range::-ms-thumb' => array('b'), |
| 1852 | - '.nav-pills .nav-link.active' => array('b'), |
|
| 1853 | - '.nav-pills .show>.nav-link' => array('b'), |
|
| 1854 | - '.page-link' => array('c'), |
|
| 1855 | - '.page-item.active .page-link' => array('b','o'), |
|
| 1856 | - '.badge-primary' => array('b'), |
|
| 1857 | - '.alert-primary' => array('b','o'), |
|
| 1858 | - '.progress-bar' => array('b'), |
|
| 1859 | - '.list-group-item.active' => array('b','o'), |
|
| 1860 | - '.bg-primary' => array('b','f'), |
|
| 1861 | - '.btn-link.btn-primary' => array('c'), |
|
| 1862 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 1863 | - ); |
|
| 1864 | - |
|
| 1865 | - $important_selectors = array( |
|
| 1866 | - '.bg-primary' => array('b','f'), |
|
| 1867 | - '.border-primary' => array('o'), |
|
| 1868 | - '.text-primary' => array('c'), |
|
| 1869 | - ); |
|
| 1870 | - |
|
| 1871 | - $color = array(); |
|
| 1872 | - $color_i = array(); |
|
| 1873 | - $background = array(); |
|
| 1874 | - $background_i = array(); |
|
| 1875 | - $border = array(); |
|
| 1876 | - $border_i = array(); |
|
| 1877 | - $fill = array(); |
|
| 1878 | - $fill_i = array(); |
|
| 1879 | - |
|
| 1880 | - $output = ''; |
|
| 1881 | - |
|
| 1882 | - // build rules into each type |
|
| 1883 | - foreach($selectors as $selector => $types){ |
|
| 1884 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1885 | - $types = array_combine($types,$types); |
|
| 1886 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1887 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1888 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1889 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1890 | - } |
|
| 1891 | - |
|
| 1892 | - // build rules into each type |
|
| 1893 | - foreach($important_selectors as $selector => $types){ |
|
| 1894 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1895 | - $types = array_combine($types,$types); |
|
| 1896 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1897 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1898 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1899 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1900 | - } |
|
| 1901 | - |
|
| 1902 | - // add any color rules |
|
| 1903 | - if(!empty($color)){ |
|
| 1904 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1905 | - } |
|
| 1906 | - if(!empty($color_i)){ |
|
| 1907 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1908 | - } |
|
| 1909 | - |
|
| 1910 | - // add any background color rules |
|
| 1911 | - if(!empty($background)){ |
|
| 1912 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1913 | - } |
|
| 1914 | - if(!empty($background_i)){ |
|
| 1915 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1916 | - } |
|
| 1917 | - |
|
| 1918 | - // add any border color rules |
|
| 1919 | - if(!empty($border)){ |
|
| 1920 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1921 | - } |
|
| 1922 | - if(!empty($border_i)){ |
|
| 1923 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1924 | - } |
|
| 1925 | - |
|
| 1926 | - // add any fill color rules |
|
| 1927 | - if(!empty($fill)){ |
|
| 1928 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1929 | - } |
|
| 1930 | - if(!empty($fill_i)){ |
|
| 1931 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1932 | - } |
|
| 1933 | - |
|
| 1934 | - |
|
| 1935 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 1936 | - |
|
| 1937 | - // darken |
|
| 1938 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1939 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1940 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1941 | - |
|
| 1942 | - // lighten |
|
| 1943 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1944 | - |
|
| 1945 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1946 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1947 | - |
|
| 1948 | - |
|
| 1949 | - // button states |
|
| 1950 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1951 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1952 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1953 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1954 | - |
|
| 1955 | - |
|
| 1956 | - // dropdown's |
|
| 1957 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1958 | - |
|
| 1959 | - |
|
| 1960 | - // input states |
|
| 1961 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1962 | - |
|
| 1963 | - // page link |
|
| 1964 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1965 | - |
|
| 1966 | - return $output; |
|
| 1967 | - } |
|
| 1968 | - |
|
| 1969 | - /** |
|
| 1970 | - * |
|
| 1971 | - * @deprecated 0.1.76 Use css_overwrite() |
|
| 1972 | - * |
|
| 1973 | - * @param $color_code |
|
| 1974 | - * @param $compatibility |
|
| 1975 | - * |
|
| 1976 | - * @return string |
|
| 1977 | - */ |
|
| 1978 | - public static function css_secondary($color_code,$compatibility){; |
|
| 1979 | - $color_code = sanitize_hex_color($color_code); |
|
| 1980 | - if(!$color_code){return '';} |
|
| 1981 | - /** |
|
| 1982 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1983 | - */ |
|
| 1984 | - $selectors = array( |
|
| 1985 | - '.btn-secondary' => array('b','o'), |
|
| 1986 | - '.btn-secondary.disabled' => array('b','o'), |
|
| 1987 | - '.btn-secondary:disabled' => array('b','o'), |
|
| 1988 | - '.btn-outline-secondary' => array('c','o'), |
|
| 1989 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
| 1990 | - '.btn-outline-secondary.disabled' => array('c'), |
|
| 1991 | - '.btn-outline-secondary:disabled' => array('c'), |
|
| 1992 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1993 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1994 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 1995 | - '.badge-secondary' => array('b'), |
|
| 1996 | - '.alert-secondary' => array('b','o'), |
|
| 1997 | - '.btn-link.btn-secondary' => array('c'), |
|
| 1998 | - ); |
|
| 1999 | - |
|
| 2000 | - $important_selectors = array( |
|
| 2001 | - '.bg-secondary' => array('b','f'), |
|
| 2002 | - '.border-secondary' => array('o'), |
|
| 2003 | - '.text-secondary' => array('c'), |
|
| 2004 | - ); |
|
| 2005 | - |
|
| 2006 | - $color = array(); |
|
| 2007 | - $color_i = array(); |
|
| 2008 | - $background = array(); |
|
| 2009 | - $background_i = array(); |
|
| 2010 | - $border = array(); |
|
| 2011 | - $border_i = array(); |
|
| 2012 | - $fill = array(); |
|
| 2013 | - $fill_i = array(); |
|
| 2014 | - |
|
| 2015 | - $output = ''; |
|
| 2016 | - |
|
| 2017 | - // build rules into each type |
|
| 2018 | - foreach($selectors as $selector => $types){ |
|
| 2019 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2020 | - $types = array_combine($types,$types); |
|
| 2021 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 2022 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 2023 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 2024 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 2025 | - } |
|
| 2026 | - |
|
| 2027 | - // build rules into each type |
|
| 2028 | - foreach($important_selectors as $selector => $types){ |
|
| 2029 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2030 | - $types = array_combine($types,$types); |
|
| 2031 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2032 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2033 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2034 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2035 | - } |
|
| 2036 | - |
|
| 2037 | - // add any color rules |
|
| 2038 | - if(!empty($color)){ |
|
| 2039 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2040 | - } |
|
| 2041 | - if(!empty($color_i)){ |
|
| 2042 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2043 | - } |
|
| 2044 | - |
|
| 2045 | - // add any background color rules |
|
| 2046 | - if(!empty($background)){ |
|
| 2047 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2048 | - } |
|
| 2049 | - if(!empty($background_i)){ |
|
| 2050 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2051 | - } |
|
| 2052 | - |
|
| 2053 | - // add any border color rules |
|
| 2054 | - if(!empty($border)){ |
|
| 2055 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2056 | - } |
|
| 2057 | - if(!empty($border_i)){ |
|
| 2058 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2059 | - } |
|
| 2060 | - |
|
| 2061 | - // add any fill color rules |
|
| 2062 | - if(!empty($fill)){ |
|
| 2063 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2064 | - } |
|
| 2065 | - if(!empty($fill_i)){ |
|
| 2066 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2067 | - } |
|
| 2068 | - |
|
| 2069 | - |
|
| 2070 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 2071 | - |
|
| 2072 | - // darken |
|
| 2073 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2074 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2075 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2076 | - |
|
| 2077 | - // lighten |
|
| 2078 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2079 | - |
|
| 2080 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2081 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 2082 | - |
|
| 2083 | - |
|
| 2084 | - // button states |
|
| 2085 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2086 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2087 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2088 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2089 | - |
|
| 2090 | - |
|
| 2091 | - return $output; |
|
| 2092 | - } |
|
| 2093 | - |
|
| 2094 | - /** |
|
| 2095 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 2096 | - * |
|
| 2097 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 2098 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 2099 | - * |
|
| 2100 | - * @return string |
|
| 2101 | - */ |
|
| 2102 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 2103 | - $hexCode = ltrim($hexCode, '#'); |
|
| 2104 | - |
|
| 2105 | - if (strlen($hexCode) == 3) { |
|
| 2106 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 2107 | - } |
|
| 2108 | - |
|
| 2109 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 2110 | - |
|
| 2111 | - foreach ($hexCode as & $color) { |
|
| 2112 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 2113 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 2114 | - |
|
| 2115 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 2116 | - } |
|
| 2117 | - |
|
| 2118 | - return '#' . implode($hexCode); |
|
| 2119 | - } |
|
| 2120 | - |
|
| 2121 | - /** |
|
| 2122 | - * Check if we should display examples. |
|
| 2123 | - */ |
|
| 2124 | - public function maybe_show_examples(){ |
|
| 2125 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 2126 | - echo "<head>"; |
|
| 2127 | - wp_head(); |
|
| 2128 | - echo "</head>"; |
|
| 2129 | - echo "<body>"; |
|
| 2130 | - echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2131 | - echo "</body>"; |
|
| 2132 | - exit; |
|
| 2133 | - } |
|
| 2134 | - } |
|
| 2135 | - |
|
| 2136 | - /** |
|
| 2137 | - * Get developer examples. |
|
| 2138 | - * |
|
| 2139 | - * @return string |
|
| 2140 | - */ |
|
| 2141 | - public function get_examples(){ |
|
| 2142 | - $output = ''; |
|
| 2143 | - |
|
| 2144 | - |
|
| 2145 | - // open form |
|
| 2146 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 2147 | - |
|
| 2148 | - // input example |
|
| 2149 | - $output .= aui()->input(array( |
|
| 2150 | - 'type' => 'text', |
|
| 2151 | - 'id' => 'text-example', |
|
| 2152 | - 'name' => 'text-example', |
|
| 2153 | - 'placeholder' => 'text placeholder', |
|
| 2154 | - 'title' => 'Text input example', |
|
| 2155 | - 'value' => '', |
|
| 2156 | - 'required' => false, |
|
| 2157 | - 'help_text' => 'help text', |
|
| 2158 | - 'label' => 'Text input example label' |
|
| 2159 | - )); |
|
| 2160 | - |
|
| 2161 | - // input example |
|
| 2162 | - $output .= aui()->input(array( |
|
| 2163 | - 'type' => 'url', |
|
| 2164 | - 'id' => 'text-example2', |
|
| 2165 | - 'name' => 'text-example', |
|
| 2166 | - 'placeholder' => 'url placeholder', |
|
| 2167 | - 'title' => 'Text input example', |
|
| 2168 | - 'value' => '', |
|
| 2169 | - 'required' => false, |
|
| 2170 | - 'help_text' => 'help text', |
|
| 2171 | - 'label' => 'Text input example label' |
|
| 2172 | - )); |
|
| 2173 | - |
|
| 2174 | - // checkbox example |
|
| 2175 | - $output .= aui()->input(array( |
|
| 2176 | - 'type' => 'checkbox', |
|
| 2177 | - 'id' => 'checkbox-example', |
|
| 2178 | - 'name' => 'checkbox-example', |
|
| 2179 | - 'placeholder' => 'checkbox-example', |
|
| 2180 | - 'title' => 'Checkbox example', |
|
| 2181 | - 'value' => '1', |
|
| 2182 | - 'checked' => true, |
|
| 2183 | - 'required' => false, |
|
| 2184 | - 'help_text' => 'help text', |
|
| 2185 | - 'label' => 'Checkbox checked' |
|
| 2186 | - )); |
|
| 2187 | - |
|
| 2188 | - // checkbox example |
|
| 2189 | - $output .= aui()->input(array( |
|
| 2190 | - 'type' => 'checkbox', |
|
| 2191 | - 'id' => 'checkbox-example2', |
|
| 2192 | - 'name' => 'checkbox-example2', |
|
| 2193 | - 'placeholder' => 'checkbox-example', |
|
| 2194 | - 'title' => 'Checkbox example', |
|
| 2195 | - 'value' => '1', |
|
| 2196 | - 'checked' => false, |
|
| 2197 | - 'required' => false, |
|
| 2198 | - 'help_text' => 'help text', |
|
| 2199 | - 'label' => 'Checkbox un-checked' |
|
| 2200 | - )); |
|
| 2201 | - |
|
| 2202 | - // switch example |
|
| 2203 | - $output .= aui()->input(array( |
|
| 2204 | - 'type' => 'checkbox', |
|
| 2205 | - 'id' => 'switch-example', |
|
| 2206 | - 'name' => 'switch-example', |
|
| 2207 | - 'placeholder' => 'checkbox-example', |
|
| 2208 | - 'title' => 'Switch example', |
|
| 2209 | - 'value' => '1', |
|
| 2210 | - 'checked' => true, |
|
| 2211 | - 'switch' => true, |
|
| 2212 | - 'required' => false, |
|
| 2213 | - 'help_text' => 'help text', |
|
| 2214 | - 'label' => 'Switch on' |
|
| 2215 | - )); |
|
| 2216 | - |
|
| 2217 | - // switch example |
|
| 2218 | - $output .= aui()->input(array( |
|
| 2219 | - 'type' => 'checkbox', |
|
| 2220 | - 'id' => 'switch-example2', |
|
| 2221 | - 'name' => 'switch-example2', |
|
| 2222 | - 'placeholder' => 'checkbox-example', |
|
| 2223 | - 'title' => 'Switch example', |
|
| 2224 | - 'value' => '1', |
|
| 2225 | - 'checked' => false, |
|
| 2226 | - 'switch' => true, |
|
| 2227 | - 'required' => false, |
|
| 2228 | - 'help_text' => 'help text', |
|
| 2229 | - 'label' => 'Switch off' |
|
| 2230 | - )); |
|
| 2231 | - |
|
| 2232 | - // close form |
|
| 2233 | - $output .= "</form>"; |
|
| 2234 | - |
|
| 2235 | - return $output; |
|
| 2236 | - } |
|
| 2237 | - |
|
| 2238 | - /** |
|
| 2239 | - * Calendar params. |
|
| 2240 | - * |
|
| 2241 | - * @since 0.1.44 |
|
| 2242 | - * |
|
| 2243 | - * @return array Calendar params. |
|
| 2244 | - */ |
|
| 2245 | - public static function calendar_params() { |
|
| 2246 | - $params = array( |
|
| 2247 | - 'month_long_1' => __( 'January', 'ayecode-connect' ), |
|
| 2248 | - 'month_long_2' => __( 'February', 'ayecode-connect' ), |
|
| 2249 | - 'month_long_3' => __( 'March', 'ayecode-connect' ), |
|
| 2250 | - 'month_long_4' => __( 'April', 'ayecode-connect' ), |
|
| 2251 | - 'month_long_5' => __( 'May', 'ayecode-connect' ), |
|
| 2252 | - 'month_long_6' => __( 'June', 'ayecode-connect' ), |
|
| 2253 | - 'month_long_7' => __( 'July', 'ayecode-connect' ), |
|
| 2254 | - 'month_long_8' => __( 'August', 'ayecode-connect' ), |
|
| 2255 | - 'month_long_9' => __( 'September', 'ayecode-connect' ), |
|
| 2256 | - 'month_long_10' => __( 'October', 'ayecode-connect' ), |
|
| 2257 | - 'month_long_11' => __( 'November', 'ayecode-connect' ), |
|
| 2258 | - 'month_long_12' => __( 'December', 'ayecode-connect' ), |
|
| 2259 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ), |
|
| 2260 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ), |
|
| 2261 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ), |
|
| 2262 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ), |
|
| 2263 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ), |
|
| 2264 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ), |
|
| 2265 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ), |
|
| 2266 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ), |
|
| 2267 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ), |
|
| 2268 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ), |
|
| 2269 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ), |
|
| 2270 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ), |
|
| 2271 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ), |
|
| 2272 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ), |
|
| 2273 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ), |
|
| 2274 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ), |
|
| 2275 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ), |
|
| 2276 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ), |
|
| 2277 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ), |
|
| 2278 | - 'day_s2_1' => __( 'Su', 'ayecode-connect' ), |
|
| 2279 | - 'day_s2_2' => __( 'Mo', 'ayecode-connect' ), |
|
| 2280 | - 'day_s2_3' => __( 'Tu', 'ayecode-connect' ), |
|
| 2281 | - 'day_s2_4' => __( 'We', 'ayecode-connect' ), |
|
| 2282 | - 'day_s2_5' => __( 'Th', 'ayecode-connect' ), |
|
| 2283 | - 'day_s2_6' => __( 'Fr', 'ayecode-connect' ), |
|
| 2284 | - 'day_s2_7' => __( 'Sa', 'ayecode-connect' ), |
|
| 2285 | - 'day_s3_1' => __( 'Sun', 'ayecode-connect' ), |
|
| 2286 | - 'day_s3_2' => __( 'Mon', 'ayecode-connect' ), |
|
| 2287 | - 'day_s3_3' => __( 'Tue', 'ayecode-connect' ), |
|
| 2288 | - 'day_s3_4' => __( 'Wed', 'ayecode-connect' ), |
|
| 2289 | - 'day_s3_5' => __( 'Thu', 'ayecode-connect' ), |
|
| 2290 | - 'day_s3_6' => __( 'Fri', 'ayecode-connect' ), |
|
| 2291 | - 'day_s3_7' => __( 'Sat', 'ayecode-connect' ), |
|
| 2292 | - 'day_s5_1' => __( 'Sunday', 'ayecode-connect' ), |
|
| 2293 | - 'day_s5_2' => __( 'Monday', 'ayecode-connect' ), |
|
| 2294 | - 'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ), |
|
| 2295 | - 'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ), |
|
| 2296 | - 'day_s5_5' => __( 'Thursday', 'ayecode-connect' ), |
|
| 2297 | - 'day_s5_6' => __( 'Friday', 'ayecode-connect' ), |
|
| 2298 | - 'day_s5_7' => __( 'Saturday', 'ayecode-connect' ), |
|
| 2299 | - 'am_lower' => __( 'am', 'ayecode-connect' ), |
|
| 2300 | - 'pm_lower' => __( 'pm', 'ayecode-connect' ), |
|
| 2301 | - 'am_upper' => __( 'AM', 'ayecode-connect' ), |
|
| 2302 | - 'pm_upper' => __( 'PM', 'ayecode-connect' ), |
|
| 2303 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 2304 | - 'time_24hr' => false, |
|
| 2305 | - 'year' => __( 'Year', 'ayecode-connect' ), |
|
| 2306 | - 'hour' => __( 'Hour', 'ayecode-connect' ), |
|
| 2307 | - 'minute' => __( 'Minute', 'ayecode-connect' ), |
|
| 2308 | - 'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ), |
|
| 2309 | - 'rangeSeparator' => __( ' to ', 'ayecode-connect' ), |
|
| 2310 | - 'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ), |
|
| 2311 | - 'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' ) |
|
| 2312 | - ); |
|
| 2313 | - |
|
| 2314 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 2315 | - } |
|
| 2316 | - |
|
| 2317 | - /** |
|
| 2318 | - * Flatpickr calendar localize. |
|
| 2319 | - * |
|
| 2320 | - * @since 0.1.44 |
|
| 2321 | - * |
|
| 2322 | - * @return string Calendar locale. |
|
| 2323 | - */ |
|
| 2324 | - public static function flatpickr_locale() { |
|
| 2325 | - $params = self::calendar_params(); |
|
| 2326 | - |
|
| 2327 | - if ( is_string( $params ) ) { |
|
| 2328 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 2329 | - } else { |
|
| 2330 | - foreach ( (array) $params as $key => $value ) { |
|
| 2331 | - if ( ! is_scalar( $value ) ) { |
|
| 2332 | - continue; |
|
| 2333 | - } |
|
| 2334 | - |
|
| 2335 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2336 | - } |
|
| 2337 | - } |
|
| 1852 | + '.nav-pills .nav-link.active' => array('b'), |
|
| 1853 | + '.nav-pills .show>.nav-link' => array('b'), |
|
| 1854 | + '.page-link' => array('c'), |
|
| 1855 | + '.page-item.active .page-link' => array('b','o'), |
|
| 1856 | + '.badge-primary' => array('b'), |
|
| 1857 | + '.alert-primary' => array('b','o'), |
|
| 1858 | + '.progress-bar' => array('b'), |
|
| 1859 | + '.list-group-item.active' => array('b','o'), |
|
| 1860 | + '.bg-primary' => array('b','f'), |
|
| 1861 | + '.btn-link.btn-primary' => array('c'), |
|
| 1862 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 1863 | + ); |
|
| 1864 | + |
|
| 1865 | + $important_selectors = array( |
|
| 1866 | + '.bg-primary' => array('b','f'), |
|
| 1867 | + '.border-primary' => array('o'), |
|
| 1868 | + '.text-primary' => array('c'), |
|
| 1869 | + ); |
|
| 1870 | + |
|
| 1871 | + $color = array(); |
|
| 1872 | + $color_i = array(); |
|
| 1873 | + $background = array(); |
|
| 1874 | + $background_i = array(); |
|
| 1875 | + $border = array(); |
|
| 1876 | + $border_i = array(); |
|
| 1877 | + $fill = array(); |
|
| 1878 | + $fill_i = array(); |
|
| 1879 | + |
|
| 1880 | + $output = ''; |
|
| 1881 | + |
|
| 1882 | + // build rules into each type |
|
| 1883 | + foreach($selectors as $selector => $types){ |
|
| 1884 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1885 | + $types = array_combine($types,$types); |
|
| 1886 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 1887 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 1888 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 1889 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 1890 | + } |
|
| 1891 | + |
|
| 1892 | + // build rules into each type |
|
| 1893 | + foreach($important_selectors as $selector => $types){ |
|
| 1894 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1895 | + $types = array_combine($types,$types); |
|
| 1896 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1897 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1898 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1899 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1900 | + } |
|
| 1901 | + |
|
| 1902 | + // add any color rules |
|
| 1903 | + if(!empty($color)){ |
|
| 1904 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1905 | + } |
|
| 1906 | + if(!empty($color_i)){ |
|
| 1907 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1908 | + } |
|
| 1909 | + |
|
| 1910 | + // add any background color rules |
|
| 1911 | + if(!empty($background)){ |
|
| 1912 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1913 | + } |
|
| 1914 | + if(!empty($background_i)){ |
|
| 1915 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1916 | + } |
|
| 1917 | + |
|
| 1918 | + // add any border color rules |
|
| 1919 | + if(!empty($border)){ |
|
| 1920 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1921 | + } |
|
| 1922 | + if(!empty($border_i)){ |
|
| 1923 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1924 | + } |
|
| 1925 | + |
|
| 1926 | + // add any fill color rules |
|
| 1927 | + if(!empty($fill)){ |
|
| 1928 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1929 | + } |
|
| 1930 | + if(!empty($fill_i)){ |
|
| 1931 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1932 | + } |
|
| 1933 | + |
|
| 1934 | + |
|
| 1935 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 1936 | + |
|
| 1937 | + // darken |
|
| 1938 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1939 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1940 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1941 | + |
|
| 1942 | + // lighten |
|
| 1943 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1944 | + |
|
| 1945 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1946 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 1947 | + |
|
| 2338 | 1948 | |
| 2339 | - $day_s3 = array(); |
|
| 2340 | - $day_s5 = array(); |
|
| 1949 | + // button states |
|
| 1950 | + $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1951 | + $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1952 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1953 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2341 | 1954 | |
| 2342 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 2343 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2344 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2345 | - } |
|
| 2346 | 1955 | |
| 2347 | - $month_s = array(); |
|
| 2348 | - $month_long = array(); |
|
| 1956 | + // dropdown's |
|
| 1957 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 2349 | 1958 | |
| 2350 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 2351 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2352 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2353 | - } |
|
| 2354 | 1959 | |
| 2355 | - ob_start(); |
|
| 2356 | - if ( 0 ) { ?><script><?php } ?> |
|
| 1960 | + // input states |
|
| 1961 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1962 | + |
|
| 1963 | + // page link |
|
| 1964 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1965 | + |
|
| 1966 | + return $output; |
|
| 1967 | + } |
|
| 1968 | + |
|
| 1969 | + /** |
|
| 1970 | + * |
|
| 1971 | + * @deprecated 0.1.76 Use css_overwrite() |
|
| 1972 | + * |
|
| 1973 | + * @param $color_code |
|
| 1974 | + * @param $compatibility |
|
| 1975 | + * |
|
| 1976 | + * @return string |
|
| 1977 | + */ |
|
| 1978 | + public static function css_secondary($color_code,$compatibility){; |
|
| 1979 | + $color_code = sanitize_hex_color($color_code); |
|
| 1980 | + if(!$color_code){return '';} |
|
| 1981 | + /** |
|
| 1982 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1983 | + */ |
|
| 1984 | + $selectors = array( |
|
| 1985 | + '.btn-secondary' => array('b','o'), |
|
| 1986 | + '.btn-secondary.disabled' => array('b','o'), |
|
| 1987 | + '.btn-secondary:disabled' => array('b','o'), |
|
| 1988 | + '.btn-outline-secondary' => array('c','o'), |
|
| 1989 | + '.btn-outline-secondary:hover' => array('b','o'), |
|
| 1990 | + '.btn-outline-secondary.disabled' => array('c'), |
|
| 1991 | + '.btn-outline-secondary:disabled' => array('c'), |
|
| 1992 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1993 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1994 | + '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 1995 | + '.badge-secondary' => array('b'), |
|
| 1996 | + '.alert-secondary' => array('b','o'), |
|
| 1997 | + '.btn-link.btn-secondary' => array('c'), |
|
| 1998 | + ); |
|
| 1999 | + |
|
| 2000 | + $important_selectors = array( |
|
| 2001 | + '.bg-secondary' => array('b','f'), |
|
| 2002 | + '.border-secondary' => array('o'), |
|
| 2003 | + '.text-secondary' => array('c'), |
|
| 2004 | + ); |
|
| 2005 | + |
|
| 2006 | + $color = array(); |
|
| 2007 | + $color_i = array(); |
|
| 2008 | + $background = array(); |
|
| 2009 | + $background_i = array(); |
|
| 2010 | + $border = array(); |
|
| 2011 | + $border_i = array(); |
|
| 2012 | + $fill = array(); |
|
| 2013 | + $fill_i = array(); |
|
| 2014 | + |
|
| 2015 | + $output = ''; |
|
| 2016 | + |
|
| 2017 | + // build rules into each type |
|
| 2018 | + foreach($selectors as $selector => $types){ |
|
| 2019 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2020 | + $types = array_combine($types,$types); |
|
| 2021 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 2022 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 2023 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 2024 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 2025 | + } |
|
| 2026 | + |
|
| 2027 | + // build rules into each type |
|
| 2028 | + foreach($important_selectors as $selector => $types){ |
|
| 2029 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2030 | + $types = array_combine($types,$types); |
|
| 2031 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2032 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2033 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2034 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2035 | + } |
|
| 2036 | + |
|
| 2037 | + // add any color rules |
|
| 2038 | + if(!empty($color)){ |
|
| 2039 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2040 | + } |
|
| 2041 | + if(!empty($color_i)){ |
|
| 2042 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2043 | + } |
|
| 2044 | + |
|
| 2045 | + // add any background color rules |
|
| 2046 | + if(!empty($background)){ |
|
| 2047 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2048 | + } |
|
| 2049 | + if(!empty($background_i)){ |
|
| 2050 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2051 | + } |
|
| 2052 | + |
|
| 2053 | + // add any border color rules |
|
| 2054 | + if(!empty($border)){ |
|
| 2055 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2056 | + } |
|
| 2057 | + if(!empty($border_i)){ |
|
| 2058 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2059 | + } |
|
| 2060 | + |
|
| 2061 | + // add any fill color rules |
|
| 2062 | + if(!empty($fill)){ |
|
| 2063 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2064 | + } |
|
| 2065 | + if(!empty($fill_i)){ |
|
| 2066 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2067 | + } |
|
| 2068 | + |
|
| 2069 | + |
|
| 2070 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 2071 | + |
|
| 2072 | + // darken |
|
| 2073 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2074 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2075 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2076 | + |
|
| 2077 | + // lighten |
|
| 2078 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2079 | + |
|
| 2080 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2081 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 2082 | + |
|
| 2083 | + |
|
| 2084 | + // button states |
|
| 2085 | + $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2086 | + $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2087 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2088 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2089 | + |
|
| 2090 | + |
|
| 2091 | + return $output; |
|
| 2092 | + } |
|
| 2093 | + |
|
| 2094 | + /** |
|
| 2095 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 2096 | + * |
|
| 2097 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 2098 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 2099 | + * |
|
| 2100 | + * @return string |
|
| 2101 | + */ |
|
| 2102 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 2103 | + $hexCode = ltrim($hexCode, '#'); |
|
| 2104 | + |
|
| 2105 | + if (strlen($hexCode) == 3) { |
|
| 2106 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 2107 | + } |
|
| 2108 | + |
|
| 2109 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 2110 | + |
|
| 2111 | + foreach ($hexCode as & $color) { |
|
| 2112 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 2113 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 2114 | + |
|
| 2115 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 2116 | + } |
|
| 2117 | + |
|
| 2118 | + return '#' . implode($hexCode); |
|
| 2119 | + } |
|
| 2120 | + |
|
| 2121 | + /** |
|
| 2122 | + * Check if we should display examples. |
|
| 2123 | + */ |
|
| 2124 | + public function maybe_show_examples(){ |
|
| 2125 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 2126 | + echo "<head>"; |
|
| 2127 | + wp_head(); |
|
| 2128 | + echo "</head>"; |
|
| 2129 | + echo "<body>"; |
|
| 2130 | + echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2131 | + echo "</body>"; |
|
| 2132 | + exit; |
|
| 2133 | + } |
|
| 2134 | + } |
|
| 2135 | + |
|
| 2136 | + /** |
|
| 2137 | + * Get developer examples. |
|
| 2138 | + * |
|
| 2139 | + * @return string |
|
| 2140 | + */ |
|
| 2141 | + public function get_examples(){ |
|
| 2142 | + $output = ''; |
|
| 2143 | + |
|
| 2144 | + |
|
| 2145 | + // open form |
|
| 2146 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 2147 | + |
|
| 2148 | + // input example |
|
| 2149 | + $output .= aui()->input(array( |
|
| 2150 | + 'type' => 'text', |
|
| 2151 | + 'id' => 'text-example', |
|
| 2152 | + 'name' => 'text-example', |
|
| 2153 | + 'placeholder' => 'text placeholder', |
|
| 2154 | + 'title' => 'Text input example', |
|
| 2155 | + 'value' => '', |
|
| 2156 | + 'required' => false, |
|
| 2157 | + 'help_text' => 'help text', |
|
| 2158 | + 'label' => 'Text input example label' |
|
| 2159 | + )); |
|
| 2160 | + |
|
| 2161 | + // input example |
|
| 2162 | + $output .= aui()->input(array( |
|
| 2163 | + 'type' => 'url', |
|
| 2164 | + 'id' => 'text-example2', |
|
| 2165 | + 'name' => 'text-example', |
|
| 2166 | + 'placeholder' => 'url placeholder', |
|
| 2167 | + 'title' => 'Text input example', |
|
| 2168 | + 'value' => '', |
|
| 2169 | + 'required' => false, |
|
| 2170 | + 'help_text' => 'help text', |
|
| 2171 | + 'label' => 'Text input example label' |
|
| 2172 | + )); |
|
| 2173 | + |
|
| 2174 | + // checkbox example |
|
| 2175 | + $output .= aui()->input(array( |
|
| 2176 | + 'type' => 'checkbox', |
|
| 2177 | + 'id' => 'checkbox-example', |
|
| 2178 | + 'name' => 'checkbox-example', |
|
| 2179 | + 'placeholder' => 'checkbox-example', |
|
| 2180 | + 'title' => 'Checkbox example', |
|
| 2181 | + 'value' => '1', |
|
| 2182 | + 'checked' => true, |
|
| 2183 | + 'required' => false, |
|
| 2184 | + 'help_text' => 'help text', |
|
| 2185 | + 'label' => 'Checkbox checked' |
|
| 2186 | + )); |
|
| 2187 | + |
|
| 2188 | + // checkbox example |
|
| 2189 | + $output .= aui()->input(array( |
|
| 2190 | + 'type' => 'checkbox', |
|
| 2191 | + 'id' => 'checkbox-example2', |
|
| 2192 | + 'name' => 'checkbox-example2', |
|
| 2193 | + 'placeholder' => 'checkbox-example', |
|
| 2194 | + 'title' => 'Checkbox example', |
|
| 2195 | + 'value' => '1', |
|
| 2196 | + 'checked' => false, |
|
| 2197 | + 'required' => false, |
|
| 2198 | + 'help_text' => 'help text', |
|
| 2199 | + 'label' => 'Checkbox un-checked' |
|
| 2200 | + )); |
|
| 2201 | + |
|
| 2202 | + // switch example |
|
| 2203 | + $output .= aui()->input(array( |
|
| 2204 | + 'type' => 'checkbox', |
|
| 2205 | + 'id' => 'switch-example', |
|
| 2206 | + 'name' => 'switch-example', |
|
| 2207 | + 'placeholder' => 'checkbox-example', |
|
| 2208 | + 'title' => 'Switch example', |
|
| 2209 | + 'value' => '1', |
|
| 2210 | + 'checked' => true, |
|
| 2211 | + 'switch' => true, |
|
| 2212 | + 'required' => false, |
|
| 2213 | + 'help_text' => 'help text', |
|
| 2214 | + 'label' => 'Switch on' |
|
| 2215 | + )); |
|
| 2216 | + |
|
| 2217 | + // switch example |
|
| 2218 | + $output .= aui()->input(array( |
|
| 2219 | + 'type' => 'checkbox', |
|
| 2220 | + 'id' => 'switch-example2', |
|
| 2221 | + 'name' => 'switch-example2', |
|
| 2222 | + 'placeholder' => 'checkbox-example', |
|
| 2223 | + 'title' => 'Switch example', |
|
| 2224 | + 'value' => '1', |
|
| 2225 | + 'checked' => false, |
|
| 2226 | + 'switch' => true, |
|
| 2227 | + 'required' => false, |
|
| 2228 | + 'help_text' => 'help text', |
|
| 2229 | + 'label' => 'Switch off' |
|
| 2230 | + )); |
|
| 2231 | + |
|
| 2232 | + // close form |
|
| 2233 | + $output .= "</form>"; |
|
| 2234 | + |
|
| 2235 | + return $output; |
|
| 2236 | + } |
|
| 2237 | + |
|
| 2238 | + /** |
|
| 2239 | + * Calendar params. |
|
| 2240 | + * |
|
| 2241 | + * @since 0.1.44 |
|
| 2242 | + * |
|
| 2243 | + * @return array Calendar params. |
|
| 2244 | + */ |
|
| 2245 | + public static function calendar_params() { |
|
| 2246 | + $params = array( |
|
| 2247 | + 'month_long_1' => __( 'January', 'ayecode-connect' ), |
|
| 2248 | + 'month_long_2' => __( 'February', 'ayecode-connect' ), |
|
| 2249 | + 'month_long_3' => __( 'March', 'ayecode-connect' ), |
|
| 2250 | + 'month_long_4' => __( 'April', 'ayecode-connect' ), |
|
| 2251 | + 'month_long_5' => __( 'May', 'ayecode-connect' ), |
|
| 2252 | + 'month_long_6' => __( 'June', 'ayecode-connect' ), |
|
| 2253 | + 'month_long_7' => __( 'July', 'ayecode-connect' ), |
|
| 2254 | + 'month_long_8' => __( 'August', 'ayecode-connect' ), |
|
| 2255 | + 'month_long_9' => __( 'September', 'ayecode-connect' ), |
|
| 2256 | + 'month_long_10' => __( 'October', 'ayecode-connect' ), |
|
| 2257 | + 'month_long_11' => __( 'November', 'ayecode-connect' ), |
|
| 2258 | + 'month_long_12' => __( 'December', 'ayecode-connect' ), |
|
| 2259 | + 'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ), |
|
| 2260 | + 'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ), |
|
| 2261 | + 'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ), |
|
| 2262 | + 'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ), |
|
| 2263 | + 'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ), |
|
| 2264 | + 'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ), |
|
| 2265 | + 'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ), |
|
| 2266 | + 'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ), |
|
| 2267 | + 'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ), |
|
| 2268 | + 'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ), |
|
| 2269 | + 'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ), |
|
| 2270 | + 'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ), |
|
| 2271 | + 'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ), |
|
| 2272 | + 'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ), |
|
| 2273 | + 'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ), |
|
| 2274 | + 'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ), |
|
| 2275 | + 'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ), |
|
| 2276 | + 'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ), |
|
| 2277 | + 'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ), |
|
| 2278 | + 'day_s2_1' => __( 'Su', 'ayecode-connect' ), |
|
| 2279 | + 'day_s2_2' => __( 'Mo', 'ayecode-connect' ), |
|
| 2280 | + 'day_s2_3' => __( 'Tu', 'ayecode-connect' ), |
|
| 2281 | + 'day_s2_4' => __( 'We', 'ayecode-connect' ), |
|
| 2282 | + 'day_s2_5' => __( 'Th', 'ayecode-connect' ), |
|
| 2283 | + 'day_s2_6' => __( 'Fr', 'ayecode-connect' ), |
|
| 2284 | + 'day_s2_7' => __( 'Sa', 'ayecode-connect' ), |
|
| 2285 | + 'day_s3_1' => __( 'Sun', 'ayecode-connect' ), |
|
| 2286 | + 'day_s3_2' => __( 'Mon', 'ayecode-connect' ), |
|
| 2287 | + 'day_s3_3' => __( 'Tue', 'ayecode-connect' ), |
|
| 2288 | + 'day_s3_4' => __( 'Wed', 'ayecode-connect' ), |
|
| 2289 | + 'day_s3_5' => __( 'Thu', 'ayecode-connect' ), |
|
| 2290 | + 'day_s3_6' => __( 'Fri', 'ayecode-connect' ), |
|
| 2291 | + 'day_s3_7' => __( 'Sat', 'ayecode-connect' ), |
|
| 2292 | + 'day_s5_1' => __( 'Sunday', 'ayecode-connect' ), |
|
| 2293 | + 'day_s5_2' => __( 'Monday', 'ayecode-connect' ), |
|
| 2294 | + 'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ), |
|
| 2295 | + 'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ), |
|
| 2296 | + 'day_s5_5' => __( 'Thursday', 'ayecode-connect' ), |
|
| 2297 | + 'day_s5_6' => __( 'Friday', 'ayecode-connect' ), |
|
| 2298 | + 'day_s5_7' => __( 'Saturday', 'ayecode-connect' ), |
|
| 2299 | + 'am_lower' => __( 'am', 'ayecode-connect' ), |
|
| 2300 | + 'pm_lower' => __( 'pm', 'ayecode-connect' ), |
|
| 2301 | + 'am_upper' => __( 'AM', 'ayecode-connect' ), |
|
| 2302 | + 'pm_upper' => __( 'PM', 'ayecode-connect' ), |
|
| 2303 | + 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 2304 | + 'time_24hr' => false, |
|
| 2305 | + 'year' => __( 'Year', 'ayecode-connect' ), |
|
| 2306 | + 'hour' => __( 'Hour', 'ayecode-connect' ), |
|
| 2307 | + 'minute' => __( 'Minute', 'ayecode-connect' ), |
|
| 2308 | + 'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ), |
|
| 2309 | + 'rangeSeparator' => __( ' to ', 'ayecode-connect' ), |
|
| 2310 | + 'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ), |
|
| 2311 | + 'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' ) |
|
| 2312 | + ); |
|
| 2313 | + |
|
| 2314 | + return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 2315 | + } |
|
| 2316 | + |
|
| 2317 | + /** |
|
| 2318 | + * Flatpickr calendar localize. |
|
| 2319 | + * |
|
| 2320 | + * @since 0.1.44 |
|
| 2321 | + * |
|
| 2322 | + * @return string Calendar locale. |
|
| 2323 | + */ |
|
| 2324 | + public static function flatpickr_locale() { |
|
| 2325 | + $params = self::calendar_params(); |
|
| 2326 | + |
|
| 2327 | + if ( is_string( $params ) ) { |
|
| 2328 | + $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 2329 | + } else { |
|
| 2330 | + foreach ( (array) $params as $key => $value ) { |
|
| 2331 | + if ( ! is_scalar( $value ) ) { |
|
| 2332 | + continue; |
|
| 2333 | + } |
|
| 2334 | + |
|
| 2335 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2336 | + } |
|
| 2337 | + } |
|
| 2338 | + |
|
| 2339 | + $day_s3 = array(); |
|
| 2340 | + $day_s5 = array(); |
|
| 2341 | + |
|
| 2342 | + for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 2343 | + $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2344 | + $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2345 | + } |
|
| 2346 | + |
|
| 2347 | + $month_s = array(); |
|
| 2348 | + $month_long = array(); |
|
| 2349 | + |
|
| 2350 | + for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 2351 | + $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2352 | + $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2353 | + } |
|
| 2354 | + |
|
| 2355 | + ob_start(); |
|
| 2356 | + if ( 0 ) { ?><script><?php } ?> |
|
| 2357 | 2357 | { |
| 2358 | 2358 | weekdays: { |
| 2359 | 2359 | shorthand: ['<?php echo implode( "','", $day_s3 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'], |
@@ -2392,189 +2392,189 @@ discard block |
||
| 2392 | 2392 | } |
| 2393 | 2393 | <?php if ( 0 ) { ?></script><?php } ?> |
| 2394 | 2394 | <?php |
| 2395 | - $locale = ob_get_clean(); |
|
| 2396 | - |
|
| 2397 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2398 | - } |
|
| 2399 | - |
|
| 2400 | - /** |
|
| 2401 | - * Select2 JS params. |
|
| 2402 | - * |
|
| 2403 | - * @since 0.1.44 |
|
| 2404 | - * |
|
| 2405 | - * @return array Select2 JS params. |
|
| 2406 | - */ |
|
| 2407 | - public static function select2_params() { |
|
| 2408 | - $params = array( |
|
| 2409 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'ayecode-connect' ), |
|
| 2410 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ), |
|
| 2411 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ), |
|
| 2412 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ), |
|
| 2413 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ), |
|
| 2414 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ), |
|
| 2415 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ), |
|
| 2416 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ), |
|
| 2417 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ), |
|
| 2418 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'ayecode-connect' ), |
|
| 2419 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'ayecode-connect' ) |
|
| 2420 | - ); |
|
| 2421 | - |
|
| 2422 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2423 | - } |
|
| 2424 | - |
|
| 2425 | - /** |
|
| 2426 | - * Select2 JS localize. |
|
| 2427 | - * |
|
| 2428 | - * @since 0.1.44 |
|
| 2429 | - * |
|
| 2430 | - * @return string Select2 JS locale. |
|
| 2431 | - */ |
|
| 2432 | - public static function select2_locale() { |
|
| 2433 | - $params = self::select2_params(); |
|
| 2434 | - |
|
| 2435 | - foreach ( (array) $params as $key => $value ) { |
|
| 2436 | - if ( ! is_scalar( $value ) ) { |
|
| 2437 | - continue; |
|
| 2438 | - } |
|
| 2395 | + $locale = ob_get_clean(); |
|
| 2439 | 2396 | |
| 2440 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2441 | - } |
|
| 2442 | - |
|
| 2443 | - $locale = json_encode( $params ); |
|
| 2444 | - |
|
| 2445 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2446 | - } |
|
| 2447 | - |
|
| 2448 | - /** |
|
| 2449 | - * Time ago JS localize. |
|
| 2450 | - * |
|
| 2451 | - * @since 0.1.47 |
|
| 2452 | - * |
|
| 2453 | - * @return string Time ago JS locale. |
|
| 2454 | - */ |
|
| 2455 | - public static function timeago_locale() { |
|
| 2456 | - $params = array( |
|
| 2457 | - 'prefix_ago' => '', |
|
| 2458 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ), |
|
| 2459 | - 'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ', |
|
| 2460 | - 'suffix_after' => '', |
|
| 2461 | - 'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ), |
|
| 2462 | - 'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ), |
|
| 2463 | - 'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ), |
|
| 2464 | - 'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ), |
|
| 2465 | - 'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ), |
|
| 2466 | - 'day' => _x( 'a day', 'time ago', 'ayecode-connect' ), |
|
| 2467 | - 'days' => _x( '%d days', 'time ago', 'ayecode-connect' ), |
|
| 2468 | - 'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ), |
|
| 2469 | - 'months' => _x( '%d months', 'time ago', 'ayecode-connect' ), |
|
| 2470 | - 'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ), |
|
| 2471 | - 'years' => _x( '%d years', 'time ago', 'ayecode-connect' ), |
|
| 2472 | - ); |
|
| 2473 | - |
|
| 2474 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2475 | - |
|
| 2476 | - foreach ( (array) $params as $key => $value ) { |
|
| 2477 | - if ( ! is_scalar( $value ) ) { |
|
| 2478 | - continue; |
|
| 2479 | - } |
|
| 2397 | + return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2398 | + } |
|
| 2399 | + |
|
| 2400 | + /** |
|
| 2401 | + * Select2 JS params. |
|
| 2402 | + * |
|
| 2403 | + * @since 0.1.44 |
|
| 2404 | + * |
|
| 2405 | + * @return array Select2 JS params. |
|
| 2406 | + */ |
|
| 2407 | + public static function select2_params() { |
|
| 2408 | + $params = array( |
|
| 2409 | + 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'ayecode-connect' ), |
|
| 2410 | + 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ), |
|
| 2411 | + 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ), |
|
| 2412 | + 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ), |
|
| 2413 | + 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ), |
|
| 2414 | + 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ), |
|
| 2415 | + 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ), |
|
| 2416 | + 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ), |
|
| 2417 | + 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ), |
|
| 2418 | + 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'ayecode-connect' ), |
|
| 2419 | + 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'ayecode-connect' ) |
|
| 2420 | + ); |
|
| 2421 | + |
|
| 2422 | + return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2423 | + } |
|
| 2424 | + |
|
| 2425 | + /** |
|
| 2426 | + * Select2 JS localize. |
|
| 2427 | + * |
|
| 2428 | + * @since 0.1.44 |
|
| 2429 | + * |
|
| 2430 | + * @return string Select2 JS locale. |
|
| 2431 | + */ |
|
| 2432 | + public static function select2_locale() { |
|
| 2433 | + $params = self::select2_params(); |
|
| 2434 | + |
|
| 2435 | + foreach ( (array) $params as $key => $value ) { |
|
| 2436 | + if ( ! is_scalar( $value ) ) { |
|
| 2437 | + continue; |
|
| 2438 | + } |
|
| 2439 | + |
|
| 2440 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2441 | + } |
|
| 2442 | + |
|
| 2443 | + $locale = json_encode( $params ); |
|
| 2444 | + |
|
| 2445 | + return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2446 | + } |
|
| 2447 | + |
|
| 2448 | + /** |
|
| 2449 | + * Time ago JS localize. |
|
| 2450 | + * |
|
| 2451 | + * @since 0.1.47 |
|
| 2452 | + * |
|
| 2453 | + * @return string Time ago JS locale. |
|
| 2454 | + */ |
|
| 2455 | + public static function timeago_locale() { |
|
| 2456 | + $params = array( |
|
| 2457 | + 'prefix_ago' => '', |
|
| 2458 | + 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ), |
|
| 2459 | + 'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ', |
|
| 2460 | + 'suffix_after' => '', |
|
| 2461 | + 'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ), |
|
| 2462 | + 'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ), |
|
| 2463 | + 'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ), |
|
| 2464 | + 'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ), |
|
| 2465 | + 'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ), |
|
| 2466 | + 'day' => _x( 'a day', 'time ago', 'ayecode-connect' ), |
|
| 2467 | + 'days' => _x( '%d days', 'time ago', 'ayecode-connect' ), |
|
| 2468 | + 'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ), |
|
| 2469 | + 'months' => _x( '%d months', 'time ago', 'ayecode-connect' ), |
|
| 2470 | + 'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ), |
|
| 2471 | + 'years' => _x( '%d years', 'time ago', 'ayecode-connect' ), |
|
| 2472 | + ); |
|
| 2473 | + |
|
| 2474 | + $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2475 | + |
|
| 2476 | + foreach ( (array) $params as $key => $value ) { |
|
| 2477 | + if ( ! is_scalar( $value ) ) { |
|
| 2478 | + continue; |
|
| 2479 | + } |
|
| 2480 | + |
|
| 2481 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2482 | + } |
|
| 2480 | 2483 | |
| 2481 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2482 | - } |
|
| 2483 | - |
|
| 2484 | - $locale = json_encode( $params ); |
|
| 2485 | - |
|
| 2486 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2487 | - } |
|
| 2488 | - |
|
| 2489 | - /** |
|
| 2490 | - * JavaScript Minifier |
|
| 2491 | - * |
|
| 2492 | - * @param $input |
|
| 2493 | - * |
|
| 2494 | - * @return mixed |
|
| 2495 | - */ |
|
| 2496 | - public static function minify_js($input) { |
|
| 2497 | - if(trim($input) === "") return $input; |
|
| 2498 | - return preg_replace( |
|
| 2499 | - array( |
|
| 2500 | - // Remove comment(s) |
|
| 2501 | - '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
| 2502 | - // Remove white-space(s) outside the string and regex |
|
| 2503 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
| 2504 | - // Remove the last semicolon |
|
| 2505 | - '#;+\}#', |
|
| 2506 | - // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
| 2507 | - '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
| 2508 | - // --ibid. From `foo['bar']` to `foo.bar` |
|
| 2509 | - '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
| 2510 | - ), |
|
| 2511 | - array( |
|
| 2512 | - '$1', |
|
| 2513 | - '$1$2', |
|
| 2514 | - '}', |
|
| 2515 | - '$1$3', |
|
| 2516 | - '$1.$3' |
|
| 2517 | - ), |
|
| 2518 | - $input); |
|
| 2519 | - } |
|
| 2520 | - |
|
| 2521 | - /** |
|
| 2522 | - * Minify CSS |
|
| 2523 | - * |
|
| 2524 | - * @param $input |
|
| 2525 | - * |
|
| 2526 | - * @return mixed |
|
| 2527 | - */ |
|
| 2528 | - public static function minify_css($input) { |
|
| 2529 | - if(trim($input) === "") return $input; |
|
| 2530 | - return preg_replace( |
|
| 2531 | - array( |
|
| 2532 | - // Remove comment(s) |
|
| 2533 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
| 2534 | - // Remove unused white-space(s) |
|
| 2535 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
| 2536 | - // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
| 2537 | - '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
| 2538 | - // Replace `:0 0 0 0` with `:0` |
|
| 2539 | - '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
| 2540 | - // Replace `background-position:0` with `background-position:0 0` |
|
| 2541 | - '#(background-position):0(?=[;\}])#si', |
|
| 2542 | - // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
| 2543 | - '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
| 2544 | - // Minify string value |
|
| 2545 | - '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
| 2546 | - '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
| 2547 | - // Minify HEX color code |
|
| 2548 | - '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
| 2549 | - // Replace `(border|outline):none` with `(border|outline):0` |
|
| 2550 | - '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
| 2551 | - // Remove empty selector(s) |
|
| 2552 | - '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
| 2553 | - ), |
|
| 2554 | - array( |
|
| 2555 | - '$1', |
|
| 2556 | - '$1$2$3$4$5$6$7', |
|
| 2557 | - '$1', |
|
| 2558 | - ':0', |
|
| 2559 | - '$1:0 0', |
|
| 2560 | - '.$1', |
|
| 2561 | - '$1$3', |
|
| 2562 | - '$1$2$4$5', |
|
| 2563 | - '$1$2$3', |
|
| 2564 | - '$1:0', |
|
| 2565 | - '$1$2' |
|
| 2566 | - ), |
|
| 2567 | - $input); |
|
| 2568 | - } |
|
| 2569 | - |
|
| 2570 | - /** |
|
| 2571 | - * Get the conditional fields JavaScript. |
|
| 2572 | - * |
|
| 2573 | - * @return mixed |
|
| 2574 | - */ |
|
| 2575 | - public function conditional_fields_js() { |
|
| 2576 | - ob_start(); |
|
| 2577 | - ?> |
|
| 2484 | + $locale = json_encode( $params ); |
|
| 2485 | + |
|
| 2486 | + return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2487 | + } |
|
| 2488 | + |
|
| 2489 | + /** |
|
| 2490 | + * JavaScript Minifier |
|
| 2491 | + * |
|
| 2492 | + * @param $input |
|
| 2493 | + * |
|
| 2494 | + * @return mixed |
|
| 2495 | + */ |
|
| 2496 | + public static function minify_js($input) { |
|
| 2497 | + if(trim($input) === "") return $input; |
|
| 2498 | + return preg_replace( |
|
| 2499 | + array( |
|
| 2500 | + // Remove comment(s) |
|
| 2501 | + '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
| 2502 | + // Remove white-space(s) outside the string and regex |
|
| 2503 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
| 2504 | + // Remove the last semicolon |
|
| 2505 | + '#;+\}#', |
|
| 2506 | + // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
| 2507 | + '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
| 2508 | + // --ibid. From `foo['bar']` to `foo.bar` |
|
| 2509 | + '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
| 2510 | + ), |
|
| 2511 | + array( |
|
| 2512 | + '$1', |
|
| 2513 | + '$1$2', |
|
| 2514 | + '}', |
|
| 2515 | + '$1$3', |
|
| 2516 | + '$1.$3' |
|
| 2517 | + ), |
|
| 2518 | + $input); |
|
| 2519 | + } |
|
| 2520 | + |
|
| 2521 | + /** |
|
| 2522 | + * Minify CSS |
|
| 2523 | + * |
|
| 2524 | + * @param $input |
|
| 2525 | + * |
|
| 2526 | + * @return mixed |
|
| 2527 | + */ |
|
| 2528 | + public static function minify_css($input) { |
|
| 2529 | + if(trim($input) === "") return $input; |
|
| 2530 | + return preg_replace( |
|
| 2531 | + array( |
|
| 2532 | + // Remove comment(s) |
|
| 2533 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
| 2534 | + // Remove unused white-space(s) |
|
| 2535 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
| 2536 | + // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
| 2537 | + '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
| 2538 | + // Replace `:0 0 0 0` with `:0` |
|
| 2539 | + '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
| 2540 | + // Replace `background-position:0` with `background-position:0 0` |
|
| 2541 | + '#(background-position):0(?=[;\}])#si', |
|
| 2542 | + // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
| 2543 | + '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
| 2544 | + // Minify string value |
|
| 2545 | + '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
| 2546 | + '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
| 2547 | + // Minify HEX color code |
|
| 2548 | + '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
| 2549 | + // Replace `(border|outline):none` with `(border|outline):0` |
|
| 2550 | + '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
| 2551 | + // Remove empty selector(s) |
|
| 2552 | + '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
| 2553 | + ), |
|
| 2554 | + array( |
|
| 2555 | + '$1', |
|
| 2556 | + '$1$2$3$4$5$6$7', |
|
| 2557 | + '$1', |
|
| 2558 | + ':0', |
|
| 2559 | + '$1:0 0', |
|
| 2560 | + '.$1', |
|
| 2561 | + '$1$3', |
|
| 2562 | + '$1$2$4$5', |
|
| 2563 | + '$1$2$3', |
|
| 2564 | + '$1:0', |
|
| 2565 | + '$1$2' |
|
| 2566 | + ), |
|
| 2567 | + $input); |
|
| 2568 | + } |
|
| 2569 | + |
|
| 2570 | + /** |
|
| 2571 | + * Get the conditional fields JavaScript. |
|
| 2572 | + * |
|
| 2573 | + * @return mixed |
|
| 2574 | + */ |
|
| 2575 | + public function conditional_fields_js() { |
|
| 2576 | + ob_start(); |
|
| 2577 | + ?> |
|
| 2578 | 2578 | <script> |
| 2579 | 2579 | /** |
| 2580 | 2580 | * Conditional Fields |
@@ -3095,14 +3095,14 @@ discard block |
||
| 3095 | 3095 | <?php do_action( 'aui_conditional_fields_js', $this ); ?> |
| 3096 | 3096 | </script> |
| 3097 | 3097 | <?php |
| 3098 | - $output = ob_get_clean(); |
|
| 3098 | + $output = ob_get_clean(); |
|
| 3099 | 3099 | |
| 3100 | - return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
| 3101 | - } |
|
| 3102 | - } |
|
| 3100 | + return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
| 3101 | + } |
|
| 3102 | + } |
|
| 3103 | 3103 | |
| 3104 | - /** |
|
| 3105 | - * Run the class if found. |
|
| 3106 | - */ |
|
| 3107 | - AyeCode_UI_Settings::instance(); |
|
| 3104 | + /** |
|
| 3105 | + * Run the class if found. |
|
| 3106 | + */ |
|
| 3107 | + AyeCode_UI_Settings::instance(); |
|
| 3108 | 3108 | } |
| 3109 | 3109 | \ No newline at end of file |
@@ -16,222 +16,222 @@ |
||
| 16 | 16 | |
| 17 | 17 | // If this file is called directly, abort. |
| 18 | 18 | if ( ! defined( 'WPINC' ) ) { |
| 19 | - die; |
|
| 19 | + die; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | class AyeCode_UI_Plugin { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * AUI Plugin constructor. |
|
| 26 | - * |
|
| 27 | - * @since 1.0.0 |
|
| 28 | - */ |
|
| 29 | - public function __construct() { |
|
| 30 | - |
|
| 31 | - // load AUI |
|
| 32 | - require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' ); |
|
| 33 | - |
|
| 34 | - // Maybe show example page |
|
| 35 | - add_action( 'template_redirect', array( $this,'maybe_show_examples' ) ); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - public function maybe_show_examples(){ |
|
| 39 | - if ( current_user_can( 'manage_options' ) && isset( $_REQUEST['preview-aui'] ) ) { |
|
| 40 | - echo "<head>"; |
|
| 41 | - wp_head(); |
|
| 42 | - echo "</head>"; |
|
| 43 | - echo "<body class='bsui'>"; |
|
| 44 | - echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 45 | - wp_footer(); |
|
| 46 | - echo "</body>"; |
|
| 47 | - exit; |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public function get_examples(){ |
|
| 52 | - $output = ''; |
|
| 53 | - |
|
| 54 | - // open form |
|
| 55 | - $output .= "<form class='p-5 m-5 border rounded bg-white'>"; |
|
| 56 | - |
|
| 57 | - $output .= aui()->input( |
|
| 58 | - array( |
|
| 59 | - 'type' => 'datepicker', |
|
| 60 | - 'id' => 'date_example_sm', |
|
| 61 | - 'size' => 'sm', |
|
| 62 | - 'name' => 'date_example_sm', |
|
| 63 | - 'label' => 'Date Input Label (small)', |
|
| 64 | - 'help_text' => 'help text', |
|
| 65 | - 'label_type' => 'top', |
|
| 66 | - 'placeholder' => 'YYYY-MM-DD 00:00', |
|
| 67 | - 'value' => '', |
|
| 68 | - 'extra_attributes' => array( |
|
| 69 | - 'data-enable-time' => 'true', |
|
| 70 | - 'data-time_24hr' => 'true', |
|
| 71 | - 'data-allow-input' => 'true', |
|
| 72 | - ), |
|
| 73 | - ) |
|
| 74 | - ); |
|
| 75 | - |
|
| 76 | - $output .= aui()->input( |
|
| 77 | - array( |
|
| 78 | - 'type' => 'datepicker', |
|
| 79 | - 'id' => 'date_example', |
|
| 80 | - //'size' => 'smx', |
|
| 81 | - 'name' => 'date_example', |
|
| 82 | - 'label' => 'Date Input Label', |
|
| 83 | - 'help_text' => 'help text', |
|
| 84 | - 'label_type' => 'top', |
|
| 85 | - 'placeholder' => 'YYYY-MM-DD 00:00', |
|
| 86 | - 'value' => '', |
|
| 87 | - 'extra_attributes' => array( |
|
| 88 | - 'data-enable-time' => 'true', |
|
| 89 | - 'data-time_24hr' => 'true', |
|
| 90 | - 'data-allow-input' => 'true', |
|
| 91 | - ), |
|
| 92 | - ) |
|
| 93 | - ); |
|
| 94 | - |
|
| 95 | - $output .= aui()->input( |
|
| 96 | - array( |
|
| 97 | - 'type' => 'datepicker', |
|
| 98 | - 'id' => 'date_example_lg', |
|
| 99 | - 'size' => 'lg', |
|
| 100 | - 'name' => 'date_example_lg', |
|
| 101 | - 'label' => 'Date Input Label (large)', |
|
| 102 | - 'help_text' => 'help text', |
|
| 103 | - 'label_type' => 'top', |
|
| 104 | - 'placeholder' => 'YYYY-MM-DD 00:00', |
|
| 105 | - 'value' => '', |
|
| 106 | - 'extra_attributes' => array( |
|
| 107 | - 'data-enable-time' => 'true', |
|
| 108 | - 'data-time_24hr' => 'true', |
|
| 109 | - //'data-allow-input' => 'true', |
|
| 110 | - ), |
|
| 111 | - ) |
|
| 112 | - ); |
|
| 113 | - |
|
| 114 | - // input example |
|
| 115 | - $output .= aui()->input( |
|
| 116 | - array( |
|
| 117 | - 'type' => 'text', |
|
| 118 | - 'id' => 'text-example', |
|
| 119 | - 'size' => 'sm', |
|
| 120 | - //'clear_icon' => true, |
|
| 121 | - 'name' => 'text-example', |
|
| 122 | - 'placeholder' => 'text placeholder', |
|
| 123 | - 'title' => 'Text input example', |
|
| 124 | - 'value' => '', |
|
| 125 | - 'required' => false, |
|
| 126 | - 'help_text' => 'help text', |
|
| 127 | - 'label' => 'Text input example label', |
|
| 128 | - 'label_type' => 'top' |
|
| 129 | - ) |
|
| 130 | - ); |
|
| 131 | - |
|
| 132 | - $output .= aui()->input( |
|
| 133 | - array( |
|
| 134 | - 'type' => 'search', |
|
| 135 | - 'id' => 'text-example', |
|
| 136 | - 'size' => 'sm', |
|
| 137 | - //'clear_icon' => true, |
|
| 138 | - 'name' => 'text-example', |
|
| 139 | - 'placeholder' => 'text placeholder', |
|
| 140 | - 'title' => 'Text input example', |
|
| 141 | - 'value' => '', |
|
| 142 | - 'required' => false, |
|
| 143 | - 'help_text' => 'help text', |
|
| 144 | - 'label' => 'Text input example label', |
|
| 145 | - 'label_type' => 'top' |
|
| 146 | - ) |
|
| 147 | - ); |
|
| 148 | - |
|
| 149 | - // input example |
|
| 150 | - $output .= aui()->input( |
|
| 151 | - array( |
|
| 152 | - 'type' => 'url', |
|
| 153 | - 'id' => 'text-example2', |
|
| 154 | - 'name' => 'text-example', |
|
| 155 | - 'placeholder' => 'url placeholder', |
|
| 156 | - 'title' => 'Text input example', |
|
| 157 | - 'value' => '', |
|
| 158 | - 'required' => false, |
|
| 159 | - 'help_text' => 'help text', |
|
| 160 | - 'label' => 'Text input example label' |
|
| 161 | - ) |
|
| 162 | - ); |
|
| 163 | - |
|
| 164 | - // checkbox example |
|
| 165 | - $output .= aui()->input( |
|
| 166 | - array( |
|
| 167 | - 'type' => 'checkbox', |
|
| 168 | - 'id' => 'checkbox-example', |
|
| 169 | - 'name' => 'checkbox-example', |
|
| 170 | - 'placeholder' => 'checkbox-example', |
|
| 171 | - 'title' => 'Checkbox example', |
|
| 172 | - 'value' => '1', |
|
| 173 | - 'checked' => true, |
|
| 174 | - 'required' => false, |
|
| 175 | - 'help_text' => 'help text', |
|
| 176 | - 'label' => 'Checkbox checked' |
|
| 177 | - ) |
|
| 178 | - ); |
|
| 179 | - |
|
| 180 | - // checkbox example |
|
| 181 | - $output .= aui()->input( |
|
| 182 | - array( |
|
| 183 | - 'type' => 'checkbox', |
|
| 184 | - 'id' => 'checkbox-example2', |
|
| 185 | - 'name' => 'checkbox-example2', |
|
| 186 | - 'placeholder' => 'checkbox-example', |
|
| 187 | - 'title' => 'Checkbox example', |
|
| 188 | - 'value' => '1', |
|
| 189 | - 'checked' => false, |
|
| 190 | - 'required' => false, |
|
| 191 | - 'help_text' => 'help text', |
|
| 192 | - 'label' => 'Checkbox un-checked' |
|
| 193 | - ) |
|
| 194 | - ); |
|
| 195 | - |
|
| 196 | - // switch example |
|
| 197 | - $output .= aui()->input( |
|
| 198 | - array( |
|
| 199 | - 'type' => 'checkbox', |
|
| 200 | - 'id' => 'switch-example', |
|
| 201 | - 'name' => 'switch-example', |
|
| 202 | - 'placeholder' => 'checkbox-example', |
|
| 203 | - 'title' => 'Switch example', |
|
| 204 | - 'value' => '1', |
|
| 205 | - 'checked' => true, |
|
| 206 | - 'switch' => true, |
|
| 207 | - 'required' => false, |
|
| 208 | - 'help_text' => 'help text', |
|
| 209 | - 'label' => 'Switch on' |
|
| 210 | - ) |
|
| 211 | - ); |
|
| 212 | - |
|
| 213 | - // switch example |
|
| 214 | - $output .= aui()->input( |
|
| 215 | - array( |
|
| 216 | - 'type' => 'checkbox', |
|
| 217 | - 'id' => 'switch-example2', |
|
| 218 | - 'name' => 'switch-example2', |
|
| 219 | - 'placeholder' => 'checkbox-example', |
|
| 220 | - 'title' => 'Switch example', |
|
| 221 | - 'value' => '1', |
|
| 222 | - 'checked' => false, |
|
| 223 | - 'switch' => true, |
|
| 224 | - 'required' => false, |
|
| 225 | - 'help_text' => 'help text', |
|
| 226 | - 'label' => 'Switch off' |
|
| 227 | - ) |
|
| 228 | - ); |
|
| 229 | - |
|
| 230 | - // close form |
|
| 231 | - $output .= "</form>"; |
|
| 232 | - |
|
| 233 | - return $output; |
|
| 234 | - } |
|
| 24 | + /** |
|
| 25 | + * AUI Plugin constructor. |
|
| 26 | + * |
|
| 27 | + * @since 1.0.0 |
|
| 28 | + */ |
|
| 29 | + public function __construct() { |
|
| 30 | + |
|
| 31 | + // load AUI |
|
| 32 | + require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' ); |
|
| 33 | + |
|
| 34 | + // Maybe show example page |
|
| 35 | + add_action( 'template_redirect', array( $this,'maybe_show_examples' ) ); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + public function maybe_show_examples(){ |
|
| 39 | + if ( current_user_can( 'manage_options' ) && isset( $_REQUEST['preview-aui'] ) ) { |
|
| 40 | + echo "<head>"; |
|
| 41 | + wp_head(); |
|
| 42 | + echo "</head>"; |
|
| 43 | + echo "<body class='bsui'>"; |
|
| 44 | + echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 45 | + wp_footer(); |
|
| 46 | + echo "</body>"; |
|
| 47 | + exit; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public function get_examples(){ |
|
| 52 | + $output = ''; |
|
| 53 | + |
|
| 54 | + // open form |
|
| 55 | + $output .= "<form class='p-5 m-5 border rounded bg-white'>"; |
|
| 56 | + |
|
| 57 | + $output .= aui()->input( |
|
| 58 | + array( |
|
| 59 | + 'type' => 'datepicker', |
|
| 60 | + 'id' => 'date_example_sm', |
|
| 61 | + 'size' => 'sm', |
|
| 62 | + 'name' => 'date_example_sm', |
|
| 63 | + 'label' => 'Date Input Label (small)', |
|
| 64 | + 'help_text' => 'help text', |
|
| 65 | + 'label_type' => 'top', |
|
| 66 | + 'placeholder' => 'YYYY-MM-DD 00:00', |
|
| 67 | + 'value' => '', |
|
| 68 | + 'extra_attributes' => array( |
|
| 69 | + 'data-enable-time' => 'true', |
|
| 70 | + 'data-time_24hr' => 'true', |
|
| 71 | + 'data-allow-input' => 'true', |
|
| 72 | + ), |
|
| 73 | + ) |
|
| 74 | + ); |
|
| 75 | + |
|
| 76 | + $output .= aui()->input( |
|
| 77 | + array( |
|
| 78 | + 'type' => 'datepicker', |
|
| 79 | + 'id' => 'date_example', |
|
| 80 | + //'size' => 'smx', |
|
| 81 | + 'name' => 'date_example', |
|
| 82 | + 'label' => 'Date Input Label', |
|
| 83 | + 'help_text' => 'help text', |
|
| 84 | + 'label_type' => 'top', |
|
| 85 | + 'placeholder' => 'YYYY-MM-DD 00:00', |
|
| 86 | + 'value' => '', |
|
| 87 | + 'extra_attributes' => array( |
|
| 88 | + 'data-enable-time' => 'true', |
|
| 89 | + 'data-time_24hr' => 'true', |
|
| 90 | + 'data-allow-input' => 'true', |
|
| 91 | + ), |
|
| 92 | + ) |
|
| 93 | + ); |
|
| 94 | + |
|
| 95 | + $output .= aui()->input( |
|
| 96 | + array( |
|
| 97 | + 'type' => 'datepicker', |
|
| 98 | + 'id' => 'date_example_lg', |
|
| 99 | + 'size' => 'lg', |
|
| 100 | + 'name' => 'date_example_lg', |
|
| 101 | + 'label' => 'Date Input Label (large)', |
|
| 102 | + 'help_text' => 'help text', |
|
| 103 | + 'label_type' => 'top', |
|
| 104 | + 'placeholder' => 'YYYY-MM-DD 00:00', |
|
| 105 | + 'value' => '', |
|
| 106 | + 'extra_attributes' => array( |
|
| 107 | + 'data-enable-time' => 'true', |
|
| 108 | + 'data-time_24hr' => 'true', |
|
| 109 | + //'data-allow-input' => 'true', |
|
| 110 | + ), |
|
| 111 | + ) |
|
| 112 | + ); |
|
| 113 | + |
|
| 114 | + // input example |
|
| 115 | + $output .= aui()->input( |
|
| 116 | + array( |
|
| 117 | + 'type' => 'text', |
|
| 118 | + 'id' => 'text-example', |
|
| 119 | + 'size' => 'sm', |
|
| 120 | + //'clear_icon' => true, |
|
| 121 | + 'name' => 'text-example', |
|
| 122 | + 'placeholder' => 'text placeholder', |
|
| 123 | + 'title' => 'Text input example', |
|
| 124 | + 'value' => '', |
|
| 125 | + 'required' => false, |
|
| 126 | + 'help_text' => 'help text', |
|
| 127 | + 'label' => 'Text input example label', |
|
| 128 | + 'label_type' => 'top' |
|
| 129 | + ) |
|
| 130 | + ); |
|
| 131 | + |
|
| 132 | + $output .= aui()->input( |
|
| 133 | + array( |
|
| 134 | + 'type' => 'search', |
|
| 135 | + 'id' => 'text-example', |
|
| 136 | + 'size' => 'sm', |
|
| 137 | + //'clear_icon' => true, |
|
| 138 | + 'name' => 'text-example', |
|
| 139 | + 'placeholder' => 'text placeholder', |
|
| 140 | + 'title' => 'Text input example', |
|
| 141 | + 'value' => '', |
|
| 142 | + 'required' => false, |
|
| 143 | + 'help_text' => 'help text', |
|
| 144 | + 'label' => 'Text input example label', |
|
| 145 | + 'label_type' => 'top' |
|
| 146 | + ) |
|
| 147 | + ); |
|
| 148 | + |
|
| 149 | + // input example |
|
| 150 | + $output .= aui()->input( |
|
| 151 | + array( |
|
| 152 | + 'type' => 'url', |
|
| 153 | + 'id' => 'text-example2', |
|
| 154 | + 'name' => 'text-example', |
|
| 155 | + 'placeholder' => 'url placeholder', |
|
| 156 | + 'title' => 'Text input example', |
|
| 157 | + 'value' => '', |
|
| 158 | + 'required' => false, |
|
| 159 | + 'help_text' => 'help text', |
|
| 160 | + 'label' => 'Text input example label' |
|
| 161 | + ) |
|
| 162 | + ); |
|
| 163 | + |
|
| 164 | + // checkbox example |
|
| 165 | + $output .= aui()->input( |
|
| 166 | + array( |
|
| 167 | + 'type' => 'checkbox', |
|
| 168 | + 'id' => 'checkbox-example', |
|
| 169 | + 'name' => 'checkbox-example', |
|
| 170 | + 'placeholder' => 'checkbox-example', |
|
| 171 | + 'title' => 'Checkbox example', |
|
| 172 | + 'value' => '1', |
|
| 173 | + 'checked' => true, |
|
| 174 | + 'required' => false, |
|
| 175 | + 'help_text' => 'help text', |
|
| 176 | + 'label' => 'Checkbox checked' |
|
| 177 | + ) |
|
| 178 | + ); |
|
| 179 | + |
|
| 180 | + // checkbox example |
|
| 181 | + $output .= aui()->input( |
|
| 182 | + array( |
|
| 183 | + 'type' => 'checkbox', |
|
| 184 | + 'id' => 'checkbox-example2', |
|
| 185 | + 'name' => 'checkbox-example2', |
|
| 186 | + 'placeholder' => 'checkbox-example', |
|
| 187 | + 'title' => 'Checkbox example', |
|
| 188 | + 'value' => '1', |
|
| 189 | + 'checked' => false, |
|
| 190 | + 'required' => false, |
|
| 191 | + 'help_text' => 'help text', |
|
| 192 | + 'label' => 'Checkbox un-checked' |
|
| 193 | + ) |
|
| 194 | + ); |
|
| 195 | + |
|
| 196 | + // switch example |
|
| 197 | + $output .= aui()->input( |
|
| 198 | + array( |
|
| 199 | + 'type' => 'checkbox', |
|
| 200 | + 'id' => 'switch-example', |
|
| 201 | + 'name' => 'switch-example', |
|
| 202 | + 'placeholder' => 'checkbox-example', |
|
| 203 | + 'title' => 'Switch example', |
|
| 204 | + 'value' => '1', |
|
| 205 | + 'checked' => true, |
|
| 206 | + 'switch' => true, |
|
| 207 | + 'required' => false, |
|
| 208 | + 'help_text' => 'help text', |
|
| 209 | + 'label' => 'Switch on' |
|
| 210 | + ) |
|
| 211 | + ); |
|
| 212 | + |
|
| 213 | + // switch example |
|
| 214 | + $output .= aui()->input( |
|
| 215 | + array( |
|
| 216 | + 'type' => 'checkbox', |
|
| 217 | + 'id' => 'switch-example2', |
|
| 218 | + 'name' => 'switch-example2', |
|
| 219 | + 'placeholder' => 'checkbox-example', |
|
| 220 | + 'title' => 'Switch example', |
|
| 221 | + 'value' => '1', |
|
| 222 | + 'checked' => false, |
|
| 223 | + 'switch' => true, |
|
| 224 | + 'required' => false, |
|
| 225 | + 'help_text' => 'help text', |
|
| 226 | + 'label' => 'Switch off' |
|
| 227 | + ) |
|
| 228 | + ); |
|
| 229 | + |
|
| 230 | + // close form |
|
| 231 | + $output .= "</form>"; |
|
| 232 | + |
|
| 233 | + return $output; |
|
| 234 | + } |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | new AyeCode_UI_Plugin(); |
| 238 | 238 | \ No newline at end of file |
@@ -7,40 +7,40 @@ |
||
| 7 | 7 | * Bail if we are not in WP. |
| 8 | 8 | */ |
| 9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | - exit; |
|
| 10 | + exit; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Set the version only if its the current newest while loading. |
| 15 | 15 | */ |
| 16 | 16 | add_action('after_setup_theme', function () { |
| 17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 18 | - $this_version = "0.2.9"; |
|
| 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 | - } |
|
| 17 | + global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 18 | + $this_version = "0.2.9"; |
|
| 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 | + } |
|
| 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 | 28 | add_action('after_setup_theme', function () { |
| 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' ); |
|
| 33 | - } |
|
| 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' ); |
|
| 33 | + } |
|
| 34 | 34 | },1); |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Add the function that calls the class. |
| 38 | 38 | */ |
| 39 | 39 | if(!function_exists('aui')){ |
| 40 | - function aui(){ |
|
| 41 | - if(!class_exists("AUI",false)){ |
|
| 42 | - return false; |
|
| 43 | - } |
|
| 44 | - return AUI::instance(); |
|
| 45 | - } |
|
| 40 | + function aui(){ |
|
| 41 | + if(!class_exists("AUI",false)){ |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | + return AUI::instance(); |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -1,60 +1,60 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | - exit; |
|
| 3 | + exit; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | if ( ! class_exists( 'WP_Super_Duper' ) ) { |
| 7 | 7 | |
| 8 | - define( 'SUPER_DUPER_VER', '1.1.35' ); |
|
| 9 | - |
|
| 10 | - /** |
|
| 11 | - * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
| 12 | - * |
|
| 13 | - * Should not be called direct but extended instead. |
|
| 14 | - * |
|
| 15 | - * Class WP_Super_Duper |
|
| 16 | - * @since 1.0.16 change log moved to file change-log.txt - CHANGED |
|
| 17 | - * @ver 1.1.1 |
|
| 18 | - */ |
|
| 19 | - class WP_Super_Duper extends WP_Widget { |
|
| 20 | - |
|
| 21 | - public $version = SUPER_DUPER_VER; |
|
| 22 | - public $font_awesome_icon_version = "5.11.2"; |
|
| 23 | - public $block_code; |
|
| 24 | - public $options; |
|
| 25 | - public $base_id; |
|
| 26 | - public $settings_hash; |
|
| 27 | - public $arguments = array(); |
|
| 28 | - public $instance = array(); |
|
| 29 | - private $class_name; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * The relative url to the current folder. |
|
| 33 | - * |
|
| 34 | - * @var string |
|
| 35 | - */ |
|
| 36 | - public $url = ''; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Take the array options and use them to build. |
|
| 40 | - */ |
|
| 41 | - public function __construct( $options ) { |
|
| 42 | - global $sd_widgets; |
|
| 43 | - |
|
| 44 | - $sd_widgets[ $options['base_id'] ] = array( |
|
| 45 | - 'name' => $options['name'], |
|
| 46 | - 'class_name' => $options['class_name'], |
|
| 47 | - 'output_types' => !empty($options['output_types']) ? $options['output_types'] : array() |
|
| 48 | - ); |
|
| 49 | - $this->base_id = $options['base_id']; |
|
| 50 | - // lets filter the options before we do anything |
|
| 51 | - $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 52 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 53 | - $options = $this->add_name_from_key( $options ); |
|
| 54 | - $this->options = $options; |
|
| 55 | - |
|
| 56 | - $this->base_id = $options['base_id']; |
|
| 57 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 8 | + define( 'SUPER_DUPER_VER', '1.1.35' ); |
|
| 9 | + |
|
| 10 | + /** |
|
| 11 | + * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
| 12 | + * |
|
| 13 | + * Should not be called direct but extended instead. |
|
| 14 | + * |
|
| 15 | + * Class WP_Super_Duper |
|
| 16 | + * @since 1.0.16 change log moved to file change-log.txt - CHANGED |
|
| 17 | + * @ver 1.1.1 |
|
| 18 | + */ |
|
| 19 | + class WP_Super_Duper extends WP_Widget { |
|
| 20 | + |
|
| 21 | + public $version = SUPER_DUPER_VER; |
|
| 22 | + public $font_awesome_icon_version = "5.11.2"; |
|
| 23 | + public $block_code; |
|
| 24 | + public $options; |
|
| 25 | + public $base_id; |
|
| 26 | + public $settings_hash; |
|
| 27 | + public $arguments = array(); |
|
| 28 | + public $instance = array(); |
|
| 29 | + private $class_name; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * The relative url to the current folder. |
|
| 33 | + * |
|
| 34 | + * @var string |
|
| 35 | + */ |
|
| 36 | + public $url = ''; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Take the array options and use them to build. |
|
| 40 | + */ |
|
| 41 | + public function __construct( $options ) { |
|
| 42 | + global $sd_widgets; |
|
| 43 | + |
|
| 44 | + $sd_widgets[ $options['base_id'] ] = array( |
|
| 45 | + 'name' => $options['name'], |
|
| 46 | + 'class_name' => $options['class_name'], |
|
| 47 | + 'output_types' => !empty($options['output_types']) ? $options['output_types'] : array() |
|
| 48 | + ); |
|
| 49 | + $this->base_id = $options['base_id']; |
|
| 50 | + // lets filter the options before we do anything |
|
| 51 | + $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 52 | + $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 53 | + $options = $this->add_name_from_key( $options ); |
|
| 54 | + $this->options = $options; |
|
| 55 | + |
|
| 56 | + $this->base_id = $options['base_id']; |
|
| 57 | + $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 58 | 58 | |
| 59 | 59 | // nested blocks can't work as a widget |
| 60 | 60 | if(!empty($this->options['nested-block'])){ |
@@ -65,235 +65,235 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - // init parent |
|
| 69 | - if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
| 68 | + // init parent |
|
| 69 | + if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
| 70 | 70 | parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | - if ( isset( $options['class_name'] ) ) { |
|
| 75 | - // register widget |
|
| 76 | - $this->class_name = $options['class_name']; |
|
| 74 | + if ( isset( $options['class_name'] ) ) { |
|
| 75 | + // register widget |
|
| 76 | + $this->class_name = $options['class_name']; |
|
| 77 | 77 | |
| 78 | - // register shortcode, this needs to be done even for blocks and widgets |
|
| 78 | + // register shortcode, this needs to be done even for blocks and widgets |
|
| 79 | 79 | $this->register_shortcode(); |
| 80 | 80 | |
| 81 | 81 | |
| 82 | - // Fusion Builder (avada) support |
|
| 83 | - if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 84 | - add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 85 | - } |
|
| 82 | + // Fusion Builder (avada) support |
|
| 83 | + if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 84 | + add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - // register block |
|
| 88 | - if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){ |
|
| 89 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 87 | + // register block |
|
| 88 | + if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){ |
|
| 89 | + add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 90 | 90 | } |
| 91 | - } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - // add the CSS and JS we need ONCE |
|
| 94 | - global $sd_widget_scripts; |
|
| 93 | + // add the CSS and JS we need ONCE |
|
| 94 | + global $sd_widget_scripts; |
|
| 95 | 95 | |
| 96 | - if ( ! $sd_widget_scripts ) { |
|
| 97 | - wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 98 | - wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 99 | - wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 96 | + if ( ! $sd_widget_scripts ) { |
|
| 97 | + wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 98 | + wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 99 | + wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 100 | 100 | |
| 101 | - // maybe add elementor editor styles |
|
| 102 | - add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 101 | + // maybe add elementor editor styles |
|
| 102 | + add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 103 | 103 | |
| 104 | - $sd_widget_scripts = true; |
|
| 104 | + $sd_widget_scripts = true; |
|
| 105 | 105 | |
| 106 | - // add shortcode insert button once |
|
| 107 | - add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 108 | - // generatepress theme sections compatibility |
|
| 109 | - if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 110 | - add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 111 | - } |
|
| 112 | - /* Load script on Divi theme builder page */ |
|
| 113 | - if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { |
|
| 114 | - add_thickbox(); |
|
| 115 | - add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 116 | - } |
|
| 106 | + // add shortcode insert button once |
|
| 107 | + add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 108 | + // generatepress theme sections compatibility |
|
| 109 | + if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 110 | + add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 111 | + } |
|
| 112 | + /* Load script on Divi theme builder page */ |
|
| 113 | + if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { |
|
| 114 | + add_thickbox(); |
|
| 115 | + add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - if ( $this->is_preview() ) { |
|
| 119 | - add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 120 | - // this makes the insert button work for elementor |
|
| 121 | - add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 122 | - $this, |
|
| 123 | - 'shortcode_insert_button_script' |
|
| 124 | - ) ); // for elementor |
|
| 125 | - } |
|
| 126 | - // this makes the insert button work for cornerstone |
|
| 127 | - add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 118 | + if ( $this->is_preview() ) { |
|
| 119 | + add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 120 | + // this makes the insert button work for elementor |
|
| 121 | + add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 122 | + $this, |
|
| 123 | + 'shortcode_insert_button_script' |
|
| 124 | + ) ); // for elementor |
|
| 125 | + } |
|
| 126 | + // this makes the insert button work for cornerstone |
|
| 127 | + add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 128 | 128 | |
| 129 | - add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 130 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 129 | + add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 130 | + add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 131 | 131 | |
| 132 | - // add generator text to head |
|
| 133 | - add_action( 'admin_head', array( $this, 'generator' ), 99 ); |
|
| 134 | - add_action( 'wp_head', array( $this, 'generator' ), 99 ); |
|
| 135 | - } |
|
| 132 | + // add generator text to head |
|
| 133 | + add_action( 'admin_head', array( $this, 'generator' ), 99 ); |
|
| 134 | + add_action( 'wp_head', array( $this, 'generator' ), 99 ); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 138 | - } |
|
| 137 | + do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | /** |
| 141 | 141 | * The register widget function |
| 142 | 142 | * @return void |
| 143 | 143 | */ |
| 144 | - public function _register() { |
|
| 144 | + public function _register() { |
|
| 145 | 145 | if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
| 146 | 146 | parent::_register(); |
| 147 | - } |
|
| 148 | - } |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Add our widget CSS to elementor editor. |
|
| 152 | - */ |
|
| 153 | - public function elementor_editor_styles() { |
|
| 154 | - wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 155 | - } |
|
| 150 | + /** |
|
| 151 | + * Add our widget CSS to elementor editor. |
|
| 152 | + */ |
|
| 153 | + public function elementor_editor_styles() { |
|
| 154 | + wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - public function register_fusion_element() { |
|
| 157 | + public function register_fusion_element() { |
|
| 158 | 158 | |
| 159 | - $options = $this->options; |
|
| 159 | + $options = $this->options; |
|
| 160 | 160 | |
| 161 | - if ( $this->base_id ) { |
|
| 161 | + if ( $this->base_id ) { |
|
| 162 | 162 | |
| 163 | - $params = $this->get_fusion_params(); |
|
| 163 | + $params = $this->get_fusion_params(); |
|
| 164 | 164 | |
| 165 | - $args = array( |
|
| 166 | - 'name' => $options['name'], |
|
| 167 | - 'shortcode' => $this->base_id, |
|
| 168 | - 'icon' => $options['block-icon'] ? $options['block-icon'] : 'far fa-square', |
|
| 169 | - 'allow_generator' => true, |
|
| 170 | - ); |
|
| 165 | + $args = array( |
|
| 166 | + 'name' => $options['name'], |
|
| 167 | + 'shortcode' => $this->base_id, |
|
| 168 | + 'icon' => $options['block-icon'] ? $options['block-icon'] : 'far fa-square', |
|
| 169 | + 'allow_generator' => true, |
|
| 170 | + ); |
|
| 171 | 171 | |
| 172 | - if ( ! empty( $params ) ) { |
|
| 173 | - $args['params'] = $params; |
|
| 174 | - } |
|
| 172 | + if ( ! empty( $params ) ) { |
|
| 173 | + $args['params'] = $params; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - fusion_builder_map( $args ); |
|
| 177 | - } |
|
| 176 | + fusion_builder_map( $args ); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - } |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - public function get_fusion_params() { |
|
| 182 | - $params = array(); |
|
| 183 | - $arguments = $this->get_arguments(); |
|
| 184 | - |
|
| 185 | - if ( ! empty( $arguments ) ) { |
|
| 186 | - foreach ( $arguments as $key => $val ) { |
|
| 187 | - $param = array(); |
|
| 188 | - // type |
|
| 189 | - $param['type'] = str_replace( |
|
| 190 | - array( |
|
| 191 | - "text", |
|
| 192 | - "number", |
|
| 193 | - "email", |
|
| 194 | - "color", |
|
| 195 | - "checkbox" |
|
| 196 | - ), |
|
| 197 | - array( |
|
| 198 | - "textfield", |
|
| 199 | - "textfield", |
|
| 200 | - "textfield", |
|
| 201 | - "colorpicker", |
|
| 202 | - "select", |
|
| 203 | - |
|
| 204 | - ), |
|
| 205 | - $val['type'] ); |
|
| 206 | - |
|
| 207 | - // multiselect |
|
| 208 | - if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 209 | - $param['type'] = 'multiple_select'; |
|
| 210 | - $param['multiple'] = true; |
|
| 211 | - } |
|
| 181 | + public function get_fusion_params() { |
|
| 182 | + $params = array(); |
|
| 183 | + $arguments = $this->get_arguments(); |
|
| 184 | + |
|
| 185 | + if ( ! empty( $arguments ) ) { |
|
| 186 | + foreach ( $arguments as $key => $val ) { |
|
| 187 | + $param = array(); |
|
| 188 | + // type |
|
| 189 | + $param['type'] = str_replace( |
|
| 190 | + array( |
|
| 191 | + "text", |
|
| 192 | + "number", |
|
| 193 | + "email", |
|
| 194 | + "color", |
|
| 195 | + "checkbox" |
|
| 196 | + ), |
|
| 197 | + array( |
|
| 198 | + "textfield", |
|
| 199 | + "textfield", |
|
| 200 | + "textfield", |
|
| 201 | + "colorpicker", |
|
| 202 | + "select", |
|
| 212 | 203 | |
| 213 | - // heading |
|
| 214 | - $param['heading'] = isset( $val['title'] ) ? $val['title'] : ''; |
|
| 204 | + ), |
|
| 205 | + $val['type'] ); |
|
| 215 | 206 | |
| 216 | - // description |
|
| 217 | - $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 207 | + // multiselect |
|
| 208 | + if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 209 | + $param['type'] = 'multiple_select'; |
|
| 210 | + $param['multiple'] = true; |
|
| 211 | + } |
|
| 218 | 212 | |
| 219 | - // param_name |
|
| 220 | - $param['param_name'] = $key; |
|
| 213 | + // heading |
|
| 214 | + $param['heading'] = isset( $val['title'] ) ? $val['title'] : ''; |
|
| 221 | 215 | |
| 222 | - // Default |
|
| 223 | - $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 216 | + // description |
|
| 217 | + $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 224 | 218 | |
| 225 | - // Group |
|
| 226 | - if ( isset( $val['group'] ) ) { |
|
| 227 | - $param['group'] = $val['group']; |
|
| 228 | - } |
|
| 219 | + // param_name |
|
| 220 | + $param['param_name'] = $key; |
|
| 229 | 221 | |
| 230 | - // value |
|
| 231 | - if ( $val['type'] == 'checkbox' ) { |
|
| 232 | - if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 233 | - unset( $param['default'] ); |
|
| 234 | - } |
|
| 235 | - $param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) ); |
|
| 236 | - } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 237 | - $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 238 | - } else { |
|
| 239 | - $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 240 | - } |
|
| 222 | + // Default |
|
| 223 | + $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 241 | 224 | |
| 242 | - // setup the param |
|
| 243 | - $params[] = $param; |
|
| 225 | + // Group |
|
| 226 | + if ( isset( $val['group'] ) ) { |
|
| 227 | + $param['group'] = $val['group']; |
|
| 228 | + } |
|
| 244 | 229 | |
| 245 | - } |
|
| 246 | - } |
|
| 230 | + // value |
|
| 231 | + if ( $val['type'] == 'checkbox' ) { |
|
| 232 | + if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 233 | + unset( $param['default'] ); |
|
| 234 | + } |
|
| 235 | + $param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) ); |
|
| 236 | + } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 237 | + $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 238 | + } else { |
|
| 239 | + $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 240 | + } |
|
| 247 | 241 | |
| 242 | + // setup the param |
|
| 243 | + $params[] = $param; |
|
| 248 | 244 | |
| 249 | - return $params; |
|
| 250 | - } |
|
| 245 | + } |
|
| 246 | + } |
|
| 251 | 247 | |
| 252 | - /** |
|
| 253 | - * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
|
| 254 | - */ |
|
| 255 | - public static function maybe_cornerstone_builder() { |
|
| 256 | - if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 257 | - self::shortcode_insert_button_script(); |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | 248 | |
| 261 | - /** |
|
| 262 | - * A function to ge the shortcode builder picker html. |
|
| 263 | - * |
|
| 264 | - * @param string $editor_id |
|
| 265 | - * |
|
| 266 | - * @return string |
|
| 267 | - */ |
|
| 268 | - public static function get_picker( $editor_id = '' ) { |
|
| 269 | - |
|
| 270 | - ob_start(); |
|
| 271 | - if ( isset( $_POST['editor_id'] ) ) { |
|
| 272 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 273 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 274 | - $editor_id = 'main_content_content_vb_tiny_mce'; |
|
| 275 | - } |
|
| 249 | + return $params; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
|
| 254 | + */ |
|
| 255 | + public static function maybe_cornerstone_builder() { |
|
| 256 | + if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 257 | + self::shortcode_insert_button_script(); |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * A function to ge the shortcode builder picker html. |
|
| 263 | + * |
|
| 264 | + * @param string $editor_id |
|
| 265 | + * |
|
| 266 | + * @return string |
|
| 267 | + */ |
|
| 268 | + public static function get_picker( $editor_id = '' ) { |
|
| 269 | + |
|
| 270 | + ob_start(); |
|
| 271 | + if ( isset( $_POST['editor_id'] ) ) { |
|
| 272 | + $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 273 | + } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 274 | + $editor_id = 'main_content_content_vb_tiny_mce'; |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - global $sd_widgets; |
|
| 277 | + global $sd_widgets; |
|
| 278 | 278 | |
| 279 | 279 | // print_r($sd_widgets);exit; |
| 280 | - ?> |
|
| 280 | + ?> |
|
| 281 | 281 | |
| 282 | 282 | <div class="sd-shortcode-left-wrap"> |
| 283 | 283 | <?php |
| 284 | - ksort( $sd_widgets ); |
|
| 285 | - // print_r($sd_widgets);exit; |
|
| 286 | - if ( ! empty( $sd_widgets ) ) { |
|
| 287 | - echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
| 288 | - echo "<option>" . __( 'Select shortcode', 'ayecode-connect' ) . "</option>"; |
|
| 289 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 290 | - if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; } |
|
| 291 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 292 | - } |
|
| 293 | - echo "</select>"; |
|
| 284 | + ksort( $sd_widgets ); |
|
| 285 | + // print_r($sd_widgets);exit; |
|
| 286 | + if ( ! empty( $sd_widgets ) ) { |
|
| 287 | + echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
| 288 | + echo "<option>" . __( 'Select shortcode', 'ayecode-connect' ) . "</option>"; |
|
| 289 | + foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 290 | + if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; } |
|
| 291 | + echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 292 | + } |
|
| 293 | + echo "</select>"; |
|
| 294 | 294 | |
| 295 | - } |
|
| 296 | - ?> |
|
| 295 | + } |
|
| 296 | + ?> |
|
| 297 | 297 | <div class="sd-shortcode-settings"></div> |
| 298 | 298 | |
| 299 | 299 | </div> |
@@ -304,8 +304,8 @@ discard block |
||
| 304 | 304 | <?php if ( $editor_id != '' ) { ?> |
| 305 | 305 | <button class="button sd-insert-shortcode-button" |
| 306 | 306 | onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { |
| 307 | - echo "'" . $editor_id . "'"; |
|
| 308 | - } ?>)"><?php _e( 'Insert shortcode', 'ayecode-connect' ); ?></button> |
|
| 307 | + echo "'" . $editor_id . "'"; |
|
| 308 | + } ?>)"><?php _e( 'Insert shortcode', 'ayecode-connect' ); ?></button> |
|
| 309 | 309 | <?php } ?> |
| 310 | 310 | <button class="button" |
| 311 | 311 | onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button> |
@@ -313,150 +313,150 @@ discard block |
||
| 313 | 313 | </div> |
| 314 | 314 | <?php |
| 315 | 315 | |
| 316 | - $html = ob_get_clean(); |
|
| 316 | + $html = ob_get_clean(); |
|
| 317 | 317 | |
| 318 | - if ( wp_doing_ajax() ) { |
|
| 319 | - echo $html; |
|
| 320 | - $should_die = true; |
|
| 318 | + if ( wp_doing_ajax() ) { |
|
| 319 | + echo $html; |
|
| 320 | + $should_die = true; |
|
| 321 | 321 | |
| 322 | - // some builder get the editor via ajax so we should not die on those occasions |
|
| 323 | - $dont_die = array( |
|
| 324 | - 'parent_tag',// WP Bakery |
|
| 325 | - 'avia_request' // enfold |
|
| 326 | - ); |
|
| 322 | + // some builder get the editor via ajax so we should not die on those occasions |
|
| 323 | + $dont_die = array( |
|
| 324 | + 'parent_tag',// WP Bakery |
|
| 325 | + 'avia_request' // enfold |
|
| 326 | + ); |
|
| 327 | 327 | |
| 328 | - foreach ( $dont_die as $request ) { |
|
| 329 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 330 | - $should_die = false; |
|
| 331 | - } |
|
| 332 | - } |
|
| 328 | + foreach ( $dont_die as $request ) { |
|
| 329 | + if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 330 | + $should_die = false; |
|
| 331 | + } |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | - if ( $should_die ) { |
|
| 335 | - wp_die(); |
|
| 336 | - } |
|
| 334 | + if ( $should_die ) { |
|
| 335 | + wp_die(); |
|
| 336 | + } |
|
| 337 | 337 | |
| 338 | - } else { |
|
| 339 | - return $html; |
|
| 340 | - } |
|
| 338 | + } else { |
|
| 339 | + return $html; |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - return ''; |
|
| 342 | + return ''; |
|
| 343 | 343 | |
| 344 | - } |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | - /** |
|
| 347 | - * Output the version in the header. |
|
| 348 | - */ |
|
| 349 | - public function generator() { |
|
| 350 | - $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) ); |
|
| 351 | - $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) ); |
|
| 352 | - |
|
| 353 | - // Find source plugin/theme of SD |
|
| 354 | - $source = array(); |
|
| 355 | - if ( strpos( $file, $plugins_dir ) !== false ) { |
|
| 356 | - $source = explode( "/", plugin_basename( $file ) ); |
|
| 357 | - } else if ( function_exists( 'get_theme_root' ) ) { |
|
| 358 | - $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) ); |
|
| 359 | - |
|
| 360 | - if ( strpos( $file, $themes_dir ) !== false ) { |
|
| 361 | - $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) ); |
|
| 362 | - } |
|
| 363 | - } |
|
| 346 | + /** |
|
| 347 | + * Output the version in the header. |
|
| 348 | + */ |
|
| 349 | + public function generator() { |
|
| 350 | + $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) ); |
|
| 351 | + $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) ); |
|
| 352 | + |
|
| 353 | + // Find source plugin/theme of SD |
|
| 354 | + $source = array(); |
|
| 355 | + if ( strpos( $file, $plugins_dir ) !== false ) { |
|
| 356 | + $source = explode( "/", plugin_basename( $file ) ); |
|
| 357 | + } else if ( function_exists( 'get_theme_root' ) ) { |
|
| 358 | + $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) ); |
|
| 359 | + |
|
| 360 | + if ( strpos( $file, $themes_dir ) !== false ) { |
|
| 361 | + $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) ); |
|
| 362 | + } |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | - echo '<meta name="generator" content="WP Super Duper v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />'; |
|
| 366 | - } |
|
| 365 | + echo '<meta name="generator" content="WP Super Duper v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />'; |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - /** |
|
| 369 | - * Get widget settings. |
|
| 370 | - * |
|
| 371 | - * @since 1.0.0 |
|
| 372 | - */ |
|
| 373 | - public static function get_widget_settings() { |
|
| 374 | - global $sd_widgets; |
|
| 375 | - |
|
| 376 | - $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 377 | - if ( ! $shortcode ) { |
|
| 378 | - wp_die(); |
|
| 379 | - } |
|
| 380 | - $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 381 | - if ( ! $widget_args ) { |
|
| 382 | - wp_die(); |
|
| 383 | - } |
|
| 384 | - $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 385 | - if ( ! $class_name ) { |
|
| 386 | - wp_die(); |
|
| 387 | - } |
|
| 368 | + /** |
|
| 369 | + * Get widget settings. |
|
| 370 | + * |
|
| 371 | + * @since 1.0.0 |
|
| 372 | + */ |
|
| 373 | + public static function get_widget_settings() { |
|
| 374 | + global $sd_widgets; |
|
| 375 | + |
|
| 376 | + $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 377 | + if ( ! $shortcode ) { |
|
| 378 | + wp_die(); |
|
| 379 | + } |
|
| 380 | + $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 381 | + if ( ! $widget_args ) { |
|
| 382 | + wp_die(); |
|
| 383 | + } |
|
| 384 | + $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 385 | + if ( ! $class_name ) { |
|
| 386 | + wp_die(); |
|
| 387 | + } |
|
| 388 | 388 | |
| 389 | - // invoke an instance method |
|
| 390 | - $widget = new $class_name; |
|
| 389 | + // invoke an instance method |
|
| 390 | + $widget = new $class_name; |
|
| 391 | 391 | |
| 392 | - ob_start(); |
|
| 393 | - $widget->form( array() ); |
|
| 394 | - $form = ob_get_clean(); |
|
| 395 | - echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
|
| 396 | - echo "<style>" . $widget->widget_css() . "</style>"; |
|
| 397 | - echo "<script>" . $widget->widget_js() . "</script>"; |
|
| 398 | - ?> |
|
| 392 | + ob_start(); |
|
| 393 | + $widget->form( array() ); |
|
| 394 | + $form = ob_get_clean(); |
|
| 395 | + echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
|
| 396 | + echo "<style>" . $widget->widget_css() . "</style>"; |
|
| 397 | + echo "<script>" . $widget->widget_js() . "</script>"; |
|
| 398 | + ?> |
|
| 399 | 399 | <?php |
| 400 | - wp_die(); |
|
| 401 | - } |
|
| 400 | + wp_die(); |
|
| 401 | + } |
|
| 402 | 402 | |
| 403 | - /** |
|
| 404 | - * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed). |
|
| 405 | - * |
|
| 406 | - * @param string $editor_id Optional. Shortcode editor id. Default null. |
|
| 407 | - * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null. |
|
| 408 | - * |
|
| 409 | - *@since 1.0.0 |
|
| 410 | - * |
|
| 411 | - */ |
|
| 412 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 413 | - global $sd_widgets, $shortcode_insert_button_once; |
|
| 414 | - if ( $shortcode_insert_button_once ) { |
|
| 415 | - return; |
|
| 416 | - } |
|
| 417 | - add_thickbox(); |
|
| 403 | + /** |
|
| 404 | + * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed). |
|
| 405 | + * |
|
| 406 | + * @param string $editor_id Optional. Shortcode editor id. Default null. |
|
| 407 | + * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null. |
|
| 408 | + * |
|
| 409 | + *@since 1.0.0 |
|
| 410 | + * |
|
| 411 | + */ |
|
| 412 | + public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 413 | + global $sd_widgets, $shortcode_insert_button_once; |
|
| 414 | + if ( $shortcode_insert_button_once ) { |
|
| 415 | + return; |
|
| 416 | + } |
|
| 417 | + add_thickbox(); |
|
| 418 | 418 | |
| 419 | 419 | |
| 420 | - /** |
|
| 421 | - * Cornerstone makes us play dirty tricks :/ |
|
| 422 | - * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
|
| 423 | - */ |
|
| 424 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 425 | - echo '<span id="insert-media-button">'; |
|
| 426 | - } |
|
| 420 | + /** |
|
| 421 | + * Cornerstone makes us play dirty tricks :/ |
|
| 422 | + * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
|
| 423 | + */ |
|
| 424 | + if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 425 | + echo '<span id="insert-media-button">'; |
|
| 426 | + } |
|
| 427 | 427 | |
| 428 | - echo self::shortcode_button( 'this', 'true' ); |
|
| 428 | + echo self::shortcode_button( 'this', 'true' ); |
|
| 429 | 429 | |
| 430 | - // see opening note |
|
| 431 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 432 | - echo '</span>'; // end #insert-media-button |
|
| 433 | - } |
|
| 430 | + // see opening note |
|
| 431 | + if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 432 | + echo '</span>'; // end #insert-media-button |
|
| 433 | + } |
|
| 434 | 434 | |
| 435 | - // Add separate script for generatepress theme sections |
|
| 436 | - if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 437 | - } else { |
|
| 438 | - self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 439 | - } |
|
| 435 | + // Add separate script for generatepress theme sections |
|
| 436 | + if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 437 | + } else { |
|
| 438 | + self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 439 | + } |
|
| 440 | 440 | |
| 441 | - $shortcode_insert_button_once = true; |
|
| 442 | - } |
|
| 441 | + $shortcode_insert_button_once = true; |
|
| 442 | + } |
|
| 443 | 443 | |
| 444 | - /** |
|
| 445 | - * Gets the shortcode insert button html. |
|
| 446 | - * |
|
| 447 | - * @param string $id |
|
| 448 | - * @param string $search_for_id |
|
| 449 | - * |
|
| 450 | - * @return mixed |
|
| 451 | - */ |
|
| 452 | - public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 453 | - ob_start(); |
|
| 454 | - ?> |
|
| 444 | + /** |
|
| 445 | + * Gets the shortcode insert button html. |
|
| 446 | + * |
|
| 447 | + * @param string $id |
|
| 448 | + * @param string $search_for_id |
|
| 449 | + * |
|
| 450 | + * @return mixed |
|
| 451 | + */ |
|
| 452 | + public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 453 | + ob_start(); |
|
| 454 | + ?> |
|
| 455 | 455 | <span class="sd-lable-shortcode-inserter"> |
| 456 | 456 | <a onclick="sd_ajax_get_picker(<?php echo $id; |
| 457 | - if ( $search_for_id ) { |
|
| 458 | - echo "," . $search_for_id; |
|
| 459 | - } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
|
| 457 | + if ( $search_for_id ) { |
|
| 458 | + echo "," . $search_for_id; |
|
| 459 | + } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
|
| 460 | 460 | class="thickbox button super-duper-content-open" title="Add Shortcode"> |
| 461 | 461 | <span style="vertical-align: middle;line-height: 18px;font-size: 20px;" |
| 462 | 462 | class="dashicons dashicons-screenoptions"></span> |
@@ -467,21 +467,21 @@ discard block |
||
| 467 | 467 | </span> |
| 468 | 468 | |
| 469 | 469 | <?php |
| 470 | - $html = ob_get_clean(); |
|
| 470 | + $html = ob_get_clean(); |
|
| 471 | 471 | |
| 472 | - // remove line breaks so we can use it in js |
|
| 473 | - return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 474 | - } |
|
| 472 | + // remove line breaks so we can use it in js |
|
| 473 | + return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | - /** |
|
| 477 | - * Makes SD work with the siteOrigin page builder. |
|
| 478 | - * |
|
| 479 | - * @return mixed |
|
| 480 | - *@since 1.0.6 |
|
| 481 | - */ |
|
| 482 | - public static function siteorigin_js() { |
|
| 483 | - ob_start(); |
|
| 484 | - ?> |
|
| 476 | + /** |
|
| 477 | + * Makes SD work with the siteOrigin page builder. |
|
| 478 | + * |
|
| 479 | + * @return mixed |
|
| 480 | + *@since 1.0.6 |
|
| 481 | + */ |
|
| 482 | + public static function siteorigin_js() { |
|
| 483 | + ob_start(); |
|
| 484 | + ?> |
|
| 485 | 485 | <script> |
| 486 | 486 | /** |
| 487 | 487 | * Check a form to see what items should be shown or hidden. |
@@ -557,29 +557,29 @@ discard block |
||
| 557 | 557 | }); |
| 558 | 558 | </script> |
| 559 | 559 | <?php |
| 560 | - $output = ob_get_clean(); |
|
| 560 | + $output = ob_get_clean(); |
|
| 561 | 561 | |
| 562 | - /* |
|
| 562 | + /* |
|
| 563 | 563 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 564 | 564 | */ |
| 565 | 565 | |
| 566 | - return str_replace( array( |
|
| 567 | - '<script>', |
|
| 568 | - '</script>' |
|
| 569 | - ), '', $output ); |
|
| 570 | - } |
|
| 566 | + return str_replace( array( |
|
| 567 | + '<script>', |
|
| 568 | + '</script>' |
|
| 569 | + ), '', $output ); |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | - /** |
|
| 573 | - * Output the JS and CSS for the shortcode insert button. |
|
| 574 | - * |
|
| 575 | - * @param string $editor_id |
|
| 576 | - * @param string $insert_shortcode_function |
|
| 577 | - * |
|
| 578 | - *@since 1.0.6 |
|
| 579 | - * |
|
| 580 | - */ |
|
| 581 | - public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 582 | - ?> |
|
| 572 | + /** |
|
| 573 | + * Output the JS and CSS for the shortcode insert button. |
|
| 574 | + * |
|
| 575 | + * @param string $editor_id |
|
| 576 | + * @param string $insert_shortcode_function |
|
| 577 | + * |
|
| 578 | + *@since 1.0.6 |
|
| 579 | + * |
|
| 580 | + */ |
|
| 581 | + public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 582 | + ?> |
|
| 583 | 583 | <style> |
| 584 | 584 | .sd-shortcode-left-wrap { |
| 585 | 585 | float: left; |
@@ -707,35 +707,35 @@ discard block |
||
| 707 | 707 | <?php } ?> |
| 708 | 708 | </style> |
| 709 | 709 | <?php |
| 710 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 711 | - echo "<script>" . self::siteorigin_js() . "</script>"; |
|
| 712 | - } |
|
| 713 | - ?> |
|
| 710 | + if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 711 | + echo "<script>" . self::siteorigin_js() . "</script>"; |
|
| 712 | + } |
|
| 713 | + ?> |
|
| 714 | 714 | <script> |
| 715 | 715 | <?php |
| 716 | - if(! empty( $insert_shortcode_function )){ |
|
| 717 | - echo $insert_shortcode_function; |
|
| 718 | - }else{ |
|
| 716 | + if(! empty( $insert_shortcode_function )){ |
|
| 717 | + echo $insert_shortcode_function; |
|
| 718 | + }else{ |
|
| 719 | 719 | |
| 720 | - /** |
|
| 721 | - * Function for super duper insert shortcode. |
|
| 722 | - * |
|
| 723 | - * @since 1.0.0 |
|
| 724 | - */ |
|
| 725 | - ?> |
|
| 720 | + /** |
|
| 721 | + * Function for super duper insert shortcode. |
|
| 722 | + * |
|
| 723 | + * @since 1.0.0 |
|
| 724 | + */ |
|
| 725 | + ?> |
|
| 726 | 726 | function sd_insert_shortcode($editor_id) { |
| 727 | 727 | $shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val(); |
| 728 | 728 | if ($shortcode) { |
| 729 | 729 | if (!$editor_id) { |
| 730 | 730 | <?php |
| 731 | - if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 732 | - echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
|
| 733 | - } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 734 | - echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
|
| 735 | - } else { |
|
| 736 | - echo '$editor_id = "#wp-content-editor-container textarea";'; |
|
| 737 | - } |
|
| 738 | - ?> |
|
| 731 | + if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 732 | + echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
|
| 733 | + } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 734 | + echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
|
| 735 | + } else { |
|
| 736 | + echo '$editor_id = "#wp-content-editor-container textarea";'; |
|
| 737 | + } |
|
| 738 | + ?> |
|
| 739 | 739 | } else { |
| 740 | 740 | $editor_id = '#' + $editor_id; |
| 741 | 741 | } |
@@ -1049,18 +1049,18 @@ discard block |
||
| 1049 | 1049 | } |
| 1050 | 1050 | </script> |
| 1051 | 1051 | <?php |
| 1052 | - } |
|
| 1052 | + } |
|
| 1053 | 1053 | |
| 1054 | - /** |
|
| 1055 | - * Gets some CSS for the widgets screen. |
|
| 1056 | - * |
|
| 1057 | - * @param bool $advanced If we should include advanced CSS. |
|
| 1058 | - * |
|
| 1059 | - * @return mixed |
|
| 1060 | - */ |
|
| 1061 | - public function widget_css( $advanced = true ) { |
|
| 1062 | - ob_start(); |
|
| 1063 | - ?> |
|
| 1054 | + /** |
|
| 1055 | + * Gets some CSS for the widgets screen. |
|
| 1056 | + * |
|
| 1057 | + * @param bool $advanced If we should include advanced CSS. |
|
| 1058 | + * |
|
| 1059 | + * @return mixed |
|
| 1060 | + */ |
|
| 1061 | + public function widget_css( $advanced = true ) { |
|
| 1062 | + ob_start(); |
|
| 1063 | + ?> |
|
| 1064 | 1064 | <style> |
| 1065 | 1065 | <?php if( $advanced ){ ?> |
| 1066 | 1066 | .sd-advanced-setting { |
@@ -1100,26 +1100,26 @@ discard block |
||
| 1100 | 1100 | .elementor-control .sd-argument select[multiple] option{padding:3px} |
| 1101 | 1101 | </style> |
| 1102 | 1102 | <?php |
| 1103 | - $output = ob_get_clean(); |
|
| 1103 | + $output = ob_get_clean(); |
|
| 1104 | 1104 | |
| 1105 | - /* |
|
| 1105 | + /* |
|
| 1106 | 1106 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1107 | 1107 | */ |
| 1108 | 1108 | |
| 1109 | - return str_replace( array( |
|
| 1110 | - '<style>', |
|
| 1111 | - '</style>' |
|
| 1112 | - ), '', $output ); |
|
| 1113 | - } |
|
| 1109 | + return str_replace( array( |
|
| 1110 | + '<style>', |
|
| 1111 | + '</style>' |
|
| 1112 | + ), '', $output ); |
|
| 1113 | + } |
|
| 1114 | 1114 | |
| 1115 | - /** |
|
| 1116 | - * Gets some JS for the widgets screen. |
|
| 1117 | - * |
|
| 1118 | - * @return mixed |
|
| 1119 | - */ |
|
| 1120 | - public function widget_js() { |
|
| 1121 | - ob_start(); |
|
| 1122 | - ?> |
|
| 1115 | + /** |
|
| 1116 | + * Gets some JS for the widgets screen. |
|
| 1117 | + * |
|
| 1118 | + * @return mixed |
|
| 1119 | + */ |
|
| 1120 | + public function widget_js() { |
|
| 1121 | + ob_start(); |
|
| 1122 | + ?> |
|
| 1123 | 1123 | <script> |
| 1124 | 1124 | |
| 1125 | 1125 | /** |
@@ -1270,513 +1270,513 @@ discard block |
||
| 1270 | 1270 | <?php do_action( 'wp_super_duper_widget_js', $this ); ?> |
| 1271 | 1271 | </script> |
| 1272 | 1272 | <?php |
| 1273 | - $output = ob_get_clean(); |
|
| 1273 | + $output = ob_get_clean(); |
|
| 1274 | 1274 | |
| 1275 | - /* |
|
| 1275 | + /* |
|
| 1276 | 1276 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1277 | 1277 | */ |
| 1278 | 1278 | |
| 1279 | - return str_replace( array( |
|
| 1280 | - '<script>', |
|
| 1281 | - '</script>' |
|
| 1282 | - ), '', $output ); |
|
| 1283 | - } |
|
| 1279 | + return str_replace( array( |
|
| 1280 | + '<script>', |
|
| 1281 | + '</script>' |
|
| 1282 | + ), '', $output ); |
|
| 1283 | + } |
|
| 1284 | 1284 | |
| 1285 | 1285 | |
| 1286 | - /** |
|
| 1287 | - * Set the name from the argument key. |
|
| 1288 | - * |
|
| 1289 | - * @param $options |
|
| 1290 | - * |
|
| 1291 | - * @return mixed |
|
| 1292 | - */ |
|
| 1293 | - private function add_name_from_key( $options, $arguments = false ) { |
|
| 1294 | - if ( ! empty( $options['arguments'] ) ) { |
|
| 1295 | - foreach ( $options['arguments'] as $key => $val ) { |
|
| 1296 | - $options['arguments'][ $key ]['name'] = $key; |
|
| 1297 | - } |
|
| 1298 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1299 | - foreach ( $options as $key => $val ) { |
|
| 1300 | - $options[ $key ]['name'] = $key; |
|
| 1301 | - } |
|
| 1302 | - } |
|
| 1286 | + /** |
|
| 1287 | + * Set the name from the argument key. |
|
| 1288 | + * |
|
| 1289 | + * @param $options |
|
| 1290 | + * |
|
| 1291 | + * @return mixed |
|
| 1292 | + */ |
|
| 1293 | + private function add_name_from_key( $options, $arguments = false ) { |
|
| 1294 | + if ( ! empty( $options['arguments'] ) ) { |
|
| 1295 | + foreach ( $options['arguments'] as $key => $val ) { |
|
| 1296 | + $options['arguments'][ $key ]['name'] = $key; |
|
| 1297 | + } |
|
| 1298 | + } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1299 | + foreach ( $options as $key => $val ) { |
|
| 1300 | + $options[ $key ]['name'] = $key; |
|
| 1301 | + } |
|
| 1302 | + } |
|
| 1303 | 1303 | |
| 1304 | - return $options; |
|
| 1305 | - } |
|
| 1304 | + return $options; |
|
| 1305 | + } |
|
| 1306 | 1306 | |
| 1307 | - /** |
|
| 1308 | - * Register the parent shortcode. |
|
| 1309 | - * |
|
| 1310 | - * @since 1.0.0 |
|
| 1311 | - */ |
|
| 1312 | - public function register_shortcode() { |
|
| 1313 | - add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1314 | - add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) ); |
|
| 1315 | - } |
|
| 1307 | + /** |
|
| 1308 | + * Register the parent shortcode. |
|
| 1309 | + * |
|
| 1310 | + * @since 1.0.0 |
|
| 1311 | + */ |
|
| 1312 | + public function register_shortcode() { |
|
| 1313 | + add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1314 | + add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) ); |
|
| 1315 | + } |
|
| 1316 | 1316 | |
| 1317 | - /** |
|
| 1318 | - * Render the shortcode via ajax so we can return it to Gutenberg. |
|
| 1319 | - * |
|
| 1320 | - * @since 1.0.0 |
|
| 1321 | - */ |
|
| 1322 | - public function render_shortcode() { |
|
| 1323 | - check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1324 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1325 | - wp_die(); |
|
| 1326 | - } |
|
| 1317 | + /** |
|
| 1318 | + * Render the shortcode via ajax so we can return it to Gutenberg. |
|
| 1319 | + * |
|
| 1320 | + * @since 1.0.0 |
|
| 1321 | + */ |
|
| 1322 | + public function render_shortcode() { |
|
| 1323 | + check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1324 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1325 | + wp_die(); |
|
| 1326 | + } |
|
| 1327 | 1327 | |
| 1328 | - // we might need the $post value here so lets set it. |
|
| 1329 | - if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1330 | - $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1331 | - if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1332 | - global $post; |
|
| 1333 | - $post = $post_obj; |
|
| 1334 | - } |
|
| 1335 | - } |
|
| 1328 | + // we might need the $post value here so lets set it. |
|
| 1329 | + if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1330 | + $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1331 | + if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1332 | + global $post; |
|
| 1333 | + $post = $post_obj; |
|
| 1334 | + } |
|
| 1335 | + } |
|
| 1336 | 1336 | |
| 1337 | - if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1338 | - $is_preview = $this->is_preview(); |
|
| 1339 | - $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1340 | - $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1341 | - $attributes = ''; |
|
| 1342 | - if ( ! empty( $attributes_array ) ) { |
|
| 1343 | - foreach ( $attributes_array as $key => $value ) { |
|
| 1344 | - if ( is_array( $value ) ) { |
|
| 1345 | - $value = implode( ",", $value ); |
|
| 1346 | - } |
|
| 1337 | + if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1338 | + $is_preview = $this->is_preview(); |
|
| 1339 | + $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1340 | + $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1341 | + $attributes = ''; |
|
| 1342 | + if ( ! empty( $attributes_array ) ) { |
|
| 1343 | + foreach ( $attributes_array as $key => $value ) { |
|
| 1344 | + if ( is_array( $value ) ) { |
|
| 1345 | + $value = implode( ",", $value ); |
|
| 1346 | + } |
|
| 1347 | 1347 | |
| 1348 | - if ( ! empty( $value ) ) { |
|
| 1349 | - $value = wp_unslash( $value ); |
|
| 1348 | + if ( ! empty( $value ) ) { |
|
| 1349 | + $value = wp_unslash( $value ); |
|
| 1350 | 1350 | |
| 1351 | - // Encode [ and ]. |
|
| 1352 | - if ( $is_preview ) { |
|
| 1353 | - $value = $this->encode_shortcodes( $value ); |
|
| 1354 | - } |
|
| 1355 | - } |
|
| 1356 | - $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . esc_attr( $value ) . "' "; |
|
| 1357 | - } |
|
| 1358 | - } |
|
| 1351 | + // Encode [ and ]. |
|
| 1352 | + if ( $is_preview ) { |
|
| 1353 | + $value = $this->encode_shortcodes( $value ); |
|
| 1354 | + } |
|
| 1355 | + } |
|
| 1356 | + $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . esc_attr( $value ) . "' "; |
|
| 1357 | + } |
|
| 1358 | + } |
|
| 1359 | 1359 | |
| 1360 | - $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
|
| 1360 | + $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
|
| 1361 | 1361 | |
| 1362 | - $content = do_shortcode( $shortcode ); |
|
| 1362 | + $content = do_shortcode( $shortcode ); |
|
| 1363 | 1363 | |
| 1364 | - // Decode [ and ]. |
|
| 1365 | - if ( ! empty( $content ) && $is_preview ) { |
|
| 1366 | - $content = $this->decode_shortcodes( $content ); |
|
| 1367 | - } |
|
| 1364 | + // Decode [ and ]. |
|
| 1365 | + if ( ! empty( $content ) && $is_preview ) { |
|
| 1366 | + $content = $this->decode_shortcodes( $content ); |
|
| 1367 | + } |
|
| 1368 | 1368 | |
| 1369 | - echo $content; |
|
| 1370 | - } |
|
| 1371 | - wp_die(); |
|
| 1372 | - } |
|
| 1369 | + echo $content; |
|
| 1370 | + } |
|
| 1371 | + wp_die(); |
|
| 1372 | + } |
|
| 1373 | 1373 | |
| 1374 | - /** |
|
| 1375 | - * Output the shortcode. |
|
| 1376 | - * |
|
| 1377 | - * @param array $args |
|
| 1378 | - * @param string $content |
|
| 1379 | - * |
|
| 1380 | - * @return string |
|
| 1381 | - */ |
|
| 1382 | - public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1383 | - $_instance = $args; |
|
| 1384 | - |
|
| 1385 | - $args = $this->argument_values( $args ); |
|
| 1386 | - |
|
| 1387 | - // add extra argument so we know its a output to gutenberg |
|
| 1388 | - //$args |
|
| 1389 | - $args = $this->string_to_bool( $args ); |
|
| 1390 | - |
|
| 1391 | - // if we have a enclosed shortcode we add it to the special `html` argument |
|
| 1392 | - if ( ! empty( $content ) ) { |
|
| 1393 | - $args['html'] = $content; |
|
| 1394 | - } |
|
| 1374 | + /** |
|
| 1375 | + * Output the shortcode. |
|
| 1376 | + * |
|
| 1377 | + * @param array $args |
|
| 1378 | + * @param string $content |
|
| 1379 | + * |
|
| 1380 | + * @return string |
|
| 1381 | + */ |
|
| 1382 | + public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1383 | + $_instance = $args; |
|
| 1395 | 1384 | |
| 1396 | - if ( ! $this->is_preview() ) { |
|
| 1397 | - /** |
|
| 1398 | - * Filters the settings for a particular widget args. |
|
| 1399 | - * |
|
| 1400 | - * @param array $args The current widget instance's settings. |
|
| 1401 | - * @param WP_Super_Duper $widget The current widget settings. |
|
| 1402 | - * @param array $_instance An array of default widget arguments. |
|
| 1403 | - * |
|
| 1404 | - *@since 1.0.28 |
|
| 1405 | - * |
|
| 1406 | - */ |
|
| 1407 | - $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance ); |
|
| 1385 | + $args = $this->argument_values( $args ); |
|
| 1408 | 1386 | |
| 1409 | - if ( ! is_array( $args ) ) { |
|
| 1410 | - return $args; |
|
| 1411 | - } |
|
| 1412 | - } |
|
| 1387 | + // add extra argument so we know its a output to gutenberg |
|
| 1388 | + //$args |
|
| 1389 | + $args = $this->string_to_bool( $args ); |
|
| 1413 | 1390 | |
| 1414 | - $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1415 | - $class .= " sdel-".$this->get_instance_hash(); |
|
| 1391 | + // if we have a enclosed shortcode we add it to the special `html` argument |
|
| 1392 | + if ( ! empty( $content ) ) { |
|
| 1393 | + $args['html'] = $content; |
|
| 1394 | + } |
|
| 1416 | 1395 | |
| 1417 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1418 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1396 | + if ( ! $this->is_preview() ) { |
|
| 1397 | + /** |
|
| 1398 | + * Filters the settings for a particular widget args. |
|
| 1399 | + * |
|
| 1400 | + * @param array $args The current widget instance's settings. |
|
| 1401 | + * @param WP_Super_Duper $widget The current widget settings. |
|
| 1402 | + * @param array $_instance An array of default widget arguments. |
|
| 1403 | + * |
|
| 1404 | + *@since 1.0.28 |
|
| 1405 | + * |
|
| 1406 | + */ |
|
| 1407 | + $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance ); |
|
| 1408 | + |
|
| 1409 | + if ( ! is_array( $args ) ) { |
|
| 1410 | + return $args; |
|
| 1411 | + } |
|
| 1412 | + } |
|
| 1419 | 1413 | |
| 1420 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1421 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 1414 | + $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1415 | + $class .= " sdel-".$this->get_instance_hash(); |
|
| 1422 | 1416 | |
| 1423 | - $shortcode_args = array(); |
|
| 1424 | - $output = ''; |
|
| 1425 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1426 | - if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1427 | - $no_wrap = true; |
|
| 1428 | - } |
|
| 1429 | - $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1430 | - if ( $main_content && ! $no_wrap ) { |
|
| 1431 | - // wrap the shortcode in a div with the same class as the widget |
|
| 1432 | - $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
|
| 1433 | - if ( ! empty( $args['title'] ) ) { |
|
| 1434 | - // if its a shortcode and there is a title try to grab the title wrappers |
|
| 1435 | - $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1436 | - if ( empty( $instance ) ) { |
|
| 1437 | - global $wp_registered_sidebars; |
|
| 1438 | - if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1439 | - foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1440 | - if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1441 | - $shortcode_args['before_title'] = $sidebar['before_title']; |
|
| 1442 | - $shortcode_args['after_title'] = $sidebar['after_title']; |
|
| 1443 | - break; |
|
| 1444 | - } |
|
| 1445 | - } |
|
| 1446 | - } |
|
| 1447 | - } |
|
| 1448 | - $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1449 | - } |
|
| 1450 | - $output .= $main_content; |
|
| 1451 | - $output .= '</div>'; |
|
| 1452 | - } elseif ( $main_content && $no_wrap ) { |
|
| 1453 | - $output .= $main_content; |
|
| 1454 | - } |
|
| 1417 | + $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1418 | + $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1455 | 1419 | |
| 1456 | - // if preview show a placeholder if empty |
|
| 1457 | - if ( $this->is_preview() && $output == '' ) { |
|
| 1458 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1459 | - } |
|
| 1420 | + $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1421 | + $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 1460 | 1422 | |
| 1461 | - return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1462 | - } |
|
| 1423 | + $shortcode_args = array(); |
|
| 1424 | + $output = ''; |
|
| 1425 | + $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1426 | + if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1427 | + $no_wrap = true; |
|
| 1428 | + } |
|
| 1429 | + $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1430 | + if ( $main_content && ! $no_wrap ) { |
|
| 1431 | + // wrap the shortcode in a div with the same class as the widget |
|
| 1432 | + $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
|
| 1433 | + if ( ! empty( $args['title'] ) ) { |
|
| 1434 | + // if its a shortcode and there is a title try to grab the title wrappers |
|
| 1435 | + $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1436 | + if ( empty( $instance ) ) { |
|
| 1437 | + global $wp_registered_sidebars; |
|
| 1438 | + if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1439 | + foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1440 | + if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1441 | + $shortcode_args['before_title'] = $sidebar['before_title']; |
|
| 1442 | + $shortcode_args['after_title'] = $sidebar['after_title']; |
|
| 1443 | + break; |
|
| 1444 | + } |
|
| 1445 | + } |
|
| 1446 | + } |
|
| 1447 | + } |
|
| 1448 | + $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1449 | + } |
|
| 1450 | + $output .= $main_content; |
|
| 1451 | + $output .= '</div>'; |
|
| 1452 | + } elseif ( $main_content && $no_wrap ) { |
|
| 1453 | + $output .= $main_content; |
|
| 1454 | + } |
|
| 1463 | 1455 | |
| 1464 | - /** |
|
| 1465 | - * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
| 1466 | - * |
|
| 1467 | - * @param string $name |
|
| 1468 | - * |
|
| 1469 | - * @return string |
|
| 1470 | - */ |
|
| 1471 | - public function preview_placeholder_text( $name = '' ) { |
|
| 1472 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "</div>"; |
|
| 1473 | - } |
|
| 1456 | + // if preview show a placeholder if empty |
|
| 1457 | + if ( $this->is_preview() && $output == '' ) { |
|
| 1458 | + $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1459 | + } |
|
| 1474 | 1460 | |
| 1475 | - /** |
|
| 1476 | - * Sometimes booleans values can be turned to strings, so we fix that. |
|
| 1477 | - * |
|
| 1478 | - * @param $options |
|
| 1479 | - * |
|
| 1480 | - * @return mixed |
|
| 1481 | - */ |
|
| 1482 | - public function string_to_bool( $options ) { |
|
| 1483 | - // convert bool strings to booleans |
|
| 1484 | - foreach ( $options as $key => $val ) { |
|
| 1485 | - if ( $val == 'false' ) { |
|
| 1486 | - $options[ $key ] = false; |
|
| 1487 | - } elseif ( $val == 'true' ) { |
|
| 1488 | - $options[ $key ] = true; |
|
| 1489 | - } |
|
| 1490 | - } |
|
| 1461 | + return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1462 | + } |
|
| 1491 | 1463 | |
| 1492 | - return $options; |
|
| 1493 | - } |
|
| 1464 | + /** |
|
| 1465 | + * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
| 1466 | + * |
|
| 1467 | + * @param string $name |
|
| 1468 | + * |
|
| 1469 | + * @return string |
|
| 1470 | + */ |
|
| 1471 | + public function preview_placeholder_text( $name = '' ) { |
|
| 1472 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "</div>"; |
|
| 1473 | + } |
|
| 1494 | 1474 | |
| 1495 | - /** |
|
| 1496 | - * Get the argument values that are also filterable. |
|
| 1497 | - * |
|
| 1498 | - * @param $instance |
|
| 1499 | - * |
|
| 1500 | - * @return array |
|
| 1501 | - *@since 1.0.12 Don't set checkbox default value if the value is empty. |
|
| 1502 | - * |
|
| 1503 | - */ |
|
| 1504 | - public function argument_values( $instance ) { |
|
| 1505 | - $argument_values = array(); |
|
| 1506 | - |
|
| 1507 | - // set widget instance |
|
| 1508 | - $this->instance = $instance; |
|
| 1509 | - |
|
| 1510 | - if ( empty( $this->arguments ) ) { |
|
| 1511 | - $this->arguments = $this->get_arguments(); |
|
| 1512 | - } |
|
| 1475 | + /** |
|
| 1476 | + * Sometimes booleans values can be turned to strings, so we fix that. |
|
| 1477 | + * |
|
| 1478 | + * @param $options |
|
| 1479 | + * |
|
| 1480 | + * @return mixed |
|
| 1481 | + */ |
|
| 1482 | + public function string_to_bool( $options ) { |
|
| 1483 | + // convert bool strings to booleans |
|
| 1484 | + foreach ( $options as $key => $val ) { |
|
| 1485 | + if ( $val == 'false' ) { |
|
| 1486 | + $options[ $key ] = false; |
|
| 1487 | + } elseif ( $val == 'true' ) { |
|
| 1488 | + $options[ $key ] = true; |
|
| 1489 | + } |
|
| 1490 | + } |
|
| 1513 | 1491 | |
| 1514 | - if ( ! empty( $this->arguments ) ) { |
|
| 1515 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1516 | - // set the input name from the key |
|
| 1517 | - $args['name'] = $key; |
|
| 1518 | - // |
|
| 1519 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1520 | - if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1521 | - // don't set default for an empty checkbox |
|
| 1522 | - } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1523 | - $argument_values[ $key ] = $args['default']; |
|
| 1524 | - } |
|
| 1525 | - } |
|
| 1526 | - } |
|
| 1492 | + return $options; |
|
| 1493 | + } |
|
| 1527 | 1494 | |
| 1528 | - return $argument_values; |
|
| 1529 | - } |
|
| 1495 | + /** |
|
| 1496 | + * Get the argument values that are also filterable. |
|
| 1497 | + * |
|
| 1498 | + * @param $instance |
|
| 1499 | + * |
|
| 1500 | + * @return array |
|
| 1501 | + *@since 1.0.12 Don't set checkbox default value if the value is empty. |
|
| 1502 | + * |
|
| 1503 | + */ |
|
| 1504 | + public function argument_values( $instance ) { |
|
| 1505 | + $argument_values = array(); |
|
| 1530 | 1506 | |
| 1531 | - /** |
|
| 1532 | - * Set arguments in super duper. |
|
| 1533 | - * |
|
| 1534 | - * @return array Set arguments. |
|
| 1535 | - *@since 1.0.0 |
|
| 1536 | - * |
|
| 1537 | - */ |
|
| 1538 | - public function set_arguments() { |
|
| 1539 | - return $this->arguments; |
|
| 1540 | - } |
|
| 1507 | + // set widget instance |
|
| 1508 | + $this->instance = $instance; |
|
| 1541 | 1509 | |
| 1542 | - /** |
|
| 1543 | - * Get arguments in super duper. |
|
| 1544 | - * |
|
| 1545 | - * @return array Get arguments. |
|
| 1546 | - *@since 1.0.0 |
|
| 1547 | - * |
|
| 1548 | - */ |
|
| 1549 | - public function get_arguments() { |
|
| 1550 | - if ( empty( $this->arguments ) ) { |
|
| 1551 | - $this->arguments = $this->set_arguments(); |
|
| 1552 | - } |
|
| 1510 | + if ( empty( $this->arguments ) ) { |
|
| 1511 | + $this->arguments = $this->get_arguments(); |
|
| 1512 | + } |
|
| 1553 | 1513 | |
| 1554 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1555 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1514 | + if ( ! empty( $this->arguments ) ) { |
|
| 1515 | + foreach ( $this->arguments as $key => $args ) { |
|
| 1516 | + // set the input name from the key |
|
| 1517 | + $args['name'] = $key; |
|
| 1518 | + // |
|
| 1519 | + $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1520 | + if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1521 | + // don't set default for an empty checkbox |
|
| 1522 | + } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1523 | + $argument_values[ $key ] = $args['default']; |
|
| 1524 | + } |
|
| 1525 | + } |
|
| 1526 | + } |
|
| 1556 | 1527 | |
| 1557 | - return $this->arguments; |
|
| 1558 | - } |
|
| 1528 | + return $argument_values; |
|
| 1529 | + } |
|
| 1559 | 1530 | |
| 1560 | - /** |
|
| 1561 | - * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
| 1562 | - * |
|
| 1563 | - * @param array $args |
|
| 1564 | - * @param array $widget_args |
|
| 1565 | - * @param string $content |
|
| 1566 | - */ |
|
| 1567 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1531 | + /** |
|
| 1532 | + * Set arguments in super duper. |
|
| 1533 | + * |
|
| 1534 | + * @return array Set arguments. |
|
| 1535 | + *@since 1.0.0 |
|
| 1536 | + * |
|
| 1537 | + */ |
|
| 1538 | + public function set_arguments() { |
|
| 1539 | + return $this->arguments; |
|
| 1540 | + } |
|
| 1568 | 1541 | |
| 1569 | - } |
|
| 1542 | + /** |
|
| 1543 | + * Get arguments in super duper. |
|
| 1544 | + * |
|
| 1545 | + * @return array Get arguments. |
|
| 1546 | + *@since 1.0.0 |
|
| 1547 | + * |
|
| 1548 | + */ |
|
| 1549 | + public function get_arguments() { |
|
| 1550 | + if ( empty( $this->arguments ) ) { |
|
| 1551 | + $this->arguments = $this->set_arguments(); |
|
| 1552 | + } |
|
| 1570 | 1553 | |
| 1571 | - /** |
|
| 1572 | - * Add the dynamic block code inline when the wp-block in enqueued. |
|
| 1573 | - */ |
|
| 1574 | - public function register_block() { |
|
| 1575 | - wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1576 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1577 | - wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1578 | - } |
|
| 1579 | - } |
|
| 1554 | + $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1555 | + $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1580 | 1556 | |
| 1581 | - /** |
|
| 1582 | - * Check if we need to show advanced options. |
|
| 1583 | - * |
|
| 1584 | - * @return bool |
|
| 1585 | - */ |
|
| 1586 | - public function block_show_advanced() { |
|
| 1587 | - |
|
| 1588 | - $show = false; |
|
| 1589 | - $arguments = $this->get_arguments(); |
|
| 1590 | - |
|
| 1591 | - if ( ! empty( $arguments ) ) { |
|
| 1592 | - foreach ( $arguments as $argument ) { |
|
| 1593 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1594 | - $show = true; |
|
| 1595 | - break; // no need to continue if we know we have it |
|
| 1596 | - } |
|
| 1597 | - } |
|
| 1598 | - } |
|
| 1557 | + return $this->arguments; |
|
| 1558 | + } |
|
| 1599 | 1559 | |
| 1600 | - return $show; |
|
| 1601 | - } |
|
| 1560 | + /** |
|
| 1561 | + * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
| 1562 | + * |
|
| 1563 | + * @param array $args |
|
| 1564 | + * @param array $widget_args |
|
| 1565 | + * @param string $content |
|
| 1566 | + */ |
|
| 1567 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1602 | 1568 | |
| 1603 | - /** |
|
| 1604 | - * Get the url path to the current folder. |
|
| 1605 | - * |
|
| 1606 | - * @return string |
|
| 1607 | - */ |
|
| 1608 | - public function get_url() { |
|
| 1609 | - $url = $this->url; |
|
| 1610 | - |
|
| 1611 | - if ( ! $url ) { |
|
| 1612 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1613 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1614 | - |
|
| 1615 | - // Replace http:// to https://. |
|
| 1616 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1617 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1618 | - } |
|
| 1569 | + } |
|
| 1619 | 1570 | |
| 1620 | - // Check if we are inside a plugin |
|
| 1621 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1622 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1623 | - $url = trailingslashit( $url ); |
|
| 1624 | - $this->url = $url; |
|
| 1625 | - } |
|
| 1571 | + /** |
|
| 1572 | + * Add the dynamic block code inline when the wp-block in enqueued. |
|
| 1573 | + */ |
|
| 1574 | + public function register_block() { |
|
| 1575 | + wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1576 | + if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1577 | + wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1578 | + } |
|
| 1579 | + } |
|
| 1626 | 1580 | |
| 1627 | - return $url; |
|
| 1628 | - } |
|
| 1581 | + /** |
|
| 1582 | + * Check if we need to show advanced options. |
|
| 1583 | + * |
|
| 1584 | + * @return bool |
|
| 1585 | + */ |
|
| 1586 | + public function block_show_advanced() { |
|
| 1629 | 1587 | |
| 1630 | - /** |
|
| 1631 | - * Get the url path to the current folder. |
|
| 1632 | - * |
|
| 1633 | - * @return string |
|
| 1634 | - */ |
|
| 1635 | - public function get_url_old() { |
|
| 1588 | + $show = false; |
|
| 1589 | + $arguments = $this->get_arguments(); |
|
| 1636 | 1590 | |
| 1637 | - $url = $this->url; |
|
| 1591 | + if ( ! empty( $arguments ) ) { |
|
| 1592 | + foreach ( $arguments as $argument ) { |
|
| 1593 | + if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1594 | + $show = true; |
|
| 1595 | + break; // no need to continue if we know we have it |
|
| 1596 | + } |
|
| 1597 | + } |
|
| 1598 | + } |
|
| 1638 | 1599 | |
| 1639 | - if ( ! $url ) { |
|
| 1640 | - // check if we are inside a plugin |
|
| 1641 | - $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1600 | + return $show; |
|
| 1601 | + } |
|
| 1642 | 1602 | |
| 1643 | - $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1644 | - $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1603 | + /** |
|
| 1604 | + * Get the url path to the current folder. |
|
| 1605 | + * |
|
| 1606 | + * @return string |
|
| 1607 | + */ |
|
| 1608 | + public function get_url() { |
|
| 1609 | + $url = $this->url; |
|
| 1645 | 1610 | |
| 1646 | - if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1647 | - $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1648 | - $this->url = $url; |
|
| 1649 | - } |
|
| 1650 | - } |
|
| 1611 | + if ( ! $url ) { |
|
| 1612 | + $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1613 | + $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1651 | 1614 | |
| 1615 | + // Replace http:// to https://. |
|
| 1616 | + if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1617 | + $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1618 | + } |
|
| 1652 | 1619 | |
| 1653 | - return $url; |
|
| 1654 | - } |
|
| 1620 | + // Check if we are inside a plugin |
|
| 1621 | + $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1622 | + $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1623 | + $url = trailingslashit( $url ); |
|
| 1624 | + $this->url = $url; |
|
| 1625 | + } |
|
| 1655 | 1626 | |
| 1656 | - /** |
|
| 1657 | - * Generate the block icon. |
|
| 1658 | - * |
|
| 1659 | - * Enables the use of Font Awesome icons. |
|
| 1660 | - * |
|
| 1661 | - * @note xlink:href is actually deprecated but href is not supported by all so we use both. |
|
| 1662 | - * |
|
| 1663 | - * @param $icon |
|
| 1664 | - * |
|
| 1665 | - * @return string |
|
| 1666 | - *@since 1.1.0 |
|
| 1667 | - */ |
|
| 1668 | - public function get_block_icon( $icon ) { |
|
| 1669 | - |
|
| 1670 | - // check if we have a Font Awesome icon |
|
| 1671 | - $fa_type = ''; |
|
| 1672 | - if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1673 | - $fa_type = 'solid'; |
|
| 1674 | - } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1675 | - $fa_type = 'regular'; |
|
| 1676 | - } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1677 | - $fa_type = 'brands'; |
|
| 1678 | - } else { |
|
| 1679 | - $icon = "'" . $icon . "'"; |
|
| 1680 | - } |
|
| 1627 | + return $url; |
|
| 1628 | + } |
|
| 1681 | 1629 | |
| 1682 | - // set the icon if we found one |
|
| 1683 | - if ( $fa_type ) { |
|
| 1684 | - $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1685 | - $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; |
|
| 1686 | - } |
|
| 1630 | + /** |
|
| 1631 | + * Get the url path to the current folder. |
|
| 1632 | + * |
|
| 1633 | + * @return string |
|
| 1634 | + */ |
|
| 1635 | + public function get_url_old() { |
|
| 1687 | 1636 | |
| 1688 | - return $icon; |
|
| 1689 | - } |
|
| 1637 | + $url = $this->url; |
|
| 1690 | 1638 | |
| 1691 | - public function group_arguments( $arguments ) { |
|
| 1692 | - if ( ! empty( $arguments ) ) { |
|
| 1693 | - $temp_arguments = array(); |
|
| 1694 | - $general = __( "General", 'ayecode-connect' ); |
|
| 1695 | - $add_sections = false; |
|
| 1696 | - foreach ( $arguments as $key => $args ) { |
|
| 1697 | - if ( isset( $args['group'] ) ) { |
|
| 1698 | - $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1699 | - $add_sections = true; |
|
| 1700 | - } else { |
|
| 1701 | - $temp_arguments[ $general ][ $key ] = $args; |
|
| 1702 | - } |
|
| 1703 | - } |
|
| 1639 | + if ( ! $url ) { |
|
| 1640 | + // check if we are inside a plugin |
|
| 1641 | + $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1704 | 1642 | |
| 1705 | - // only add sections if more than one |
|
| 1706 | - if ( $add_sections ) { |
|
| 1707 | - $arguments = $temp_arguments; |
|
| 1708 | - } |
|
| 1709 | - } |
|
| 1643 | + $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1644 | + $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1710 | 1645 | |
| 1711 | - return $arguments; |
|
| 1712 | - } |
|
| 1646 | + if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1647 | + $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1648 | + $this->url = $url; |
|
| 1649 | + } |
|
| 1650 | + } |
|
| 1713 | 1651 | |
| 1714 | - /** |
|
| 1715 | - * Parse used group tabs. |
|
| 1716 | - * |
|
| 1717 | - * @since 1.1.17 |
|
| 1718 | - */ |
|
| 1719 | - public function group_block_tabs( $tabs, $arguments ) { |
|
| 1720 | - if ( ! empty( $tabs ) && ! empty( $arguments ) ) { |
|
| 1721 | - $has_sections = false; |
|
| 1722 | - |
|
| 1723 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1724 | - if ( isset( $args['group'] ) ) { |
|
| 1725 | - $has_sections = true; |
|
| 1726 | - break; |
|
| 1727 | - } |
|
| 1728 | - } |
|
| 1729 | 1652 | |
| 1730 | - if ( ! $has_sections ) { |
|
| 1731 | - return $tabs; |
|
| 1732 | - } |
|
| 1653 | + return $url; |
|
| 1654 | + } |
|
| 1733 | 1655 | |
| 1734 | - $new_tabs = array(); |
|
| 1656 | + /** |
|
| 1657 | + * Generate the block icon. |
|
| 1658 | + * |
|
| 1659 | + * Enables the use of Font Awesome icons. |
|
| 1660 | + * |
|
| 1661 | + * @note xlink:href is actually deprecated but href is not supported by all so we use both. |
|
| 1662 | + * |
|
| 1663 | + * @param $icon |
|
| 1664 | + * |
|
| 1665 | + * @return string |
|
| 1666 | + *@since 1.1.0 |
|
| 1667 | + */ |
|
| 1668 | + public function get_block_icon( $icon ) { |
|
| 1669 | + |
|
| 1670 | + // check if we have a Font Awesome icon |
|
| 1671 | + $fa_type = ''; |
|
| 1672 | + if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1673 | + $fa_type = 'solid'; |
|
| 1674 | + } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1675 | + $fa_type = 'regular'; |
|
| 1676 | + } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1677 | + $fa_type = 'brands'; |
|
| 1678 | + } else { |
|
| 1679 | + $icon = "'" . $icon . "'"; |
|
| 1680 | + } |
|
| 1735 | 1681 | |
| 1736 | - foreach ( $tabs as $tab_key => $tab ) { |
|
| 1737 | - $new_groups = array(); |
|
| 1682 | + // set the icon if we found one |
|
| 1683 | + if ( $fa_type ) { |
|
| 1684 | + $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1685 | + $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; |
|
| 1686 | + } |
|
| 1738 | 1687 | |
| 1739 | - if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) { |
|
| 1740 | - foreach ( $tab['groups'] as $group ) { |
|
| 1741 | - if ( isset( $arguments[ $group ] ) ) { |
|
| 1742 | - $new_groups[] = $group; |
|
| 1743 | - } |
|
| 1744 | - } |
|
| 1745 | - } |
|
| 1688 | + return $icon; |
|
| 1689 | + } |
|
| 1746 | 1690 | |
| 1747 | - if ( ! empty( $new_groups ) ) { |
|
| 1748 | - $tab['groups'] = $new_groups; |
|
| 1691 | + public function group_arguments( $arguments ) { |
|
| 1692 | + if ( ! empty( $arguments ) ) { |
|
| 1693 | + $temp_arguments = array(); |
|
| 1694 | + $general = __( "General", 'ayecode-connect' ); |
|
| 1695 | + $add_sections = false; |
|
| 1696 | + foreach ( $arguments as $key => $args ) { |
|
| 1697 | + if ( isset( $args['group'] ) ) { |
|
| 1698 | + $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1699 | + $add_sections = true; |
|
| 1700 | + } else { |
|
| 1701 | + $temp_arguments[ $general ][ $key ] = $args; |
|
| 1702 | + } |
|
| 1703 | + } |
|
| 1749 | 1704 | |
| 1750 | - $new_tabs[ $tab_key ] = $tab; |
|
| 1751 | - } |
|
| 1752 | - } |
|
| 1705 | + // only add sections if more than one |
|
| 1706 | + if ( $add_sections ) { |
|
| 1707 | + $arguments = $temp_arguments; |
|
| 1708 | + } |
|
| 1709 | + } |
|
| 1753 | 1710 | |
| 1754 | - $tabs = $new_tabs; |
|
| 1755 | - } |
|
| 1711 | + return $arguments; |
|
| 1712 | + } |
|
| 1756 | 1713 | |
| 1757 | - return $tabs; |
|
| 1758 | - } |
|
| 1714 | + /** |
|
| 1715 | + * Parse used group tabs. |
|
| 1716 | + * |
|
| 1717 | + * @since 1.1.17 |
|
| 1718 | + */ |
|
| 1719 | + public function group_block_tabs( $tabs, $arguments ) { |
|
| 1720 | + if ( ! empty( $tabs ) && ! empty( $arguments ) ) { |
|
| 1721 | + $has_sections = false; |
|
| 1722 | + |
|
| 1723 | + foreach ( $this->arguments as $key => $args ) { |
|
| 1724 | + if ( isset( $args['group'] ) ) { |
|
| 1725 | + $has_sections = true; |
|
| 1726 | + break; |
|
| 1727 | + } |
|
| 1728 | + } |
|
| 1729 | + |
|
| 1730 | + if ( ! $has_sections ) { |
|
| 1731 | + return $tabs; |
|
| 1732 | + } |
|
| 1733 | + |
|
| 1734 | + $new_tabs = array(); |
|
| 1735 | + |
|
| 1736 | + foreach ( $tabs as $tab_key => $tab ) { |
|
| 1737 | + $new_groups = array(); |
|
| 1738 | + |
|
| 1739 | + if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) { |
|
| 1740 | + foreach ( $tab['groups'] as $group ) { |
|
| 1741 | + if ( isset( $arguments[ $group ] ) ) { |
|
| 1742 | + $new_groups[] = $group; |
|
| 1743 | + } |
|
| 1744 | + } |
|
| 1745 | + } |
|
| 1746 | + |
|
| 1747 | + if ( ! empty( $new_groups ) ) { |
|
| 1748 | + $tab['groups'] = $new_groups; |
|
| 1749 | + |
|
| 1750 | + $new_tabs[ $tab_key ] = $tab; |
|
| 1751 | + } |
|
| 1752 | + } |
|
| 1753 | + |
|
| 1754 | + $tabs = $new_tabs; |
|
| 1755 | + } |
|
| 1759 | 1756 | |
| 1760 | - /** |
|
| 1761 | - * Output the JS for building the dynamic Guntenberg block. |
|
| 1762 | - * |
|
| 1763 | - * @return mixed |
|
| 1764 | - *@since 1.0.9 Save numbers as numbers and not strings. |
|
| 1765 | - * @since 1.1.0 Font Awesome classes can be used for icons. |
|
| 1766 | - * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. |
|
| 1767 | - */ |
|
| 1768 | - public function block() { |
|
| 1769 | - global $sd_is_js_functions_loaded, $aui_bs5; |
|
| 1770 | - |
|
| 1771 | - $show_advanced = $this->block_show_advanced(); |
|
| 1772 | - |
|
| 1773 | - ob_start(); |
|
| 1774 | - ?> |
|
| 1757 | + return $tabs; |
|
| 1758 | + } |
|
| 1759 | + |
|
| 1760 | + /** |
|
| 1761 | + * Output the JS for building the dynamic Guntenberg block. |
|
| 1762 | + * |
|
| 1763 | + * @return mixed |
|
| 1764 | + *@since 1.0.9 Save numbers as numbers and not strings. |
|
| 1765 | + * @since 1.1.0 Font Awesome classes can be used for icons. |
|
| 1766 | + * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. |
|
| 1767 | + */ |
|
| 1768 | + public function block() { |
|
| 1769 | + global $sd_is_js_functions_loaded, $aui_bs5; |
|
| 1770 | + |
|
| 1771 | + $show_advanced = $this->block_show_advanced(); |
|
| 1772 | + |
|
| 1773 | + ob_start(); |
|
| 1774 | + ?> |
|
| 1775 | 1775 | <script> |
| 1776 | 1776 | <?php |
| 1777 | - if ( ! $sd_is_js_functions_loaded ) { |
|
| 1778 | - $sd_is_js_functions_loaded = true; |
|
| 1779 | - ?> |
|
| 1777 | + if ( ! $sd_is_js_functions_loaded ) { |
|
| 1778 | + $sd_is_js_functions_loaded = true; |
|
| 1779 | + ?> |
|
| 1780 | 1780 | function sd_show_view_options($this){ |
| 1781 | 1781 | if(jQuery($this).html().length){ |
| 1782 | 1782 | jQuery($this).html(''); |
@@ -2226,8 +2226,8 @@ discard block |
||
| 2226 | 2226 | $classes = []; |
| 2227 | 2227 | |
| 2228 | 2228 | <?php |
| 2229 | - if($aui_bs5){ |
|
| 2230 | - ?> |
|
| 2229 | + if($aui_bs5){ |
|
| 2230 | + ?> |
|
| 2231 | 2231 | $aui_bs5 = true; |
| 2232 | 2232 | $p_ml = 'ms-'; |
| 2233 | 2233 | $p_mr = 'me-'; |
@@ -2235,8 +2235,8 @@ discard block |
||
| 2235 | 2235 | $p_pl = 'ps-'; |
| 2236 | 2236 | $p_pr = 'pe-'; |
| 2237 | 2237 | <?php |
| 2238 | - }else{ |
|
| 2239 | - ?> |
|
| 2238 | + }else{ |
|
| 2239 | + ?> |
|
| 2240 | 2240 | $aui_bs5 = false; |
| 2241 | 2241 | $p_ml = 'ml-'; |
| 2242 | 2242 | $p_mr = 'mr-'; |
@@ -2244,8 +2244,8 @@ discard block |
||
| 2244 | 2244 | $p_pl = 'pl-'; |
| 2245 | 2245 | $p_pr = 'pr-'; |
| 2246 | 2246 | <?php |
| 2247 | - } |
|
| 2248 | - ?> |
|
| 2247 | + } |
|
| 2248 | + ?> |
|
| 2249 | 2249 | |
| 2250 | 2250 | // margins |
| 2251 | 2251 | if ( $args['mt'] !== undefined && $args['mt'] !== '' ) { $classes.push( "mt-" + $args['mt'] ); $mt = $args['mt']; }else{$mt = null;} |
@@ -2428,10 +2428,10 @@ discard block |
||
| 2428 | 2428 | |
| 2429 | 2429 | } |
| 2430 | 2430 | |
| 2431 | - if(method_exists($this,'block_global_js')){ |
|
| 2432 | - echo $this->block_global_js(); |
|
| 2433 | - } |
|
| 2434 | - ?> |
|
| 2431 | + if(method_exists($this,'block_global_js')){ |
|
| 2432 | + echo $this->block_global_js(); |
|
| 2433 | + } |
|
| 2434 | + ?> |
|
| 2435 | 2435 | |
| 2436 | 2436 | jQuery(function() { |
| 2437 | 2437 | |
@@ -2481,14 +2481,14 @@ discard block |
||
| 2481 | 2481 | icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
| 2482 | 2482 | supports: { |
| 2483 | 2483 | <?php |
| 2484 | - if ( isset( $this->options['block-supports'] ) ) { |
|
| 2485 | - echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 2486 | - } |
|
| 2487 | - ?> |
|
| 2484 | + if ( isset( $this->options['block-supports'] ) ) { |
|
| 2485 | + echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 2486 | + } |
|
| 2487 | + ?> |
|
| 2488 | 2488 | }, |
| 2489 | 2489 | <?php |
| 2490 | - if ( isset( $this->options['block-label'] ) ) { |
|
| 2491 | - ?> |
|
| 2490 | + if ( isset( $this->options['block-label'] ) ) { |
|
| 2491 | + ?> |
|
| 2492 | 2492 | __experimentalLabel( attributes, { context } ) { |
| 2493 | 2493 | return <?php echo $this->options['block-label']; ?>; |
| 2494 | 2494 | }, |
@@ -2497,7 +2497,7 @@ discard block |
||
| 2497 | 2497 | ?> |
| 2498 | 2498 | category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
| 2499 | 2499 | <?php if ( isset( $this->options['block-keywords'] ) ) { |
| 2500 | - echo "keywords : " . $this->options['block-keywords'] . ","; |
|
| 2500 | + echo "keywords : " . $this->options['block-keywords'] . ","; |
|
| 2501 | 2501 | |
| 2502 | 2502 | // // block hover preview. |
| 2503 | 2503 | // $example_args = array(); |
@@ -2522,86 +2522,86 @@ discard block |
||
| 2522 | 2522 | |
| 2523 | 2523 | } |
| 2524 | 2524 | |
| 2525 | - // maybe set no_wrap |
|
| 2526 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 2527 | - if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 2528 | - $no_wrap = true; |
|
| 2529 | - } |
|
| 2530 | - if ( $no_wrap ) { |
|
| 2531 | - $this->options['block-wrap'] = ''; |
|
| 2532 | - } |
|
| 2525 | + // maybe set no_wrap |
|
| 2526 | + $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 2527 | + if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 2528 | + $no_wrap = true; |
|
| 2529 | + } |
|
| 2530 | + if ( $no_wrap ) { |
|
| 2531 | + $this->options['block-wrap'] = ''; |
|
| 2532 | + } |
|
| 2533 | 2533 | |
| 2534 | - // maybe load the drag/drop functions. |
|
| 2535 | - $img_drag_drop = false; |
|
| 2534 | + // maybe load the drag/drop functions. |
|
| 2535 | + $img_drag_drop = false; |
|
| 2536 | 2536 | |
| 2537 | - $show_alignment = false; |
|
| 2538 | - // align feature |
|
| 2539 | - /*echo "supports: {"; |
|
| 2537 | + $show_alignment = false; |
|
| 2538 | + // align feature |
|
| 2539 | + /*echo "supports: {"; |
|
| 2540 | 2540 | echo " align: true,"; |
| 2541 | 2541 | echo " html: false"; |
| 2542 | 2542 | echo "},";*/ |
| 2543 | 2543 | |
| 2544 | - if ( ! empty( $this->arguments ) ) { |
|
| 2545 | - echo "attributes : {"; |
|
| 2544 | + if ( ! empty( $this->arguments ) ) { |
|
| 2545 | + echo "attributes : {"; |
|
| 2546 | 2546 | |
| 2547 | - if ( $show_advanced ) { |
|
| 2548 | - echo "show_advanced: {"; |
|
| 2549 | - echo " type: 'boolean',"; |
|
| 2550 | - echo " default: false,"; |
|
| 2551 | - echo "},"; |
|
| 2552 | - } |
|
| 2547 | + if ( $show_advanced ) { |
|
| 2548 | + echo "show_advanced: {"; |
|
| 2549 | + echo " type: 'boolean',"; |
|
| 2550 | + echo " default: false,"; |
|
| 2551 | + echo "},"; |
|
| 2552 | + } |
|
| 2553 | 2553 | |
| 2554 | - // block wrap element |
|
| 2555 | - if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 2556 | - echo "block_wrap: {"; |
|
| 2557 | - echo " type: 'string',"; |
|
| 2558 | - echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 2559 | - echo "},"; |
|
| 2560 | - } |
|
| 2554 | + // block wrap element |
|
| 2555 | + if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 2556 | + echo "block_wrap: {"; |
|
| 2557 | + echo " type: 'string',"; |
|
| 2558 | + echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 2559 | + echo "},"; |
|
| 2560 | + } |
|
| 2561 | 2561 | |
| 2562 | 2562 | |
| 2563 | 2563 | |
| 2564 | - foreach ( $this->arguments as $key => $args ) { |
|
| 2564 | + foreach ( $this->arguments as $key => $args ) { |
|
| 2565 | 2565 | |
| 2566 | - if( $args['type'] == 'image' || $args['type'] == 'images' ){ |
|
| 2567 | - $img_drag_drop = true; |
|
| 2568 | - } |
|
| 2566 | + if( $args['type'] == 'image' || $args['type'] == 'images' ){ |
|
| 2567 | + $img_drag_drop = true; |
|
| 2568 | + } |
|
| 2569 | 2569 | |
| 2570 | - // set if we should show alignment |
|
| 2571 | - if ( $key == 'alignment' ) { |
|
| 2572 | - $show_alignment = true; |
|
| 2573 | - } |
|
| 2570 | + // set if we should show alignment |
|
| 2571 | + if ( $key == 'alignment' ) { |
|
| 2572 | + $show_alignment = true; |
|
| 2573 | + } |
|
| 2574 | 2574 | |
| 2575 | - $extra = ''; |
|
| 2575 | + $extra = ''; |
|
| 2576 | 2576 | |
| 2577 | - if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
|
| 2578 | - continue; |
|
| 2579 | - } |
|
| 2580 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 2581 | - $type = 'boolean'; |
|
| 2582 | - $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 2583 | - } elseif ( $args['type'] == 'number' ) { |
|
| 2584 | - $type = 'number'; |
|
| 2585 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2586 | - } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 2587 | - $type = 'array'; |
|
| 2588 | - if ( isset( $args['default'] ) && is_array( $args['default'] ) ) { |
|
| 2589 | - $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 2590 | - } else { |
|
| 2591 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2592 | - } |
|
| 2593 | - } elseif ( $args['type'] == 'tagselect' ) { |
|
| 2594 | - $type = 'array'; |
|
| 2595 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2596 | - } elseif ( $args['type'] == 'multiselect' ) { |
|
| 2597 | - $type = 'array'; |
|
| 2598 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2599 | - } elseif ( $args['type'] == 'image_xy' ) { |
|
| 2600 | - $type = 'object'; |
|
| 2601 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2602 | - } elseif ( $args['type'] == 'image' ) { |
|
| 2603 | - $type = 'string'; |
|
| 2604 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2577 | + if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
|
| 2578 | + continue; |
|
| 2579 | + } |
|
| 2580 | + elseif ( $args['type'] == 'checkbox' ) { |
|
| 2581 | + $type = 'boolean'; |
|
| 2582 | + $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 2583 | + } elseif ( $args['type'] == 'number' ) { |
|
| 2584 | + $type = 'number'; |
|
| 2585 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2586 | + } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 2587 | + $type = 'array'; |
|
| 2588 | + if ( isset( $args['default'] ) && is_array( $args['default'] ) ) { |
|
| 2589 | + $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 2590 | + } else { |
|
| 2591 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2592 | + } |
|
| 2593 | + } elseif ( $args['type'] == 'tagselect' ) { |
|
| 2594 | + $type = 'array'; |
|
| 2595 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2596 | + } elseif ( $args['type'] == 'multiselect' ) { |
|
| 2597 | + $type = 'array'; |
|
| 2598 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2599 | + } elseif ( $args['type'] == 'image_xy' ) { |
|
| 2600 | + $type = 'object'; |
|
| 2601 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2602 | + } elseif ( $args['type'] == 'image' ) { |
|
| 2603 | + $type = 'string'; |
|
| 2604 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2605 | 2605 | |
| 2606 | 2606 | // add a field for ID |
| 2607 | 2607 | // echo $key . "_id : {"; |
@@ -2611,25 +2611,25 @@ discard block |
||
| 2611 | 2611 | // echo "type : 'object',"; |
| 2612 | 2612 | // echo "},"; |
| 2613 | 2613 | |
| 2614 | - } else { |
|
| 2615 | - $type = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string'; |
|
| 2616 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2614 | + } else { |
|
| 2615 | + $type = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string'; |
|
| 2616 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2617 | 2617 | |
| 2618 | - } |
|
| 2619 | - echo $key . " : {"; |
|
| 2620 | - echo "type : '$type',"; |
|
| 2621 | - echo "default : $default,"; |
|
| 2622 | - echo "},"; |
|
| 2623 | - } |
|
| 2618 | + } |
|
| 2619 | + echo $key . " : {"; |
|
| 2620 | + echo "type : '$type',"; |
|
| 2621 | + echo "default : $default,"; |
|
| 2622 | + echo "},"; |
|
| 2623 | + } |
|
| 2624 | 2624 | |
| 2625 | - echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},"; |
|
| 2626 | - echo "className: { type: 'string', default: '' },"; |
|
| 2625 | + echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},"; |
|
| 2626 | + echo "className: { type: 'string', default: '' },"; |
|
| 2627 | 2627 | |
| 2628 | - echo "},"; |
|
| 2628 | + echo "},"; |
|
| 2629 | 2629 | |
| 2630 | - } |
|
| 2630 | + } |
|
| 2631 | 2631 | |
| 2632 | - ?> |
|
| 2632 | + ?> |
|
| 2633 | 2633 | |
| 2634 | 2634 | // The "edit" property must be a valid function. |
| 2635 | 2635 | edit: function (props) { |
@@ -2728,9 +2728,9 @@ discard block |
||
| 2728 | 2728 | |
| 2729 | 2729 | var $value = ''; |
| 2730 | 2730 | <?php |
| 2731 | - // if we have a post_type and a category then link them |
|
| 2732 | - if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){ |
|
| 2733 | - ?> |
|
| 2731 | + // if we have a post_type and a category then link them |
|
| 2732 | + if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){ |
|
| 2733 | + ?> |
|
| 2734 | 2734 | if(typeof(prev_attributes[props.clientId]) != 'undefined'){ |
| 2735 | 2735 | $pt = props.attributes.post_type; |
| 2736 | 2736 | if(post_type_rest_slugs.length){ |
@@ -2743,11 +2743,11 @@ discard block |
||
| 2743 | 2743 | term_query_type = $pt; |
| 2744 | 2744 | } |
| 2745 | 2745 | <?php |
| 2746 | - $cat_path = ''; |
|
| 2747 | - if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) { |
|
| 2748 | - $cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) ); |
|
| 2749 | - $cat_path = str_replace( array( '"', ''' ), array( '"', "'" ), $cat_path ); |
|
| 2750 | - } |
|
| 2746 | + $cat_path = ''; |
|
| 2747 | + if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) { |
|
| 2748 | + $cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) ); |
|
| 2749 | + $cat_path = str_replace( array( '"', ''' ), array( '"', "'" ), $cat_path ); |
|
| 2750 | + } |
|
| 2751 | 2751 | ?> |
| 2752 | 2752 | /* taxonomies */ |
| 2753 | 2753 | if($value && 'post_type' in prev_attributes[props.clientId] && 'category' in prev_attributes[props.clientId] && run){ |
@@ -2839,7 +2839,7 @@ discard block |
||
| 2839 | 2839 | <?php |
| 2840 | 2840 | $current_screen = function_exists('get_current_screen') ? get_current_screen() : ''; |
| 2841 | 2841 | if(!empty($current_screen->base) && $current_screen->base==='widgets'){ |
| 2842 | - echo 'const { deviceType } = "";'; |
|
| 2842 | + echo 'const { deviceType } = "";'; |
|
| 2843 | 2843 | }else{ |
| 2844 | 2844 | ?> |
| 2845 | 2845 | /** Get device type const. */ |
@@ -2873,8 +2873,8 @@ discard block |
||
| 2873 | 2873 | 'attributes': props.attributes, |
| 2874 | 2874 | 'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '', |
| 2875 | 2875 | 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
| 2876 | - echo $post->ID; |
|
| 2877 | - }else{echo '0';}?>, |
|
| 2876 | + echo $post->ID; |
|
| 2877 | + }else{echo '0';}?>, |
|
| 2878 | 2878 | '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
| 2879 | 2879 | }; |
| 2880 | 2880 | |
@@ -2951,10 +2951,10 @@ discard block |
||
| 2951 | 2951 | |
| 2952 | 2952 | <?php |
| 2953 | 2953 | |
| 2954 | - if(! empty( $this->arguments )){ |
|
| 2954 | + if(! empty( $this->arguments )){ |
|
| 2955 | 2955 | |
| 2956 | - if ( $show_advanced ) { |
|
| 2957 | - ?> |
|
| 2956 | + if ( $show_advanced ) { |
|
| 2957 | + ?> |
|
| 2958 | 2958 | el('div', { |
| 2959 | 2959 | style: {'padding-left': '16px','padding-right': '16px'} |
| 2960 | 2960 | }, |
@@ -2971,127 +2971,127 @@ discard block |
||
| 2971 | 2971 | ) |
| 2972 | 2972 | , |
| 2973 | 2973 | <?php |
| 2974 | - } |
|
| 2974 | + } |
|
| 2975 | 2975 | |
| 2976 | - $arguments = $this->group_arguments( $this->arguments ); |
|
| 2977 | - $block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array(); |
|
| 2976 | + $arguments = $this->group_arguments( $this->arguments ); |
|
| 2977 | + $block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array(); |
|
| 2978 | 2978 | |
| 2979 | - // Do we have sections? |
|
| 2980 | - $has_sections = $arguments == $this->arguments ? false : true; |
|
| 2979 | + // Do we have sections? |
|
| 2980 | + $has_sections = $arguments == $this->arguments ? false : true; |
|
| 2981 | 2981 | |
| 2982 | - if($has_sections){ |
|
| 2983 | - $panel_count = 0; |
|
| 2984 | - $open_tab = ''; |
|
| 2982 | + if($has_sections){ |
|
| 2983 | + $panel_count = 0; |
|
| 2984 | + $open_tab = ''; |
|
| 2985 | 2985 | |
| 2986 | - $open_tab_groups = array(); |
|
| 2987 | - $used_tabs = array(); |
|
| 2986 | + $open_tab_groups = array(); |
|
| 2987 | + $used_tabs = array(); |
|
| 2988 | 2988 | |
| 2989 | - foreach ( $arguments as $key => $args ) { |
|
| 2990 | - $close_tab = false; |
|
| 2991 | - $close_tabs = false; |
|
| 2989 | + foreach ( $arguments as $key => $args ) { |
|
| 2990 | + $close_tab = false; |
|
| 2991 | + $close_tabs = false; |
|
| 2992 | 2992 | |
| 2993 | - if ( ! empty( $block_group_tabs ) ) { |
|
| 2994 | - foreach ( $block_group_tabs as $tab_name => $tab_args ) { |
|
| 2995 | - if ( in_array( $key, $tab_args['groups'] ) ) { |
|
| 2996 | - $open_tab_groups[] = $key; |
|
| 2993 | + if ( ! empty( $block_group_tabs ) ) { |
|
| 2994 | + foreach ( $block_group_tabs as $tab_name => $tab_args ) { |
|
| 2995 | + if ( in_array( $key, $tab_args['groups'] ) ) { |
|
| 2996 | + $open_tab_groups[] = $key; |
|
| 2997 | 2997 | |
| 2998 | - if ( $open_tab != $tab_name ) { |
|
| 2999 | - $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false; |
|
| 3000 | - $tab_args['tab']['open'] = true; |
|
| 2998 | + if ( $open_tab != $tab_name ) { |
|
| 2999 | + $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false; |
|
| 3000 | + $tab_args['tab']['open'] = true; |
|
| 3001 | 3001 | |
| 3002 | - $this->block_tab_start( '', $tab_args ); |
|
| 3003 | - $open_tab = $tab_name; |
|
| 3004 | - $used_tabs[] = $tab_name; |
|
| 3005 | - } |
|
| 3002 | + $this->block_tab_start( '', $tab_args ); |
|
| 3003 | + $open_tab = $tab_name; |
|
| 3004 | + $used_tabs[] = $tab_name; |
|
| 3005 | + } |
|
| 3006 | 3006 | |
| 3007 | - if ( $open_tab_groups == $tab_args['groups'] ) { |
|
| 3008 | - $close_tab = true; |
|
| 3009 | - $open_tab_groups = array(); |
|
| 3007 | + if ( $open_tab_groups == $tab_args['groups'] ) { |
|
| 3008 | + $close_tab = true; |
|
| 3009 | + $open_tab_groups = array(); |
|
| 3010 | 3010 | |
| 3011 | - if ( $used_tabs == array_keys( $block_group_tabs ) ) { |
|
| 3012 | - $close_tabs = true; |
|
| 3013 | - } |
|
| 3014 | - } |
|
| 3015 | - } |
|
| 3016 | - } |
|
| 3017 | - } |
|
| 3018 | - ?> |
|
| 3011 | + if ( $used_tabs == array_keys( $block_group_tabs ) ) { |
|
| 3012 | + $close_tabs = true; |
|
| 3013 | + } |
|
| 3014 | + } |
|
| 3015 | + } |
|
| 3016 | + } |
|
| 3017 | + } |
|
| 3018 | + ?> |
|
| 3019 | 3019 | el(wp.components.PanelBody, { |
| 3020 | 3020 | title: '<?php esc_attr_e( $key ); ?>', |
| 3021 | 3021 | initialOpen: <?php if ( $panel_count ) { |
| 3022 | - echo "false"; |
|
| 3023 | - } else { |
|
| 3024 | - echo "true"; |
|
| 3025 | - }?> |
|
| 3022 | + echo "false"; |
|
| 3023 | + } else { |
|
| 3024 | + echo "true"; |
|
| 3025 | + }?> |
|
| 3026 | 3026 | }, |
| 3027 | 3027 | <?php |
| 3028 | - foreach ( $args as $k => $a ) { |
|
| 3029 | - $this->block_tab_start( $k, $a ); |
|
| 3030 | - $this->block_row_start( $k, $a ); |
|
| 3031 | - $this->build_block_arguments( $k, $a ); |
|
| 3032 | - $this->block_row_end( $k, $a ); |
|
| 3033 | - $this->block_tab_end( $k, $a ); |
|
| 3034 | - } |
|
| 3035 | - ?> |
|
| 3028 | + foreach ( $args as $k => $a ) { |
|
| 3029 | + $this->block_tab_start( $k, $a ); |
|
| 3030 | + $this->block_row_start( $k, $a ); |
|
| 3031 | + $this->build_block_arguments( $k, $a ); |
|
| 3032 | + $this->block_row_end( $k, $a ); |
|
| 3033 | + $this->block_tab_end( $k, $a ); |
|
| 3034 | + } |
|
| 3035 | + ?> |
|
| 3036 | 3036 | ), |
| 3037 | 3037 | <?php |
| 3038 | - $panel_count ++; |
|
| 3038 | + $panel_count ++; |
|
| 3039 | 3039 | |
| 3040 | - if($close_tab || $close_tabs){ |
|
| 3041 | - $tab_args = array( |
|
| 3042 | - 'tab' => array( |
|
| 3043 | - 'tabs_close' => $close_tabs, |
|
| 3044 | - 'close' => true, |
|
| 3045 | - ) |
|
| 3040 | + if($close_tab || $close_tabs){ |
|
| 3041 | + $tab_args = array( |
|
| 3042 | + 'tab' => array( |
|
| 3043 | + 'tabs_close' => $close_tabs, |
|
| 3044 | + 'close' => true, |
|
| 3045 | + ) |
|
| 3046 | 3046 | |
| 3047 | - ); |
|
| 3048 | - $this->block_tab_end( '', $tab_args ); |
|
| 3047 | + ); |
|
| 3048 | + $this->block_tab_end( '', $tab_args ); |
|
| 3049 | 3049 | // echo '###close'; print_r($tab_args); |
| 3050 | - $panel_count = 0; |
|
| 3051 | - } |
|
| 3050 | + $panel_count = 0; |
|
| 3051 | + } |
|
| 3052 | 3052 | // |
| 3053 | 3053 | |
| 3054 | - } |
|
| 3055 | - }else { |
|
| 3056 | - ?> |
|
| 3054 | + } |
|
| 3055 | + }else { |
|
| 3056 | + ?> |
|
| 3057 | 3057 | el(wp.components.PanelBody, { |
| 3058 | 3058 | title: '<?php esc_attr_e( "Settings", 'ayecode-connect' ); ?>', |
| 3059 | 3059 | initialOpen: true |
| 3060 | 3060 | }, |
| 3061 | 3061 | <?php |
| 3062 | - foreach ( $this->arguments as $key => $args ) { |
|
| 3063 | - $this->block_row_start( $key, $args ); |
|
| 3064 | - $this->build_block_arguments( $key, $args ); |
|
| 3065 | - $this->block_row_end( $key, $args ); |
|
| 3066 | - } |
|
| 3067 | - ?> |
|
| 3062 | + foreach ( $this->arguments as $key => $args ) { |
|
| 3063 | + $this->block_row_start( $key, $args ); |
|
| 3064 | + $this->build_block_arguments( $key, $args ); |
|
| 3065 | + $this->block_row_end( $key, $args ); |
|
| 3066 | + } |
|
| 3067 | + ?> |
|
| 3068 | 3068 | ), |
| 3069 | 3069 | <?php |
| 3070 | - } |
|
| 3070 | + } |
|
| 3071 | 3071 | |
| 3072 | - } |
|
| 3073 | - ?> |
|
| 3072 | + } |
|
| 3073 | + ?> |
|
| 3074 | 3074 | |
| 3075 | 3075 | ), |
| 3076 | 3076 | |
| 3077 | 3077 | <?php |
| 3078 | - // If the user sets block-output array then build it |
|
| 3079 | - if ( ! empty( $this->options['block-output'] ) ) { |
|
| 3080 | - $this->block_element( $this->options['block-output'] ); |
|
| 3081 | - }elseif(!empty($this->options['block-edit-return'])){ |
|
| 3082 | - echo $this->options['block-edit-return']; |
|
| 3083 | - }else{ |
|
| 3084 | - // if no block-output is set then we try and get the shortcode html output via ajax. |
|
| 3085 | - $block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div'; |
|
| 3086 | - ?> |
|
| 3078 | + // If the user sets block-output array then build it |
|
| 3079 | + if ( ! empty( $this->options['block-output'] ) ) { |
|
| 3080 | + $this->block_element( $this->options['block-output'] ); |
|
| 3081 | + }elseif(!empty($this->options['block-edit-return'])){ |
|
| 3082 | + echo $this->options['block-edit-return']; |
|
| 3083 | + }else{ |
|
| 3084 | + // if no block-output is set then we try and get the shortcode html output via ajax. |
|
| 3085 | + $block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div'; |
|
| 3086 | + ?> |
|
| 3087 | 3087 | el('<?php echo esc_attr($block_edit_wrap_tag); ?>', wp.blockEditor.useBlockProps({ |
| 3088 | 3088 | dangerouslySetInnerHTML: {__html: onChangeContent()}, |
| 3089 | 3089 | className: props.className, |
| 3090 | 3090 | style: {'minHeight': '30px'} |
| 3091 | 3091 | })) |
| 3092 | 3092 | <?php |
| 3093 | - } |
|
| 3094 | - ?> |
|
| 3093 | + } |
|
| 3094 | + ?> |
|
| 3095 | 3095 | ]; // end return |
| 3096 | 3096 | |
| 3097 | 3097 | <?php |
@@ -3110,11 +3110,11 @@ discard block |
||
| 3110 | 3110 | $html = ''; |
| 3111 | 3111 | <?php |
| 3112 | 3112 | |
| 3113 | - if(! empty( $this->arguments )){ |
|
| 3113 | + if(! empty( $this->arguments )){ |
|
| 3114 | 3114 | |
| 3115 | - foreach($this->arguments as $key => $args){ |
|
| 3116 | - // if($args['type']=='tabs'){continue;} |
|
| 3117 | - ?> |
|
| 3115 | + foreach($this->arguments as $key => $args){ |
|
| 3116 | + // if($args['type']=='tabs'){continue;} |
|
| 3117 | + ?> |
|
| 3118 | 3118 | if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
| 3119 | 3119 | if ('<?php echo esc_attr( $key );?>' == 'html') { |
| 3120 | 3120 | $html = attr.<?php echo esc_attr( $key );?>; |
@@ -3125,10 +3125,10 @@ discard block |
||
| 3125 | 3125 | } |
| 3126 | 3126 | } |
| 3127 | 3127 | <?php |
| 3128 | - } |
|
| 3129 | - } |
|
| 3128 | + } |
|
| 3129 | + } |
|
| 3130 | 3130 | |
| 3131 | - ?> |
|
| 3131 | + ?> |
|
| 3132 | 3132 | content += "]"; |
| 3133 | 3133 | |
| 3134 | 3134 | <?php |
@@ -3175,7 +3175,7 @@ discard block |
||
| 3175 | 3175 | // $this->block_element( $this->options['block-output'], true ); |
| 3176 | 3176 | // echo ";"; |
| 3177 | 3177 | |
| 3178 | - ?> |
|
| 3178 | + ?> |
|
| 3179 | 3179 | return el( |
| 3180 | 3180 | '', |
| 3181 | 3181 | {}, |
@@ -3185,9 +3185,9 @@ discard block |
||
| 3185 | 3185 | ); |
| 3186 | 3186 | <?php |
| 3187 | 3187 | |
| 3188 | - }elseif(!empty($this->options['block-save-return'])){ |
|
| 3189 | - echo 'return ' . $this->options['block-save-return']; |
|
| 3190 | - }elseif(!empty($this->options['nested-block'])){ |
|
| 3188 | + }elseif(!empty($this->options['block-save-return'])){ |
|
| 3189 | + echo 'return ' . $this->options['block-save-return']; |
|
| 3190 | + }elseif(!empty($this->options['nested-block'])){ |
|
| 3191 | 3191 | ?> |
| 3192 | 3192 | return el( |
| 3193 | 3193 | '', |
@@ -3197,22 +3197,22 @@ discard block |
||
| 3197 | 3197 | el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}}) |
| 3198 | 3198 | ); |
| 3199 | 3199 | <?php |
| 3200 | - }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 3200 | + }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 3201 | 3201 | echo "return ". $this->options['block-edit-return'].";"; |
| 3202 | - }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 3203 | - ?> |
|
| 3202 | + }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 3203 | + ?> |
|
| 3204 | 3204 | return content; |
| 3205 | 3205 | <?php |
| 3206 | - }else{ |
|
| 3207 | - ?> |
|
| 3206 | + }else{ |
|
| 3207 | + ?> |
|
| 3208 | 3208 | var block_wrap = 'div'; |
| 3209 | 3209 | if (attr.hasOwnProperty("block_wrap")) { |
| 3210 | 3210 | block_wrap = attr.block_wrap; |
| 3211 | 3211 | } |
| 3212 | 3212 | return el(block_wrap, wp.blockEditor.useBlockProps.save( {dangerouslySetInnerHTML: {__html: content}, className: align} )); |
| 3213 | 3213 | <?php |
| 3214 | - } |
|
| 3215 | - ?> |
|
| 3214 | + } |
|
| 3215 | + ?> |
|
| 3216 | 3216 | |
| 3217 | 3217 | |
| 3218 | 3218 | } |
@@ -3226,29 +3226,29 @@ discard block |
||
| 3226 | 3226 | }); |
| 3227 | 3227 | </script> |
| 3228 | 3228 | <?php |
| 3229 | - $output = ob_get_clean(); |
|
| 3229 | + $output = ob_get_clean(); |
|
| 3230 | 3230 | |
| 3231 | - /* |
|
| 3231 | + /* |
|
| 3232 | 3232 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 3233 | 3233 | */ |
| 3234 | 3234 | |
| 3235 | - return str_replace( array( |
|
| 3236 | - '<script>', |
|
| 3237 | - '</script>' |
|
| 3238 | - ), '', $output ); |
|
| 3239 | - } |
|
| 3235 | + return str_replace( array( |
|
| 3236 | + '<script>', |
|
| 3237 | + '</script>' |
|
| 3238 | + ), '', $output ); |
|
| 3239 | + } |
|
| 3240 | 3240 | |
| 3241 | 3241 | |
| 3242 | 3242 | |
| 3243 | - public function block_row_start($key, $args){ |
|
| 3243 | + public function block_row_start($key, $args){ |
|
| 3244 | 3244 | |
| 3245 | - // check for row |
|
| 3246 | - if(!empty($args['row'])){ |
|
| 3245 | + // check for row |
|
| 3246 | + if(!empty($args['row'])){ |
|
| 3247 | 3247 | |
| 3248 | - if(!empty($args['row']['open'])){ |
|
| 3248 | + if(!empty($args['row']['open'])){ |
|
| 3249 | 3249 | |
| 3250 | - // element require |
|
| 3251 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 3250 | + // element require |
|
| 3251 | + $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 3252 | 3252 | $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
| 3253 | 3253 | $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
| 3254 | 3254 | $device_type_icon = ''; |
@@ -3259,10 +3259,10 @@ discard block |
||
| 3259 | 3259 | }elseif($device_type=='Mobile'){ |
| 3260 | 3260 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3261 | 3261 | } |
| 3262 | - echo $element_require; |
|
| 3262 | + echo $element_require; |
|
| 3263 | 3263 | echo $device_type_require; |
| 3264 | 3264 | |
| 3265 | - if(false){?><script><?php }?> |
|
| 3265 | + if(false){?><script><?php }?> |
|
| 3266 | 3266 | el('div', { |
| 3267 | 3267 | className: 'bsui components-base-control', |
| 3268 | 3268 | }, |
@@ -3300,51 +3300,51 @@ discard block |
||
| 3300 | 3300 | }, |
| 3301 | 3301 | |
| 3302 | 3302 | <?php |
| 3303 | - if(false){?></script><?php } |
|
| 3304 | - }elseif(!empty($args['row']['close'])){ |
|
| 3305 | - if(false){?><script><?php }?> |
|
| 3303 | + if(false){?></script><?php } |
|
| 3304 | + }elseif(!empty($args['row']['close'])){ |
|
| 3305 | + if(false){?><script><?php }?> |
|
| 3306 | 3306 | el( |
| 3307 | 3307 | 'div', |
| 3308 | 3308 | { |
| 3309 | 3309 | className: 'col pl-0 ps-0', |
| 3310 | 3310 | }, |
| 3311 | 3311 | <?php |
| 3312 | - if(false){?></script><?php } |
|
| 3313 | - }else{ |
|
| 3314 | - if(false){?><script><?php }?> |
|
| 3312 | + if(false){?></script><?php } |
|
| 3313 | + }else{ |
|
| 3314 | + if(false){?><script><?php }?> |
|
| 3315 | 3315 | el( |
| 3316 | 3316 | 'div', |
| 3317 | 3317 | { |
| 3318 | 3318 | className: 'col pl-0 ps-0 pr-2 pe-2', |
| 3319 | 3319 | }, |
| 3320 | 3320 | <?php |
| 3321 | - if(false){?></script><?php } |
|
| 3322 | - } |
|
| 3321 | + if(false){?></script><?php } |
|
| 3322 | + } |
|
| 3323 | 3323 | |
| 3324 | - } |
|
| 3324 | + } |
|
| 3325 | 3325 | |
| 3326 | - } |
|
| 3326 | + } |
|
| 3327 | 3327 | |
| 3328 | - public function block_row_end($key, $args){ |
|
| 3328 | + public function block_row_end($key, $args){ |
|
| 3329 | 3329 | |
| 3330 | - if(!empty($args['row'])){ |
|
| 3331 | - // maybe close |
|
| 3332 | - if(!empty($args['row']['close'])){ |
|
| 3333 | - echo "))"; |
|
| 3334 | - } |
|
| 3330 | + if(!empty($args['row'])){ |
|
| 3331 | + // maybe close |
|
| 3332 | + if(!empty($args['row']['close'])){ |
|
| 3333 | + echo "))"; |
|
| 3334 | + } |
|
| 3335 | 3335 | |
| 3336 | - echo "),"; |
|
| 3337 | - } |
|
| 3338 | - } |
|
| 3336 | + echo "),"; |
|
| 3337 | + } |
|
| 3338 | + } |
|
| 3339 | 3339 | |
| 3340 | - public function block_tab_start($key, $args){ |
|
| 3340 | + public function block_tab_start($key, $args){ |
|
| 3341 | 3341 | |
| 3342 | - // check for row |
|
| 3343 | - if(!empty($args['tab'])){ |
|
| 3342 | + // check for row |
|
| 3343 | + if(!empty($args['tab'])){ |
|
| 3344 | 3344 | |
| 3345 | - if(!empty($args['tab']['tabs_open'])){ |
|
| 3345 | + if(!empty($args['tab']['tabs_open'])){ |
|
| 3346 | 3346 | |
| 3347 | - if(false){?><script><?php }?> |
|
| 3347 | + if(false){?><script><?php }?> |
|
| 3348 | 3348 | |
| 3349 | 3349 | el('div',{className: 'bsui'}, |
| 3350 | 3350 | |
@@ -3357,12 +3357,12 @@ discard block |
||
| 3357 | 3357 | tabs: [ |
| 3358 | 3358 | |
| 3359 | 3359 | <?php |
| 3360 | - if(false){?></script><?php } |
|
| 3361 | - } |
|
| 3360 | + if(false){?></script><?php } |
|
| 3361 | + } |
|
| 3362 | 3362 | |
| 3363 | - if(!empty($args['tab']['open'])){ |
|
| 3363 | + if(!empty($args['tab']['open'])){ |
|
| 3364 | 3364 | |
| 3365 | - if(false){?><script><?php }?> |
|
| 3365 | + if(false){?><script><?php }?> |
|
| 3366 | 3366 | { |
| 3367 | 3367 | name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>', |
| 3368 | 3368 | title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}), |
@@ -3371,44 +3371,44 @@ discard block |
||
| 3371 | 3371 | className: 'components-base-control__help mb-0', |
| 3372 | 3372 | dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'} |
| 3373 | 3373 | }),<?php } |
| 3374 | - if(false){?></script><?php } |
|
| 3375 | - } |
|
| 3374 | + if(false){?></script><?php } |
|
| 3375 | + } |
|
| 3376 | 3376 | |
| 3377 | - } |
|
| 3377 | + } |
|
| 3378 | 3378 | |
| 3379 | - } |
|
| 3379 | + } |
|
| 3380 | 3380 | |
| 3381 | - public function block_tab_end($key, $args){ |
|
| 3381 | + public function block_tab_end($key, $args){ |
|
| 3382 | 3382 | |
| 3383 | - if(!empty($args['tab'])){ |
|
| 3384 | - // maybe close |
|
| 3385 | - if(!empty($args['tab']['close'])){ |
|
| 3386 | - echo ")}, /* tab close */"; |
|
| 3387 | - } |
|
| 3383 | + if(!empty($args['tab'])){ |
|
| 3384 | + // maybe close |
|
| 3385 | + if(!empty($args['tab']['close'])){ |
|
| 3386 | + echo ")}, /* tab close */"; |
|
| 3387 | + } |
|
| 3388 | 3388 | |
| 3389 | - if(!empty($args['tab']['tabs_close'])){ |
|
| 3390 | - if(false){?><script><?php }?> |
|
| 3389 | + if(!empty($args['tab']['tabs_close'])){ |
|
| 3390 | + if(false){?><script><?php }?> |
|
| 3391 | 3391 | ]}, ( tab ) => { |
| 3392 | 3392 | return tab.content; |
| 3393 | 3393 | } |
| 3394 | 3394 | )), /* tabs close */ |
| 3395 | 3395 | <?php if(false){ ?></script><?php } |
| 3396 | - } |
|
| 3397 | - } |
|
| 3398 | - } |
|
| 3396 | + } |
|
| 3397 | + } |
|
| 3398 | + } |
|
| 3399 | 3399 | |
| 3400 | - public function build_block_arguments( $key, $args ) { |
|
| 3401 | - $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 3402 | - $options = ''; |
|
| 3403 | - $extra = ''; |
|
| 3404 | - $require = ''; |
|
| 3400 | + public function build_block_arguments( $key, $args ) { |
|
| 3401 | + $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 3402 | + $options = ''; |
|
| 3403 | + $extra = ''; |
|
| 3404 | + $require = ''; |
|
| 3405 | 3405 | $inside_elements = ''; |
| 3406 | - $after_elements = ''; |
|
| 3406 | + $after_elements = ''; |
|
| 3407 | 3407 | |
| 3408 | - // `content` is a protected and special argument |
|
| 3409 | - if ( $key == 'content' ) { |
|
| 3410 | - return; |
|
| 3411 | - } |
|
| 3408 | + // `content` is a protected and special argument |
|
| 3409 | + if ( $key == 'content' ) { |
|
| 3410 | + return; |
|
| 3411 | + } |
|
| 3412 | 3412 | |
| 3413 | 3413 | $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
| 3414 | 3414 | $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
@@ -3421,37 +3421,37 @@ discard block |
||
| 3421 | 3421 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3422 | 3422 | } |
| 3423 | 3423 | |
| 3424 | - // icon |
|
| 3425 | - $icon = ''; |
|
| 3426 | - if( !empty( $args['icon'] ) ){ |
|
| 3427 | - $icon .= "el('div', {"; |
|
| 3428 | - $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},"; |
|
| 3429 | - $icon .= "className: 'text-center',"; |
|
| 3430 | - $icon .= "title: '".addslashes( $args['title'] )."',"; |
|
| 3431 | - $icon .= "}),"; |
|
| 3432 | - |
|
| 3433 | - // blank title as its added to the icon. |
|
| 3434 | - $args['title'] = ''; |
|
| 3435 | - } |
|
| 3424 | + // icon |
|
| 3425 | + $icon = ''; |
|
| 3426 | + if( !empty( $args['icon'] ) ){ |
|
| 3427 | + $icon .= "el('div', {"; |
|
| 3428 | + $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},"; |
|
| 3429 | + $icon .= "className: 'text-center',"; |
|
| 3430 | + $icon .= "title: '".addslashes( $args['title'] )."',"; |
|
| 3431 | + $icon .= "}),"; |
|
| 3432 | + |
|
| 3433 | + // blank title as its added to the icon. |
|
| 3434 | + $args['title'] = ''; |
|
| 3435 | + } |
|
| 3436 | 3436 | |
| 3437 | - // require advanced |
|
| 3438 | - $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; |
|
| 3437 | + // require advanced |
|
| 3438 | + $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; |
|
| 3439 | 3439 | |
| 3440 | - // element require |
|
| 3441 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 3440 | + // element require |
|
| 3441 | + $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 3442 | 3442 | |
| 3443 | 3443 | |
| 3444 | - $onchange = "props.setAttributes({ $key: $key } )"; |
|
| 3445 | - $onchangecomplete = ""; |
|
| 3446 | - $value = "props.attributes.$key"; |
|
| 3447 | - $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' ); |
|
| 3448 | - if ( in_array( $args['type'], $text_type ) ) { |
|
| 3449 | - $type = 'TextControl'; |
|
| 3450 | - // Save numbers as numbers and not strings |
|
| 3451 | - if ( $args['type'] == 'number' ) { |
|
| 3452 | - $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; |
|
| 3453 | - } |
|
| 3454 | - } |
|
| 3444 | + $onchange = "props.setAttributes({ $key: $key } )"; |
|
| 3445 | + $onchangecomplete = ""; |
|
| 3446 | + $value = "props.attributes.$key"; |
|
| 3447 | + $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' ); |
|
| 3448 | + if ( in_array( $args['type'], $text_type ) ) { |
|
| 3449 | + $type = 'TextControl'; |
|
| 3450 | + // Save numbers as numbers and not strings |
|
| 3451 | + if ( $args['type'] == 'number' ) { |
|
| 3452 | + $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; |
|
| 3453 | + } |
|
| 3454 | + } |
|
| 3455 | 3455 | // else if ( $args['type'] == 'popup' ) { |
| 3456 | 3456 | // $type = 'TextControl'; |
| 3457 | 3457 | // $args['type'] == 'text'; |
@@ -3469,21 +3469,21 @@ discard block |
||
| 3469 | 3469 | // |
| 3470 | 3470 | // $value = "props.attributes.$key ? props.attributes.$key : ''"; |
| 3471 | 3471 | // } |
| 3472 | - else if ( $args['type'] == 'styleid' ) { |
|
| 3473 | - $type = 'TextControl'; |
|
| 3474 | - $args['type'] == 'text'; |
|
| 3475 | - // Save numbers as numbers and not strings |
|
| 3476 | - $value = "props.attributes.$key ? props.attributes.$key : ''"; |
|
| 3477 | - }else if ( $args['type'] == 'notice' ) { |
|
| 3478 | - |
|
| 3479 | - $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
|
| 3480 | - $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
|
| 3481 | - |
|
| 3482 | - $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 pe-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),"; |
|
| 3483 | - echo $notice_message ? $element_require . $notice : ''; |
|
| 3484 | - return; |
|
| 3485 | - } |
|
| 3486 | - /* |
|
| 3472 | + else if ( $args['type'] == 'styleid' ) { |
|
| 3473 | + $type = 'TextControl'; |
|
| 3474 | + $args['type'] == 'text'; |
|
| 3475 | + // Save numbers as numbers and not strings |
|
| 3476 | + $value = "props.attributes.$key ? props.attributes.$key : ''"; |
|
| 3477 | + }else if ( $args['type'] == 'notice' ) { |
|
| 3478 | + |
|
| 3479 | + $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
|
| 3480 | + $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
|
| 3481 | + |
|
| 3482 | + $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 pe-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),"; |
|
| 3483 | + echo $notice_message ? $element_require . $notice : ''; |
|
| 3484 | + return; |
|
| 3485 | + } |
|
| 3486 | + /* |
|
| 3487 | 3487 | * https://www.wptricks.com/question/set-current-tab-on-a-gutenberg-tabpanel-component-from-outside-that-component/ es5 layout |
| 3488 | 3488 | elseif($args['type']=='tabs'){ |
| 3489 | 3489 | ?> |
@@ -3536,22 +3536,22 @@ discard block |
||
| 3536 | 3536 | return; |
| 3537 | 3537 | } |
| 3538 | 3538 | */ |
| 3539 | - elseif ( $args['type'] == 'color' ) { |
|
| 3540 | - $type = 'ColorPicker'; |
|
| 3541 | - $onchange = ""; |
|
| 3542 | - $extra = "color: $value,"; |
|
| 3543 | - if(!empty($args['disable_alpha'])){ |
|
| 3544 | - $extra .= "disableAlpha: true,"; |
|
| 3545 | - } |
|
| 3546 | - $onchangecomplete = "onChangeComplete: function($key) { |
|
| 3539 | + elseif ( $args['type'] == 'color' ) { |
|
| 3540 | + $type = 'ColorPicker'; |
|
| 3541 | + $onchange = ""; |
|
| 3542 | + $extra = "color: $value,"; |
|
| 3543 | + if(!empty($args['disable_alpha'])){ |
|
| 3544 | + $extra .= "disableAlpha: true,"; |
|
| 3545 | + } |
|
| 3546 | + $onchangecomplete = "onChangeComplete: function($key) { |
|
| 3547 | 3547 | value = $key.rgb.a && $key.rgb.a < 1 ? \"rgba(\"+$key.rgb.r+\",\"+$key.rgb.g+\",\"+$key.rgb.b+\",\"+$key.rgb.a+\")\" : $key.hex; |
| 3548 | 3548 | props.setAttributes({ |
| 3549 | 3549 | $key: value |
| 3550 | 3550 | }); |
| 3551 | 3551 | },"; |
| 3552 | - }elseif ( $args['type'] == 'gradient' ) { |
|
| 3553 | - $type = 'GradientPicker'; |
|
| 3554 | - $extra .= "gradients: [{ |
|
| 3552 | + }elseif ( $args['type'] == 'gradient' ) { |
|
| 3553 | + $type = 'GradientPicker'; |
|
| 3554 | + $extra .= "gradients: [{ |
|
| 3555 | 3555 | name: 'Vivid cyan blue to vivid purple', |
| 3556 | 3556 | gradient: |
| 3557 | 3557 | 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', |
@@ -3588,7 +3588,7 @@ discard block |
||
| 3588 | 3588 | slug: 'cool-to-warm-spectrum', |
| 3589 | 3589 | }],"; |
| 3590 | 3590 | |
| 3591 | - }elseif ( $args['type'] == 'image' ) { |
|
| 3591 | + }elseif ( $args['type'] == 'image' ) { |
|
| 3592 | 3592 | // print_r($args); |
| 3593 | 3593 | |
| 3594 | 3594 | $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key || props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{ |
@@ -3613,15 +3613,15 @@ discard block |
||
| 3613 | 3613 | |
| 3614 | 3614 | |
| 3615 | 3615 | $value = '""'; |
| 3616 | - $type = 'MediaUpload'; |
|
| 3616 | + $type = 'MediaUpload'; |
|
| 3617 | 3617 | $extra .= "onSelect: function(media){ |
| 3618 | 3618 | return props.setAttributes({ |
| 3619 | 3619 | $key: media.url, |
| 3620 | 3620 | {$key}_id: media.id |
| 3621 | 3621 | }); |
| 3622 | 3622 | },"; |
| 3623 | - $extra .= "type: 'image',"; |
|
| 3624 | - $extra .= "render: function (obj) { |
|
| 3623 | + $extra .= "type: 'image',"; |
|
| 3624 | + $extra .= "render: function (obj) { |
|
| 3625 | 3625 | return el( 'div',{}, |
| 3626 | 3626 | ( !props.attributes.$key && !props.attributes.{$key}_use_featured ) && el( wp.components.Button, { |
| 3627 | 3627 | className: 'components-button components-circular-option-picker__clear is-primary is-smallx', |
@@ -3650,8 +3650,8 @@ discard block |
||
| 3650 | 3650 | $onchange = ""; |
| 3651 | 3651 | |
| 3652 | 3652 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3653 | - } else if ( $args['type'] == 'images' ) { |
|
| 3654 | - $img_preview = "props.attributes.$key && (function() { |
|
| 3653 | + } else if ( $args['type'] == 'images' ) { |
|
| 3654 | + $img_preview = "props.attributes.$key && (function() { |
|
| 3655 | 3655 | let uploads = JSON.parse('['+props.attributes.$key+']'); |
| 3656 | 3656 | let images = []; |
| 3657 | 3657 | uploads.map((upload, index) => ( |
@@ -3678,9 +3678,9 @@ discard block |
||
| 3678 | 3678 | })(),"; |
| 3679 | 3679 | |
| 3680 | 3680 | |
| 3681 | - $value = '""'; |
|
| 3682 | - $type = 'MediaUpload'; |
|
| 3683 | - $extra .= "onSelect: function(media){ |
|
| 3681 | + $value = '""'; |
|
| 3682 | + $type = 'MediaUpload'; |
|
| 3683 | + $extra .= "onSelect: function(media){ |
|
| 3684 | 3684 | let slim_images = props.attributes.$key ? JSON.parse('['+props.attributes.$key+']') : []; |
| 3685 | 3685 | if(media.length){ |
| 3686 | 3686 | for (var i=0; i < media.length; i++) { |
@@ -3693,9 +3693,9 @@ discard block |
||
| 3693 | 3693 | } |
| 3694 | 3694 | return props.setAttributes({ $key: slimImagesV}); |
| 3695 | 3695 | },"; |
| 3696 | - $extra .= "type: 'image',"; |
|
| 3697 | - $extra .= "multiple: true,"; |
|
| 3698 | - $extra .= "render: function (obj) { |
|
| 3696 | + $extra .= "type: 'image',"; |
|
| 3697 | + $extra .= "multiple: true,"; |
|
| 3698 | + $extra .= "render: function (obj) { |
|
| 3699 | 3699 | /* Init the sort */ |
| 3700 | 3700 | enableDragSort('sd-sortable'); |
| 3701 | 3701 | return el( 'div',{}, |
@@ -3725,37 +3725,37 @@ discard block |
||
| 3725 | 3725 | $onchange = ""; |
| 3726 | 3726 | |
| 3727 | 3727 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3728 | - } |
|
| 3729 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 3730 | - $type = 'CheckboxControl'; |
|
| 3731 | - $extra .= "checked: props.attributes.$key,"; |
|
| 3732 | - $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
|
| 3733 | - } elseif ( $args['type'] == 'textarea' ) { |
|
| 3734 | - $type = 'TextareaControl'; |
|
| 3735 | - |
|
| 3736 | - } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 3737 | - $type = 'SelectControl'; |
|
| 3738 | - |
|
| 3739 | - if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
|
| 3740 | - $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
|
| 3741 | - }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3742 | - $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
|
| 3743 | - }else { |
|
| 3744 | - |
|
| 3745 | - if ( ! empty( $args['options'] ) ) { |
|
| 3746 | - $options .= "options: ["; |
|
| 3747 | - foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 3748 | - $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },"; |
|
| 3749 | - } |
|
| 3750 | - $options .= "],"; |
|
| 3751 | - } |
|
| 3752 | - } |
|
| 3753 | - if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 3754 | - $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, '; |
|
| 3755 | - } |
|
| 3728 | + } |
|
| 3729 | + elseif ( $args['type'] == 'checkbox' ) { |
|
| 3730 | + $type = 'CheckboxControl'; |
|
| 3731 | + $extra .= "checked: props.attributes.$key,"; |
|
| 3732 | + $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
|
| 3733 | + } elseif ( $args['type'] == 'textarea' ) { |
|
| 3734 | + $type = 'TextareaControl'; |
|
| 3735 | + |
|
| 3736 | + } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 3737 | + $type = 'SelectControl'; |
|
| 3738 | + |
|
| 3739 | + if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
|
| 3740 | + $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
|
| 3741 | + }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3742 | + $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
|
| 3743 | + }else { |
|
| 3744 | + |
|
| 3745 | + if ( ! empty( $args['options'] ) ) { |
|
| 3746 | + $options .= "options: ["; |
|
| 3747 | + foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 3748 | + $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },"; |
|
| 3749 | + } |
|
| 3750 | + $options .= "],"; |
|
| 3751 | + } |
|
| 3752 | + } |
|
| 3753 | + if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 3754 | + $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, '; |
|
| 3755 | + } |
|
| 3756 | 3756 | |
| 3757 | - if($args['type'] == 'multiselect' || ( isset( $args['multiple'] ) && $args['multiple'] ) ){ |
|
| 3758 | - $after_elements .= "props.attributes.$key && el( wp.components.Button, { |
|
| 3757 | + if($args['type'] == 'multiselect' || ( isset( $args['multiple'] ) && $args['multiple'] ) ){ |
|
| 3758 | + $after_elements .= "props.attributes.$key && el( wp.components.Button, { |
|
| 3759 | 3759 | className: 'components-button components-circular-option-picker__clear is-secondary is-small', |
| 3760 | 3760 | style: {margin:'-8px 0 8px 0',display: 'block'}, |
| 3761 | 3761 | onClick: function(){ |
@@ -3766,8 +3766,8 @@ discard block |
||
| 3766 | 3766 | }, |
| 3767 | 3767 | 'Clear' |
| 3768 | 3768 | ),"; |
| 3769 | - } |
|
| 3770 | - } elseif ( $args['type'] == 'tagselect' ) { |
|
| 3769 | + } |
|
| 3770 | + } elseif ( $args['type'] == 'tagselect' ) { |
|
| 3771 | 3771 | // $type = 'FormTokenField'; |
| 3772 | 3772 | // |
| 3773 | 3773 | // if ( ! empty( $args['options'] ) ) { |
@@ -3802,20 +3802,20 @@ discard block |
||
| 3802 | 3802 | // $value = "[]"; |
| 3803 | 3803 | // $extra .= ' __experimentalExpandOnFocus: true,'; |
| 3804 | 3804 | |
| 3805 | - } else if ( $args['type'] == 'alignment' ) { |
|
| 3806 | - $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
|
| 3807 | - } else if ( $args['type'] == 'margins' ) { |
|
| 3808 | - |
|
| 3809 | - } else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) { |
|
| 3810 | - $type = 'TextControl'; |
|
| 3811 | - $value = "(props.attributes.$key ? props.attributes.$key : '')"; |
|
| 3812 | - $args['type'] = 'text'; |
|
| 3813 | - $options .= 'disabled:true,'; |
|
| 3814 | - $bsvc_title = esc_attr( addslashes( $args['title'] ) ); |
|
| 3815 | - $bsvc_body = $this->block_visibility_fields( $args ); |
|
| 3816 | - // @TODO reset button |
|
| 3817 | - $bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __( 'Reset', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __( 'Close', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __( 'Save Rules', 'ayecode-connect' ) . '</button>'; |
|
| 3818 | - $after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, { |
|
| 3805 | + } else if ( $args['type'] == 'alignment' ) { |
|
| 3806 | + $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
|
| 3807 | + } else if ( $args['type'] == 'margins' ) { |
|
| 3808 | + |
|
| 3809 | + } else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) { |
|
| 3810 | + $type = 'TextControl'; |
|
| 3811 | + $value = "(props.attributes.$key ? props.attributes.$key : '')"; |
|
| 3812 | + $args['type'] = 'text'; |
|
| 3813 | + $options .= 'disabled:true,'; |
|
| 3814 | + $bsvc_title = esc_attr( addslashes( $args['title'] ) ); |
|
| 3815 | + $bsvc_body = $this->block_visibility_fields( $args ); |
|
| 3816 | + // @TODO reset button |
|
| 3817 | + $bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __( 'Reset', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __( 'Close', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __( 'Save Rules', 'ayecode-connect' ) . '</button>'; |
|
| 3818 | + $after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, { |
|
| 3819 | 3819 | className: 'components-button components-circular-option-picker__clear is-primary is-smallx', |
| 3820 | 3820 | onClick: function() { |
| 3821 | 3821 | var sValue = props.attributes." . $key . "; |
@@ -3841,39 +3841,39 @@ discard block |
||
| 3841 | 3841 | }, |
| 3842 | 3842 | '" . addslashes( ! empty( $args['button_title'] ) ? $args['button_title'] : $args['title'] ) . "' |
| 3843 | 3843 | ) ),"; |
| 3844 | - } else { |
|
| 3845 | - return;// if we have not implemented the control then don't break the JS. |
|
| 3846 | - } |
|
| 3844 | + } else { |
|
| 3845 | + return;// if we have not implemented the control then don't break the JS. |
|
| 3846 | + } |
|
| 3847 | 3847 | |
| 3848 | - // color input does not show the labels so we add them |
|
| 3849 | - if($args['type']=='color'){ |
|
| 3850 | - // add show only if advanced |
|
| 3851 | - echo $require_advanced; |
|
| 3852 | - // add setting require if defined |
|
| 3853 | - echo $element_require; |
|
| 3854 | - echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; |
|
| 3855 | - } |
|
| 3848 | + // color input does not show the labels so we add them |
|
| 3849 | + if($args['type']=='color'){ |
|
| 3850 | + // add show only if advanced |
|
| 3851 | + echo $require_advanced; |
|
| 3852 | + // add setting require if defined |
|
| 3853 | + echo $element_require; |
|
| 3854 | + echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; |
|
| 3855 | + } |
|
| 3856 | 3856 | |
| 3857 | - // add show only if advanced |
|
| 3858 | - echo $require_advanced; |
|
| 3859 | - // add setting require if defined |
|
| 3860 | - echo $element_require; |
|
| 3857 | + // add show only if advanced |
|
| 3858 | + echo $require_advanced; |
|
| 3859 | + // add setting require if defined |
|
| 3860 | + echo $element_require; |
|
| 3861 | 3861 | echo $device_type_require; |
| 3862 | 3862 | |
| 3863 | - // icon |
|
| 3864 | - echo $icon; |
|
| 3865 | - ?> |
|
| 3863 | + // icon |
|
| 3864 | + echo $icon; |
|
| 3865 | + ?> |
|
| 3866 | 3866 | el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components.".$type; ?>, { |
| 3867 | 3867 | label: <?php if ( empty( $args['title'] ) ) { echo "''"; } else if ( empty( $args['row'] ) && ! empty( $args['device_type'] ) ) { ?>el('label',{className:'components-base-control__label',style:{width:"100%"}},el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['title'] ) ?>'}}),<?php if ( $device_type_icon ) { ?>deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})<?php } ?>)<?php |
| 3868 | - } else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>, |
|
| 3868 | + } else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>, |
|
| 3869 | 3869 | help: <?php echo ( isset( $args['desc'] ) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim( wp_kses_post( addslashes( $args['desc'] ) ) ) . "'}})" : "''" ); ?>, |
| 3870 | 3870 | value: <?php echo $value; ?>, |
| 3871 | 3871 | <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
| 3872 | - echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 3873 | - } ?> |
|
| 3872 | + echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 3873 | + } ?> |
|
| 3874 | 3874 | <?php if ( ! empty( $args['placeholder'] ) ) { |
| 3875 | - echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',"; |
|
| 3876 | - } ?> |
|
| 3875 | + echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',"; |
|
| 3876 | + } ?> |
|
| 3877 | 3877 | <?php echo $options; ?> |
| 3878 | 3878 | <?php echo $extra; ?> |
| 3879 | 3879 | <?php echo $custom_attributes; ?> |
@@ -3885,68 +3885,68 @@ discard block |
||
| 3885 | 3885 | <?php } ?> |
| 3886 | 3886 | } <?php echo $inside_elements; ?> ), |
| 3887 | 3887 | <?php |
| 3888 | - echo $after_elements; |
|
| 3889 | - } |
|
| 3888 | + echo $after_elements; |
|
| 3889 | + } |
|
| 3890 | 3890 | |
| 3891 | - /** |
|
| 3892 | - * Convert an array of attributes to block string. |
|
| 3893 | - * |
|
| 3894 | - * @param $custom_attributes |
|
| 3895 | - * |
|
| 3896 | - * @return string |
|
| 3897 | - *@todo there is prob a faster way to do this, also we could add some validation here. |
|
| 3898 | - * |
|
| 3899 | - */ |
|
| 3900 | - public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 3901 | - $attributes = ''; |
|
| 3902 | - if ( ! empty( $custom_attributes ) ) { |
|
| 3903 | - |
|
| 3904 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 3905 | - if(is_array($val)){ |
|
| 3906 | - $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
|
| 3907 | - }else{ |
|
| 3908 | - $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
| 3909 | - } |
|
| 3910 | - } |
|
| 3891 | + /** |
|
| 3892 | + * Convert an array of attributes to block string. |
|
| 3893 | + * |
|
| 3894 | + * @param $custom_attributes |
|
| 3895 | + * |
|
| 3896 | + * @return string |
|
| 3897 | + *@todo there is prob a faster way to do this, also we could add some validation here. |
|
| 3898 | + * |
|
| 3899 | + */ |
|
| 3900 | + public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 3901 | + $attributes = ''; |
|
| 3902 | + if ( ! empty( $custom_attributes ) ) { |
|
| 3911 | 3903 | |
| 3912 | - } |
|
| 3904 | + foreach ( $custom_attributes as $key => $val ) { |
|
| 3905 | + if(is_array($val)){ |
|
| 3906 | + $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
|
| 3907 | + }else{ |
|
| 3908 | + $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
| 3909 | + } |
|
| 3910 | + } |
|
| 3913 | 3911 | |
| 3914 | - return $attributes; |
|
| 3915 | - } |
|
| 3912 | + } |
|
| 3913 | + |
|
| 3914 | + return $attributes; |
|
| 3915 | + } |
|
| 3916 | 3916 | |
| 3917 | 3917 | |
| 3918 | 3918 | |
| 3919 | - /** |
|
| 3920 | - * A self looping function to create the output for JS block elements. |
|
| 3921 | - * |
|
| 3922 | - * This is what is output in the WP Editor visual view. |
|
| 3923 | - * |
|
| 3924 | - * @param $args |
|
| 3925 | - */ |
|
| 3926 | - public function block_element( $args, $save = false ) { |
|
| 3919 | + /** |
|
| 3920 | + * A self looping function to create the output for JS block elements. |
|
| 3921 | + * |
|
| 3922 | + * This is what is output in the WP Editor visual view. |
|
| 3923 | + * |
|
| 3924 | + * @param $args |
|
| 3925 | + */ |
|
| 3926 | + public function block_element( $args, $save = false ) { |
|
| 3927 | 3927 | |
| 3928 | 3928 | |
| 3929 | - if ( ! empty( $args ) ) { |
|
| 3930 | - foreach ( $args as $element => $new_args ) { |
|
| 3929 | + if ( ! empty( $args ) ) { |
|
| 3930 | + foreach ( $args as $element => $new_args ) { |
|
| 3931 | 3931 | |
| 3932 | - if ( is_array( $new_args ) ) { // its an element |
|
| 3932 | + if ( is_array( $new_args ) ) { // its an element |
|
| 3933 | 3933 | |
| 3934 | 3934 | |
| 3935 | - if ( isset( $new_args['element'] ) ) { |
|
| 3935 | + if ( isset( $new_args['element'] ) ) { |
|
| 3936 | 3936 | |
| 3937 | - if ( isset( $new_args['element_require'] ) ) { |
|
| 3938 | - echo str_replace( array( |
|
| 3939 | - "'+", |
|
| 3940 | - "+'" |
|
| 3941 | - ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 3942 | - unset( $new_args['element_require'] ); |
|
| 3943 | - } |
|
| 3937 | + if ( isset( $new_args['element_require'] ) ) { |
|
| 3938 | + echo str_replace( array( |
|
| 3939 | + "'+", |
|
| 3940 | + "+'" |
|
| 3941 | + ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 3942 | + unset( $new_args['element_require'] ); |
|
| 3943 | + } |
|
| 3944 | 3944 | |
| 3945 | 3945 | if($new_args['element']=='InnerBlocks'){ |
| 3946 | 3946 | echo "\n el( InnerBlocks, {"; |
| 3947 | 3947 | }elseif($new_args['element']=='innerBlocksProps'){ |
| 3948 | 3948 | $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div'; |
| 3949 | - // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
|
| 3949 | + // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
|
| 3950 | 3950 | // echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3951 | 3951 | echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3952 | 3952 | echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {"; |
@@ -3956,74 +3956,74 @@ discard block |
||
| 3956 | 3956 | echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : ''; |
| 3957 | 3957 | // echo '###'; |
| 3958 | 3958 | |
| 3959 | - // echo '###'; |
|
| 3959 | + // echo '###'; |
|
| 3960 | 3960 | }elseif($new_args['element']=='BlocksProps'){ |
| 3961 | 3961 | |
| 3962 | - if ( isset($new_args['if_inner_element']) ) { |
|
| 3963 | - $element = $new_args['if_inner_element']; |
|
| 3964 | - }else { |
|
| 3965 | - $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
|
| 3966 | - } |
|
| 3962 | + if ( isset($new_args['if_inner_element']) ) { |
|
| 3963 | + $element = $new_args['if_inner_element']; |
|
| 3964 | + }else { |
|
| 3965 | + $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
|
| 3966 | + } |
|
| 3967 | 3967 | |
| 3968 | - unset($new_args['inner_element']); |
|
| 3968 | + unset($new_args['inner_element']); |
|
| 3969 | 3969 | echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {"; |
| 3970 | 3970 | echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; |
| 3971 | 3971 | |
| 3972 | 3972 | |
| 3973 | - // echo "} ),"; |
|
| 3973 | + // echo "} ),"; |
|
| 3974 | 3974 | |
| 3975 | 3975 | }else{ |
| 3976 | 3976 | echo "\n el( '" . $new_args['element'] . "', {"; |
| 3977 | 3977 | } |
| 3978 | 3978 | |
| 3979 | 3979 | |
| 3980 | - // get the attributes |
|
| 3981 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 3980 | + // get the attributes |
|
| 3981 | + foreach ( $new_args as $new_key => $new_value ) { |
|
| 3982 | 3982 | |
| 3983 | 3983 | |
| 3984 | - if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 3985 | - // do nothing |
|
| 3986 | - } else { |
|
| 3987 | - echo $this->block_element( array( $new_key => $new_value ),$save ); |
|
| 3988 | - } |
|
| 3989 | - } |
|
| 3984 | + if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 3985 | + // do nothing |
|
| 3986 | + } else { |
|
| 3987 | + echo $this->block_element( array( $new_key => $new_value ),$save ); |
|
| 3988 | + } |
|
| 3989 | + } |
|
| 3990 | 3990 | |
| 3991 | - echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes |
|
| 3991 | + echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes |
|
| 3992 | 3992 | |
| 3993 | - // get the content |
|
| 3994 | - $first_item = 0; |
|
| 3995 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 3996 | - if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) { |
|
| 3993 | + // get the content |
|
| 3994 | + $first_item = 0; |
|
| 3995 | + foreach ( $new_args as $new_key => $new_value ) { |
|
| 3996 | + if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) { |
|
| 3997 | 3997 | |
| 3998 | - if ( $new_key === 'content' ) { |
|
| 3999 | - echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 4000 | - }else if ( $new_key === 'if_content' ) { |
|
| 4001 | - echo $this->block_props_replace( $new_value ); |
|
| 4002 | - } |
|
| 3998 | + if ( $new_key === 'content' ) { |
|
| 3999 | + echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 4000 | + }else if ( $new_key === 'if_content' ) { |
|
| 4001 | + echo $this->block_props_replace( $new_value ); |
|
| 4002 | + } |
|
| 4003 | 4003 | |
| 4004 | - if ( is_array( $new_value ) ) { |
|
| 4004 | + if ( is_array( $new_value ) ) { |
|
| 4005 | 4005 | |
| 4006 | - if ( isset( $new_value['element_require'] ) ) { |
|
| 4007 | - echo str_replace( array( |
|
| 4008 | - "'+", |
|
| 4009 | - "+'" |
|
| 4010 | - ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 4011 | - unset( $new_value['element_require'] ); |
|
| 4012 | - } |
|
| 4006 | + if ( isset( $new_value['element_require'] ) ) { |
|
| 4007 | + echo str_replace( array( |
|
| 4008 | + "'+", |
|
| 4009 | + "+'" |
|
| 4010 | + ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 4011 | + unset( $new_value['element_require'] ); |
|
| 4012 | + } |
|
| 4013 | 4013 | |
| 4014 | - if ( isset( $new_value['element_repeat'] ) ) { |
|
| 4015 | - $x = 1; |
|
| 4016 | - while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 4017 | - $this->block_element( array( '' => $new_value ),$save ); |
|
| 4018 | - $x ++; |
|
| 4019 | - } |
|
| 4020 | - } else { |
|
| 4021 | - $this->block_element( array( '' => $new_value ),$save ); |
|
| 4022 | - } |
|
| 4023 | - } |
|
| 4024 | - $first_item ++; |
|
| 4025 | - } |
|
| 4026 | - } |
|
| 4014 | + if ( isset( $new_value['element_repeat'] ) ) { |
|
| 4015 | + $x = 1; |
|
| 4016 | + while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 4017 | + $this->block_element( array( '' => $new_value ),$save ); |
|
| 4018 | + $x ++; |
|
| 4019 | + } |
|
| 4020 | + } else { |
|
| 4021 | + $this->block_element( array( '' => $new_value ),$save ); |
|
| 4022 | + } |
|
| 4023 | + } |
|
| 4024 | + $first_item ++; |
|
| 4025 | + } |
|
| 4026 | + } |
|
| 4027 | 4027 | |
| 4028 | 4028 | if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){ |
| 4029 | 4029 | echo "))";// end content |
@@ -4032,1094 +4032,1094 @@ discard block |
||
| 4032 | 4032 | } |
| 4033 | 4033 | |
| 4034 | 4034 | |
| 4035 | - echo ", \n"; |
|
| 4035 | + echo ", \n"; |
|
| 4036 | 4036 | |
| 4037 | - } |
|
| 4038 | - } else { |
|
| 4037 | + } |
|
| 4038 | + } else { |
|
| 4039 | 4039 | |
| 4040 | - if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 4041 | - $extra = ''; |
|
| 4042 | - if( strpos($new_args, '[%WrapClass%]') !== false ){ |
|
| 4043 | - $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args); |
|
| 4044 | - $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args); |
|
| 4045 | - } |
|
| 4046 | - echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 4047 | - } elseif ( $element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false ) { |
|
| 4040 | + if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 4041 | + $extra = ''; |
|
| 4042 | + if( strpos($new_args, '[%WrapClass%]') !== false ){ |
|
| 4043 | + $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args); |
|
| 4044 | + $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args); |
|
| 4045 | + } |
|
| 4046 | + echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 4047 | + } elseif ( $element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false ) { |
|
| 4048 | 4048 | $new_args = str_replace('[%WrapStyle%]','',$new_args); |
| 4049 | 4049 | echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },"; |
| 4050 | 4050 | // echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
| 4051 | - } elseif ( $element == 'style' ) { |
|
| 4052 | - echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 4053 | - } elseif ( ( $element == 'class' || $element == 'className' ) && strpos($new_args, '[%WrapClass%]') !== false ) { |
|
| 4051 | + } elseif ( $element == 'style' ) { |
|
| 4052 | + echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 4053 | + } elseif ( ( $element == 'class' || $element == 'className' ) && strpos($new_args, '[%WrapClass%]') !== false ) { |
|
| 4054 | 4054 | $new_args = str_replace('[%WrapClass%]','',$new_args); |
| 4055 | 4055 | echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),"; |
| 4056 | - } elseif ( $element == 'template' && $new_args ) { |
|
| 4057 | - echo $element . ": $new_args,"; |
|
| 4058 | - } else { |
|
| 4059 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 4060 | - } |
|
| 4056 | + } elseif ( $element == 'template' && $new_args ) { |
|
| 4057 | + echo $element . ": $new_args,"; |
|
| 4058 | + } else { |
|
| 4059 | + echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 4060 | + } |
|
| 4061 | 4061 | |
| 4062 | - } |
|
| 4063 | - } |
|
| 4064 | - } |
|
| 4065 | - } |
|
| 4062 | + } |
|
| 4063 | + } |
|
| 4064 | + } |
|
| 4065 | + } |
|
| 4066 | 4066 | |
| 4067 | - /** |
|
| 4068 | - * Replace block attributes placeholders with the proper naming. |
|
| 4069 | - * |
|
| 4070 | - * @param $string |
|
| 4071 | - * |
|
| 4072 | - * @return mixed |
|
| 4073 | - */ |
|
| 4074 | - public function block_props_replace( $string, $no_wrap = false ) { |
|
| 4075 | - if ( $no_wrap ) { |
|
| 4076 | - $string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string ); |
|
| 4077 | - } else { |
|
| 4078 | - $string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string ); |
|
| 4079 | - } |
|
| 4067 | + /** |
|
| 4068 | + * Replace block attributes placeholders with the proper naming. |
|
| 4069 | + * |
|
| 4070 | + * @param $string |
|
| 4071 | + * |
|
| 4072 | + * @return mixed |
|
| 4073 | + */ |
|
| 4074 | + public function block_props_replace( $string, $no_wrap = false ) { |
|
| 4075 | + if ( $no_wrap ) { |
|
| 4076 | + $string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string ); |
|
| 4077 | + } else { |
|
| 4078 | + $string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string ); |
|
| 4079 | + } |
|
| 4080 | 4080 | |
| 4081 | - return $string; |
|
| 4082 | - } |
|
| 4081 | + return $string; |
|
| 4082 | + } |
|
| 4083 | 4083 | |
| 4084 | - /** |
|
| 4085 | - * Outputs the content of the widget |
|
| 4086 | - * |
|
| 4087 | - * @param array $args |
|
| 4088 | - * @param array $instance |
|
| 4089 | - */ |
|
| 4090 | - public function widget( $args, $instance ) { |
|
| 4091 | - if ( ! is_array( $args ) ) { |
|
| 4092 | - $args = array(); |
|
| 4093 | - } |
|
| 4084 | + /** |
|
| 4085 | + * Outputs the content of the widget |
|
| 4086 | + * |
|
| 4087 | + * @param array $args |
|
| 4088 | + * @param array $instance |
|
| 4089 | + */ |
|
| 4090 | + public function widget( $args, $instance ) { |
|
| 4091 | + if ( ! is_array( $args ) ) { |
|
| 4092 | + $args = array(); |
|
| 4093 | + } |
|
| 4094 | 4094 | |
| 4095 | - // Get the filtered values |
|
| 4096 | - $argument_values = $this->argument_values( $instance ); |
|
| 4097 | - $argument_values = $this->string_to_bool( $argument_values ); |
|
| 4098 | - $output = $this->output( $argument_values, $args ); |
|
| 4095 | + // Get the filtered values |
|
| 4096 | + $argument_values = $this->argument_values( $instance ); |
|
| 4097 | + $argument_values = $this->string_to_bool( $argument_values ); |
|
| 4098 | + $output = $this->output( $argument_values, $args ); |
|
| 4099 | 4099 | |
| 4100 | - $no_wrap = false; |
|
| 4101 | - if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 4102 | - $no_wrap = true; |
|
| 4103 | - } |
|
| 4100 | + $no_wrap = false; |
|
| 4101 | + if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 4102 | + $no_wrap = true; |
|
| 4103 | + } |
|
| 4104 | 4104 | |
| 4105 | - ob_start(); |
|
| 4106 | - if ( $output && ! $no_wrap ) { |
|
| 4105 | + ob_start(); |
|
| 4106 | + if ( $output && ! $no_wrap ) { |
|
| 4107 | 4107 | |
| 4108 | - $class_original = $this->options['widget_ops']['classname']; |
|
| 4109 | - $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); |
|
| 4108 | + $class_original = $this->options['widget_ops']['classname']; |
|
| 4109 | + $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); |
|
| 4110 | 4110 | |
| 4111 | - // Before widget |
|
| 4112 | - $before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : ''; |
|
| 4113 | - $before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget; |
|
| 4114 | - $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 4115 | - $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 4111 | + // Before widget |
|
| 4112 | + $before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : ''; |
|
| 4113 | + $before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget; |
|
| 4114 | + $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 4115 | + $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 4116 | 4116 | |
| 4117 | - // After widget |
|
| 4118 | - $after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : ''; |
|
| 4119 | - $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 4120 | - $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 4117 | + // After widget |
|
| 4118 | + $after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : ''; |
|
| 4119 | + $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 4120 | + $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 4121 | 4121 | |
| 4122 | - echo $before_widget; |
|
| 4123 | - // elementor strips the widget wrapping div so we check for and add it back if needed |
|
| 4124 | - if ( $this->is_elementor_widget_output() ) { |
|
| 4125 | - // Filter class & attrs for elementor widget output. |
|
| 4126 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 4127 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 4122 | + echo $before_widget; |
|
| 4123 | + // elementor strips the widget wrapping div so we check for and add it back if needed |
|
| 4124 | + if ( $this->is_elementor_widget_output() ) { |
|
| 4125 | + // Filter class & attrs for elementor widget output. |
|
| 4126 | + $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 4127 | + $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 4128 | 4128 | |
| 4129 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 4130 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 4129 | + $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 4130 | + $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 4131 | 4131 | |
| 4132 | - echo "<span class='" . esc_attr( $class ) . "' " . $attrs . ">"; |
|
| 4133 | - } |
|
| 4134 | - echo $this->output_title( $args, $instance ); |
|
| 4135 | - echo $output; |
|
| 4136 | - if ( $this->is_elementor_widget_output() ) { |
|
| 4137 | - echo "</span>"; |
|
| 4138 | - } |
|
| 4139 | - echo $after_widget; |
|
| 4140 | - } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 4141 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 4142 | - echo $output; |
|
| 4143 | - } elseif ( $output && $no_wrap ) { |
|
| 4144 | - echo $output; |
|
| 4145 | - } |
|
| 4146 | - $output = ob_get_clean(); |
|
| 4132 | + echo "<span class='" . esc_attr( $class ) . "' " . $attrs . ">"; |
|
| 4133 | + } |
|
| 4134 | + echo $this->output_title( $args, $instance ); |
|
| 4135 | + echo $output; |
|
| 4136 | + if ( $this->is_elementor_widget_output() ) { |
|
| 4137 | + echo "</span>"; |
|
| 4138 | + } |
|
| 4139 | + echo $after_widget; |
|
| 4140 | + } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 4141 | + $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 4142 | + echo $output; |
|
| 4143 | + } elseif ( $output && $no_wrap ) { |
|
| 4144 | + echo $output; |
|
| 4145 | + } |
|
| 4146 | + $output = ob_get_clean(); |
|
| 4147 | 4147 | |
| 4148 | - $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 4148 | + $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 4149 | 4149 | |
| 4150 | - echo $output; |
|
| 4151 | - } |
|
| 4150 | + echo $output; |
|
| 4151 | + } |
|
| 4152 | 4152 | |
| 4153 | - /** |
|
| 4154 | - * Tests if the current output is inside a elementor container. |
|
| 4155 | - * |
|
| 4156 | - * @return bool |
|
| 4157 | - *@since 1.0.4 |
|
| 4158 | - */ |
|
| 4159 | - public function is_elementor_widget_output() { |
|
| 4160 | - $result = false; |
|
| 4161 | - if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 4162 | - $result = true; |
|
| 4163 | - } |
|
| 4153 | + /** |
|
| 4154 | + * Tests if the current output is inside a elementor container. |
|
| 4155 | + * |
|
| 4156 | + * @return bool |
|
| 4157 | + *@since 1.0.4 |
|
| 4158 | + */ |
|
| 4159 | + public function is_elementor_widget_output() { |
|
| 4160 | + $result = false; |
|
| 4161 | + if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 4162 | + $result = true; |
|
| 4163 | + } |
|
| 4164 | 4164 | |
| 4165 | - return $result; |
|
| 4166 | - } |
|
| 4165 | + return $result; |
|
| 4166 | + } |
|
| 4167 | 4167 | |
| 4168 | - /** |
|
| 4169 | - * Tests if the current output is inside a elementor preview. |
|
| 4170 | - * |
|
| 4171 | - * @return bool |
|
| 4172 | - *@since 1.0.4 |
|
| 4173 | - */ |
|
| 4174 | - public function is_elementor_preview() { |
|
| 4175 | - $result = false; |
|
| 4176 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 4177 | - $result = true; |
|
| 4178 | - } |
|
| 4168 | + /** |
|
| 4169 | + * Tests if the current output is inside a elementor preview. |
|
| 4170 | + * |
|
| 4171 | + * @return bool |
|
| 4172 | + *@since 1.0.4 |
|
| 4173 | + */ |
|
| 4174 | + public function is_elementor_preview() { |
|
| 4175 | + $result = false; |
|
| 4176 | + if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 4177 | + $result = true; |
|
| 4178 | + } |
|
| 4179 | 4179 | |
| 4180 | - return $result; |
|
| 4181 | - } |
|
| 4180 | + return $result; |
|
| 4181 | + } |
|
| 4182 | 4182 | |
| 4183 | - /** |
|
| 4184 | - * Tests if the current output is inside a Divi preview. |
|
| 4185 | - * |
|
| 4186 | - * @return bool |
|
| 4187 | - *@since 1.0.6 |
|
| 4188 | - */ |
|
| 4189 | - public function is_divi_preview() { |
|
| 4190 | - $result = false; |
|
| 4191 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 4192 | - $result = true; |
|
| 4193 | - } |
|
| 4183 | + /** |
|
| 4184 | + * Tests if the current output is inside a Divi preview. |
|
| 4185 | + * |
|
| 4186 | + * @return bool |
|
| 4187 | + *@since 1.0.6 |
|
| 4188 | + */ |
|
| 4189 | + public function is_divi_preview() { |
|
| 4190 | + $result = false; |
|
| 4191 | + if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 4192 | + $result = true; |
|
| 4193 | + } |
|
| 4194 | 4194 | |
| 4195 | - return $result; |
|
| 4196 | - } |
|
| 4195 | + return $result; |
|
| 4196 | + } |
|
| 4197 | 4197 | |
| 4198 | - /** |
|
| 4199 | - * Tests if the current output is inside a Beaver builder preview. |
|
| 4200 | - * |
|
| 4201 | - * @return bool |
|
| 4202 | - *@since 1.0.6 |
|
| 4203 | - */ |
|
| 4204 | - public function is_beaver_preview() { |
|
| 4205 | - $result = false; |
|
| 4206 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 4207 | - $result = true; |
|
| 4208 | - } |
|
| 4198 | + /** |
|
| 4199 | + * Tests if the current output is inside a Beaver builder preview. |
|
| 4200 | + * |
|
| 4201 | + * @return bool |
|
| 4202 | + *@since 1.0.6 |
|
| 4203 | + */ |
|
| 4204 | + public function is_beaver_preview() { |
|
| 4205 | + $result = false; |
|
| 4206 | + if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 4207 | + $result = true; |
|
| 4208 | + } |
|
| 4209 | 4209 | |
| 4210 | - return $result; |
|
| 4211 | - } |
|
| 4210 | + return $result; |
|
| 4211 | + } |
|
| 4212 | 4212 | |
| 4213 | - /** |
|
| 4214 | - * Tests if the current output is inside a siteorigin builder preview. |
|
| 4215 | - * |
|
| 4216 | - * @return bool |
|
| 4217 | - *@since 1.0.6 |
|
| 4218 | - */ |
|
| 4219 | - public function is_siteorigin_preview() { |
|
| 4220 | - $result = false; |
|
| 4221 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 4222 | - $result = true; |
|
| 4223 | - } |
|
| 4213 | + /** |
|
| 4214 | + * Tests if the current output is inside a siteorigin builder preview. |
|
| 4215 | + * |
|
| 4216 | + * @return bool |
|
| 4217 | + *@since 1.0.6 |
|
| 4218 | + */ |
|
| 4219 | + public function is_siteorigin_preview() { |
|
| 4220 | + $result = false; |
|
| 4221 | + if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 4222 | + $result = true; |
|
| 4223 | + } |
|
| 4224 | 4224 | |
| 4225 | - return $result; |
|
| 4226 | - } |
|
| 4225 | + return $result; |
|
| 4226 | + } |
|
| 4227 | 4227 | |
| 4228 | - /** |
|
| 4229 | - * Tests if the current output is inside a cornerstone builder preview. |
|
| 4230 | - * |
|
| 4231 | - * @return bool |
|
| 4232 | - *@since 1.0.8 |
|
| 4233 | - */ |
|
| 4234 | - public function is_cornerstone_preview() { |
|
| 4235 | - $result = false; |
|
| 4236 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 4237 | - $result = true; |
|
| 4238 | - } |
|
| 4228 | + /** |
|
| 4229 | + * Tests if the current output is inside a cornerstone builder preview. |
|
| 4230 | + * |
|
| 4231 | + * @return bool |
|
| 4232 | + *@since 1.0.8 |
|
| 4233 | + */ |
|
| 4234 | + public function is_cornerstone_preview() { |
|
| 4235 | + $result = false; |
|
| 4236 | + if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 4237 | + $result = true; |
|
| 4238 | + } |
|
| 4239 | 4239 | |
| 4240 | - return $result; |
|
| 4241 | - } |
|
| 4240 | + return $result; |
|
| 4241 | + } |
|
| 4242 | 4242 | |
| 4243 | - /** |
|
| 4244 | - * Tests if the current output is inside a fusion builder preview. |
|
| 4245 | - * |
|
| 4246 | - * @return bool |
|
| 4247 | - *@since 1.1.0 |
|
| 4248 | - */ |
|
| 4249 | - public function is_fusion_preview() { |
|
| 4250 | - $result = false; |
|
| 4251 | - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 4252 | - $result = true; |
|
| 4253 | - } |
|
| 4243 | + /** |
|
| 4244 | + * Tests if the current output is inside a fusion builder preview. |
|
| 4245 | + * |
|
| 4246 | + * @return bool |
|
| 4247 | + *@since 1.1.0 |
|
| 4248 | + */ |
|
| 4249 | + public function is_fusion_preview() { |
|
| 4250 | + $result = false; |
|
| 4251 | + if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 4252 | + $result = true; |
|
| 4253 | + } |
|
| 4254 | 4254 | |
| 4255 | - return $result; |
|
| 4256 | - } |
|
| 4255 | + return $result; |
|
| 4256 | + } |
|
| 4257 | 4257 | |
| 4258 | - /** |
|
| 4259 | - * Tests if the current output is inside a Oxygen builder preview. |
|
| 4260 | - * |
|
| 4261 | - * @return bool |
|
| 4262 | - *@since 1.0.18 |
|
| 4263 | - */ |
|
| 4264 | - public function is_oxygen_preview() { |
|
| 4265 | - $result = false; |
|
| 4266 | - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 4267 | - $result = true; |
|
| 4268 | - } |
|
| 4258 | + /** |
|
| 4259 | + * Tests if the current output is inside a Oxygen builder preview. |
|
| 4260 | + * |
|
| 4261 | + * @return bool |
|
| 4262 | + *@since 1.0.18 |
|
| 4263 | + */ |
|
| 4264 | + public function is_oxygen_preview() { |
|
| 4265 | + $result = false; |
|
| 4266 | + if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 4267 | + $result = true; |
|
| 4268 | + } |
|
| 4269 | 4269 | |
| 4270 | - return $result; |
|
| 4271 | - } |
|
| 4270 | + return $result; |
|
| 4271 | + } |
|
| 4272 | 4272 | |
| 4273 | - /** |
|
| 4274 | - * Check for Kallyas theme Zion builder preview. |
|
| 4275 | - * |
|
| 4276 | - * @since 1.1.22 |
|
| 4277 | - * |
|
| 4278 | - * @return bool True when preview page otherwise false. |
|
| 4279 | - */ |
|
| 4280 | - public function is_kallyas_zion_preview() { |
|
| 4281 | - $result = false; |
|
| 4282 | - |
|
| 4283 | - if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) { |
|
| 4284 | - $result = true; |
|
| 4285 | - } |
|
| 4273 | + /** |
|
| 4274 | + * Check for Kallyas theme Zion builder preview. |
|
| 4275 | + * |
|
| 4276 | + * @since 1.1.22 |
|
| 4277 | + * |
|
| 4278 | + * @return bool True when preview page otherwise false. |
|
| 4279 | + */ |
|
| 4280 | + public function is_kallyas_zion_preview() { |
|
| 4281 | + $result = false; |
|
| 4286 | 4282 | |
| 4287 | - return $result; |
|
| 4288 | - } |
|
| 4283 | + if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) { |
|
| 4284 | + $result = true; |
|
| 4285 | + } |
|
| 4289 | 4286 | |
| 4290 | - /** |
|
| 4291 | - * Check for Bricks theme builder preview. |
|
| 4292 | - * |
|
| 4293 | - * @since 1.1.31 |
|
| 4294 | - * |
|
| 4295 | - * @return bool True when preview page otherwise false. |
|
| 4296 | - */ |
|
| 4297 | - public function is_bricks_preview() { |
|
| 4298 | - $result = false; |
|
| 4299 | - |
|
| 4300 | - if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) { |
|
| 4301 | - $result = true; |
|
| 4302 | - } |
|
| 4287 | + return $result; |
|
| 4288 | + } |
|
| 4303 | 4289 | |
| 4304 | - return $result; |
|
| 4305 | - } |
|
| 4290 | + /** |
|
| 4291 | + * Check for Bricks theme builder preview. |
|
| 4292 | + * |
|
| 4293 | + * @since 1.1.31 |
|
| 4294 | + * |
|
| 4295 | + * @return bool True when preview page otherwise false. |
|
| 4296 | + */ |
|
| 4297 | + public function is_bricks_preview() { |
|
| 4298 | + $result = false; |
|
| 4306 | 4299 | |
| 4307 | - /** |
|
| 4308 | - * General function to check if we are in a preview situation. |
|
| 4309 | - * |
|
| 4310 | - * @return bool |
|
| 4311 | - *@since 1.0.6 |
|
| 4312 | - */ |
|
| 4313 | - public function is_preview() { |
|
| 4314 | - $preview = false; |
|
| 4315 | - if ( $this->is_divi_preview() ) { |
|
| 4316 | - $preview = true; |
|
| 4317 | - } elseif ( $this->is_elementor_preview() ) { |
|
| 4318 | - $preview = true; |
|
| 4319 | - } elseif ( $this->is_beaver_preview() ) { |
|
| 4320 | - $preview = true; |
|
| 4321 | - } elseif ( $this->is_siteorigin_preview() ) { |
|
| 4322 | - $preview = true; |
|
| 4323 | - } elseif ( $this->is_cornerstone_preview() ) { |
|
| 4324 | - $preview = true; |
|
| 4325 | - } elseif ( $this->is_fusion_preview() ) { |
|
| 4326 | - $preview = true; |
|
| 4327 | - } elseif ( $this->is_oxygen_preview() ) { |
|
| 4328 | - $preview = true; |
|
| 4329 | - } elseif( $this->is_kallyas_zion_preview() ) { |
|
| 4330 | - $preview = true; |
|
| 4331 | - } elseif( $this->is_block_content_call() ) { |
|
| 4332 | - $preview = true; |
|
| 4333 | - } elseif( $this->is_bricks_preview() ) { |
|
| 4334 | - $preview = true; |
|
| 4335 | - } |
|
| 4300 | + if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) { |
|
| 4301 | + $result = true; |
|
| 4302 | + } |
|
| 4336 | 4303 | |
| 4337 | - return $preview; |
|
| 4338 | - } |
|
| 4304 | + return $result; |
|
| 4305 | + } |
|
| 4339 | 4306 | |
| 4340 | - /** |
|
| 4341 | - * Output the super title. |
|
| 4342 | - * |
|
| 4343 | - * @param $args |
|
| 4344 | - * @param array $instance |
|
| 4345 | - * |
|
| 4346 | - * @return string |
|
| 4347 | - */ |
|
| 4348 | - public function output_title( $args, $instance = array() ) { |
|
| 4349 | - $output = ''; |
|
| 4350 | - if ( ! empty( $instance['title'] ) ) { |
|
| 4351 | - /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
| 4352 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 4353 | - |
|
| 4354 | - if(empty($instance['widget_title_tag'])){ |
|
| 4355 | - $output = $args['before_title'] . $title . $args['after_title']; |
|
| 4356 | - }else{ |
|
| 4357 | - $title_tag = esc_attr( $instance['widget_title_tag'] ); |
|
| 4358 | - |
|
| 4359 | - // classes |
|
| 4360 | - $title_classes = array(); |
|
| 4361 | - $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
| 4362 | - $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
| 4363 | - $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
| 4364 | - $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
| 4365 | - $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
| 4366 | - $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
| 4367 | - $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
| 4368 | - $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
| 4369 | - $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
| 4370 | - $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
| 4371 | - $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
| 4372 | - $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
| 4373 | - $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
| 4374 | - |
|
| 4375 | - $class = !empty( $title_classes ) ? implode(" ",$title_classes) : ''; |
|
| 4376 | - $output = "<$title_tag class='$class' >$title</$title_tag>"; |
|
| 4377 | - } |
|
| 4307 | + /** |
|
| 4308 | + * General function to check if we are in a preview situation. |
|
| 4309 | + * |
|
| 4310 | + * @return bool |
|
| 4311 | + *@since 1.0.6 |
|
| 4312 | + */ |
|
| 4313 | + public function is_preview() { |
|
| 4314 | + $preview = false; |
|
| 4315 | + if ( $this->is_divi_preview() ) { |
|
| 4316 | + $preview = true; |
|
| 4317 | + } elseif ( $this->is_elementor_preview() ) { |
|
| 4318 | + $preview = true; |
|
| 4319 | + } elseif ( $this->is_beaver_preview() ) { |
|
| 4320 | + $preview = true; |
|
| 4321 | + } elseif ( $this->is_siteorigin_preview() ) { |
|
| 4322 | + $preview = true; |
|
| 4323 | + } elseif ( $this->is_cornerstone_preview() ) { |
|
| 4324 | + $preview = true; |
|
| 4325 | + } elseif ( $this->is_fusion_preview() ) { |
|
| 4326 | + $preview = true; |
|
| 4327 | + } elseif ( $this->is_oxygen_preview() ) { |
|
| 4328 | + $preview = true; |
|
| 4329 | + } elseif( $this->is_kallyas_zion_preview() ) { |
|
| 4330 | + $preview = true; |
|
| 4331 | + } elseif( $this->is_block_content_call() ) { |
|
| 4332 | + $preview = true; |
|
| 4333 | + } elseif( $this->is_bricks_preview() ) { |
|
| 4334 | + $preview = true; |
|
| 4335 | + } |
|
| 4378 | 4336 | |
| 4379 | - } |
|
| 4337 | + return $preview; |
|
| 4338 | + } |
|
| 4380 | 4339 | |
| 4381 | - return $output; |
|
| 4382 | - } |
|
| 4340 | + /** |
|
| 4341 | + * Output the super title. |
|
| 4342 | + * |
|
| 4343 | + * @param $args |
|
| 4344 | + * @param array $instance |
|
| 4345 | + * |
|
| 4346 | + * @return string |
|
| 4347 | + */ |
|
| 4348 | + public function output_title( $args, $instance = array() ) { |
|
| 4349 | + $output = ''; |
|
| 4350 | + if ( ! empty( $instance['title'] ) ) { |
|
| 4351 | + /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
| 4352 | + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 4353 | + |
|
| 4354 | + if(empty($instance['widget_title_tag'])){ |
|
| 4355 | + $output = $args['before_title'] . $title . $args['after_title']; |
|
| 4356 | + }else{ |
|
| 4357 | + $title_tag = esc_attr( $instance['widget_title_tag'] ); |
|
| 4358 | + |
|
| 4359 | + // classes |
|
| 4360 | + $title_classes = array(); |
|
| 4361 | + $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
| 4362 | + $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
| 4363 | + $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
| 4364 | + $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
| 4365 | + $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
| 4366 | + $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
| 4367 | + $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
| 4368 | + $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
| 4369 | + $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
| 4370 | + $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
| 4371 | + $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
| 4372 | + $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
| 4373 | + $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
| 4374 | + |
|
| 4375 | + $class = !empty( $title_classes ) ? implode(" ",$title_classes) : ''; |
|
| 4376 | + $output = "<$title_tag class='$class' >$title</$title_tag>"; |
|
| 4377 | + } |
|
| 4378 | + |
|
| 4379 | + } |
|
| 4383 | 4380 | |
| 4384 | - /** |
|
| 4385 | - * Outputs the options form inputs for the widget. |
|
| 4386 | - * |
|
| 4387 | - * @param array $instance The widget options. |
|
| 4388 | - */ |
|
| 4389 | - public function form( $instance ) { |
|
| 4381 | + return $output; |
|
| 4382 | + } |
|
| 4383 | + |
|
| 4384 | + /** |
|
| 4385 | + * Outputs the options form inputs for the widget. |
|
| 4386 | + * |
|
| 4387 | + * @param array $instance The widget options. |
|
| 4388 | + */ |
|
| 4389 | + public function form( $instance ) { |
|
| 4390 | 4390 | |
| 4391 | - // set widget instance |
|
| 4392 | - $this->instance = $instance; |
|
| 4391 | + // set widget instance |
|
| 4392 | + $this->instance = $instance; |
|
| 4393 | 4393 | |
| 4394 | - // set it as a SD widget |
|
| 4395 | - echo $this->widget_advanced_toggle(); |
|
| 4394 | + // set it as a SD widget |
|
| 4395 | + echo $this->widget_advanced_toggle(); |
|
| 4396 | 4396 | |
| 4397 | - echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 4398 | - $arguments_raw = $this->get_arguments(); |
|
| 4397 | + echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 4398 | + $arguments_raw = $this->get_arguments(); |
|
| 4399 | 4399 | |
| 4400 | - if ( is_array( $arguments_raw ) ) { |
|
| 4400 | + if ( is_array( $arguments_raw ) ) { |
|
| 4401 | 4401 | |
| 4402 | - $arguments = $this->group_arguments( $arguments_raw ); |
|
| 4402 | + $arguments = $this->group_arguments( $arguments_raw ); |
|
| 4403 | 4403 | |
| 4404 | - // Do we have sections? |
|
| 4405 | - $has_sections = $arguments == $arguments_raw ? false : true; |
|
| 4404 | + // Do we have sections? |
|
| 4405 | + $has_sections = $arguments == $arguments_raw ? false : true; |
|
| 4406 | 4406 | |
| 4407 | 4407 | |
| 4408 | - if ( $has_sections ) { |
|
| 4409 | - $panel_count = 0; |
|
| 4410 | - foreach ( $arguments as $key => $args ) { |
|
| 4408 | + if ( $has_sections ) { |
|
| 4409 | + $panel_count = 0; |
|
| 4410 | + foreach ( $arguments as $key => $args ) { |
|
| 4411 | 4411 | |
| 4412 | - ?> |
|
| 4412 | + ?> |
|
| 4413 | 4413 | <script> |
| 4414 | 4414 | // jQuery(this).find("i").toggleClass("fas fa-chevron-up fas fa-chevron-down");jQuery(this).next().toggle(); |
| 4415 | 4415 | </script> |
| 4416 | 4416 | <?php |
| 4417 | 4417 | |
| 4418 | - $hide = $panel_count ? ' style="display:none;" ' : ''; |
|
| 4419 | - $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
|
| 4420 | - echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 4421 | - echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 4418 | + $hide = $panel_count ? ' style="display:none;" ' : ''; |
|
| 4419 | + $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
|
| 4420 | + echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 4421 | + echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 4422 | 4422 | |
| 4423 | - foreach ( $args as $k => $a ) { |
|
| 4423 | + foreach ( $args as $k => $a ) { |
|
| 4424 | 4424 | |
| 4425 | - $this->widget_inputs_row_start($k, $a); |
|
| 4426 | - $this->widget_inputs( $a, $instance ); |
|
| 4427 | - $this->widget_inputs_row_end($k, $a); |
|
| 4425 | + $this->widget_inputs_row_start($k, $a); |
|
| 4426 | + $this->widget_inputs( $a, $instance ); |
|
| 4427 | + $this->widget_inputs_row_end($k, $a); |
|
| 4428 | 4428 | |
| 4429 | - } |
|
| 4429 | + } |
|
| 4430 | 4430 | |
| 4431 | - echo "</div>"; |
|
| 4431 | + echo "</div>"; |
|
| 4432 | 4432 | |
| 4433 | - $panel_count ++; |
|
| 4433 | + $panel_count ++; |
|
| 4434 | 4434 | |
| 4435 | - } |
|
| 4436 | - } else { |
|
| 4437 | - foreach ( $arguments as $key => $args ) { |
|
| 4438 | - $this->widget_inputs_row_start($key, $args); |
|
| 4439 | - $this->widget_inputs( $args, $instance ); |
|
| 4440 | - $this->widget_inputs_row_end($key, $args); |
|
| 4441 | - } |
|
| 4442 | - } |
|
| 4435 | + } |
|
| 4436 | + } else { |
|
| 4437 | + foreach ( $arguments as $key => $args ) { |
|
| 4438 | + $this->widget_inputs_row_start($key, $args); |
|
| 4439 | + $this->widget_inputs( $args, $instance ); |
|
| 4440 | + $this->widget_inputs_row_end($key, $args); |
|
| 4441 | + } |
|
| 4442 | + } |
|
| 4443 | 4443 | |
| 4444 | - } |
|
| 4445 | - } |
|
| 4444 | + } |
|
| 4445 | + } |
|
| 4446 | 4446 | |
| 4447 | - public function widget_inputs_row_start( $key, $args ) { |
|
| 4448 | - if ( ! empty( $args['row'] ) ) { |
|
| 4449 | - // Maybe open |
|
| 4450 | - if ( ! empty( $args['row']['open'] ) ) { |
|
| 4451 | - ?> |
|
| 4447 | + public function widget_inputs_row_start( $key, $args ) { |
|
| 4448 | + if ( ! empty( $args['row'] ) ) { |
|
| 4449 | + // Maybe open |
|
| 4450 | + if ( ! empty( $args['row']['open'] ) ) { |
|
| 4451 | + ?> |
|
| 4452 | 4452 | <div class='bsui sd-argument' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php echo ( ! empty( $args['row']['element_require'] ) ? $this->convert_element_require( $args['row']['element_require'] ) : '' ); ?>'> |
| 4453 | 4453 | <?php if ( ! empty( $args['row']['title'] ) ) { ?> |
| 4454 | 4454 | <?php |
| 4455 | - if ( isset( $args['row']['icon'] ) ) { |
|
| 4456 | - $args['row']['icon'] = ''; |
|
| 4457 | - } |
|
| 4455 | + if ( isset( $args['row']['icon'] ) ) { |
|
| 4456 | + $args['row']['icon'] = ''; |
|
| 4457 | + } |
|
| 4458 | 4458 | |
| 4459 | - if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) { |
|
| 4460 | - $args['row']['device_type'] = $args['device_type']; |
|
| 4461 | - } |
|
| 4462 | - ?> |
|
| 4459 | + if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) { |
|
| 4460 | + $args['row']['device_type'] = $args['device_type']; |
|
| 4461 | + } |
|
| 4462 | + ?> |
|
| 4463 | 4463 | <label class="mb-0"><?php echo $this->widget_field_title( $args['row'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label> |
| 4464 | 4464 | <?php } ?> |
| 4465 | 4465 | <div class='row<?php echo ( ! empty( $args['row']['class'] ) ? ' ' . esc_attr( $args['row']['class'] ) : '' ); ?>'> |
| 4466 | 4466 | <div class='col pr-2'> |
| 4467 | 4467 | <?php |
| 4468 | - } else if ( ! empty( $args['row']['close'] ) ) { |
|
| 4469 | - echo "<div class='col pl-0 ps-0'>"; |
|
| 4470 | - } else { |
|
| 4471 | - echo "<div class='col pl-0 ps-0 pr-2 pe-2'>"; |
|
| 4472 | - } |
|
| 4473 | - } |
|
| 4474 | - } |
|
| 4468 | + } else if ( ! empty( $args['row']['close'] ) ) { |
|
| 4469 | + echo "<div class='col pl-0 ps-0'>"; |
|
| 4470 | + } else { |
|
| 4471 | + echo "<div class='col pl-0 ps-0 pr-2 pe-2'>"; |
|
| 4472 | + } |
|
| 4473 | + } |
|
| 4474 | + } |
|
| 4475 | 4475 | |
| 4476 | - public function widget_inputs_row_end( $key, $args ) { |
|
| 4477 | - if ( ! empty( $args['row'] ) ) { |
|
| 4478 | - // Maybe close |
|
| 4479 | - if ( ! empty( $args['row']['close'] ) ) { |
|
| 4480 | - echo "</div></div>"; |
|
| 4481 | - } |
|
| 4482 | - echo "</div>"; |
|
| 4483 | - } |
|
| 4484 | - } |
|
| 4476 | + public function widget_inputs_row_end( $key, $args ) { |
|
| 4477 | + if ( ! empty( $args['row'] ) ) { |
|
| 4478 | + // Maybe close |
|
| 4479 | + if ( ! empty( $args['row']['close'] ) ) { |
|
| 4480 | + echo "</div></div>"; |
|
| 4481 | + } |
|
| 4482 | + echo "</div>"; |
|
| 4483 | + } |
|
| 4484 | + } |
|
| 4485 | 4485 | |
| 4486 | - /** |
|
| 4487 | - * Get the hidden input that when added makes the advanced button show on widget settings. |
|
| 4488 | - * |
|
| 4489 | - * @return string |
|
| 4490 | - */ |
|
| 4491 | - public function widget_advanced_toggle() { |
|
| 4486 | + /** |
|
| 4487 | + * Get the hidden input that when added makes the advanced button show on widget settings. |
|
| 4488 | + * |
|
| 4489 | + * @return string |
|
| 4490 | + */ |
|
| 4491 | + public function widget_advanced_toggle() { |
|
| 4492 | 4492 | |
| 4493 | - $output = ''; |
|
| 4494 | - if ( $this->block_show_advanced() ) { |
|
| 4495 | - $val = 1; |
|
| 4496 | - } else { |
|
| 4497 | - $val = 0; |
|
| 4498 | - } |
|
| 4493 | + $output = ''; |
|
| 4494 | + if ( $this->block_show_advanced() ) { |
|
| 4495 | + $val = 1; |
|
| 4496 | + } else { |
|
| 4497 | + $val = 0; |
|
| 4498 | + } |
|
| 4499 | 4499 | |
| 4500 | - $output .= "<input type='hidden' class='sd-show-advanced' value='$val' />"; |
|
| 4500 | + $output .= "<input type='hidden' class='sd-show-advanced' value='$val' />"; |
|
| 4501 | 4501 | |
| 4502 | - return $output; |
|
| 4503 | - } |
|
| 4502 | + return $output; |
|
| 4503 | + } |
|
| 4504 | 4504 | |
| 4505 | - /** |
|
| 4506 | - * Convert require element. |
|
| 4507 | - * |
|
| 4508 | - * @param string $input Input element. |
|
| 4509 | - * |
|
| 4510 | - * @return string $output |
|
| 4511 | - *@since 1.0.0 |
|
| 4512 | - * |
|
| 4513 | - */ |
|
| 4514 | - public function convert_element_require( $input ) { |
|
| 4515 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 4516 | - |
|
| 4517 | - $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array( |
|
| 4518 | - "jQuery(form).find('[data-argument=\"", |
|
| 4519 | - "\"]').find('input,select,textarea').val()", |
|
| 4520 | - "\"]').find('input:checked').val()" |
|
| 4521 | - ), $input ) ); |
|
| 4522 | - |
|
| 4523 | - return $output; |
|
| 4524 | - } |
|
| 4505 | + /** |
|
| 4506 | + * Convert require element. |
|
| 4507 | + * |
|
| 4508 | + * @param string $input Input element. |
|
| 4509 | + * |
|
| 4510 | + * @return string $output |
|
| 4511 | + *@since 1.0.0 |
|
| 4512 | + * |
|
| 4513 | + */ |
|
| 4514 | + public function convert_element_require( $input ) { |
|
| 4515 | + $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 4525 | 4516 | |
| 4526 | - /** |
|
| 4527 | - * Builds the inputs for the widget options. |
|
| 4528 | - * |
|
| 4529 | - * @param $args |
|
| 4530 | - * @param $instance |
|
| 4531 | - */ |
|
| 4532 | - public function widget_inputs( $args, $instance ) { |
|
| 4533 | - |
|
| 4534 | - $class = ""; |
|
| 4535 | - $element_require = ""; |
|
| 4536 | - $custom_attributes = ""; |
|
| 4537 | - |
|
| 4538 | - // get value |
|
| 4539 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 4540 | - $value = $instance[ $args['name'] ]; |
|
| 4541 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 4542 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 4543 | - } else { |
|
| 4544 | - $value = ''; |
|
| 4545 | - } |
|
| 4517 | + $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array( |
|
| 4518 | + "jQuery(form).find('[data-argument=\"", |
|
| 4519 | + "\"]').find('input,select,textarea').val()", |
|
| 4520 | + "\"]').find('input:checked').val()" |
|
| 4521 | + ), $input ) ); |
|
| 4546 | 4522 | |
| 4547 | - // get placeholder |
|
| 4548 | - if ( ! empty( $args['placeholder'] ) ) { |
|
| 4549 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 4550 | - } else { |
|
| 4551 | - $placeholder = ''; |
|
| 4552 | - } |
|
| 4523 | + return $output; |
|
| 4524 | + } |
|
| 4553 | 4525 | |
| 4554 | - // get if advanced |
|
| 4555 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 4556 | - $class .= " sd-advanced-setting "; |
|
| 4557 | - } |
|
| 4526 | + /** |
|
| 4527 | + * Builds the inputs for the widget options. |
|
| 4528 | + * |
|
| 4529 | + * @param $args |
|
| 4530 | + * @param $instance |
|
| 4531 | + */ |
|
| 4532 | + public function widget_inputs( $args, $instance ) { |
|
| 4533 | + |
|
| 4534 | + $class = ""; |
|
| 4535 | + $element_require = ""; |
|
| 4536 | + $custom_attributes = ""; |
|
| 4537 | + |
|
| 4538 | + // get value |
|
| 4539 | + if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 4540 | + $value = $instance[ $args['name'] ]; |
|
| 4541 | + } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 4542 | + $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 4543 | + } else { |
|
| 4544 | + $value = ''; |
|
| 4545 | + } |
|
| 4558 | 4546 | |
| 4559 | - // element_require |
|
| 4560 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 4561 | - $element_require = $args['element_require']; |
|
| 4562 | - } |
|
| 4547 | + // get placeholder |
|
| 4548 | + if ( ! empty( $args['placeholder'] ) ) { |
|
| 4549 | + $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 4550 | + } else { |
|
| 4551 | + $placeholder = ''; |
|
| 4552 | + } |
|
| 4563 | 4553 | |
| 4564 | - // custom_attributes |
|
| 4565 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 4566 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 4567 | - } |
|
| 4554 | + // get if advanced |
|
| 4555 | + if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 4556 | + $class .= " sd-advanced-setting "; |
|
| 4557 | + } |
|
| 4558 | + |
|
| 4559 | + // element_require |
|
| 4560 | + if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 4561 | + $element_require = $args['element_require']; |
|
| 4562 | + } |
|
| 4568 | 4563 | |
| 4569 | - // before wrapper |
|
| 4570 | - ?> |
|
| 4564 | + // custom_attributes |
|
| 4565 | + if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 4566 | + $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 4567 | + } |
|
| 4568 | + |
|
| 4569 | + // before wrapper |
|
| 4570 | + ?> |
|
| 4571 | 4571 | <p class="sd-argument <?php echo esc_attr( $class ); ?>" data-argument='<?php echo esc_attr( $args['name'] ); ?>' data-element_require='<?php if ( $element_require ) { echo $this->convert_element_require( $element_require );} ?>'> |
| 4572 | 4572 | <?php |
| 4573 | - switch ( $args['type'] ) { |
|
| 4574 | - //array('text','password','number','email','tel','url','color') |
|
| 4575 | - case "text": |
|
| 4576 | - case "password": |
|
| 4577 | - case "number": |
|
| 4578 | - case "email": |
|
| 4579 | - case "tel": |
|
| 4580 | - case "url": |
|
| 4581 | - case "color": |
|
| 4582 | - ?> |
|
| 4573 | + switch ( $args['type'] ) { |
|
| 4574 | + //array('text','password','number','email','tel','url','color') |
|
| 4575 | + case "text": |
|
| 4576 | + case "password": |
|
| 4577 | + case "number": |
|
| 4578 | + case "email": |
|
| 4579 | + case "tel": |
|
| 4580 | + case "url": |
|
| 4581 | + case "color": |
|
| 4582 | + ?> |
|
| 4583 | 4583 | <label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4584 | 4584 | <input <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="<?php echo esc_attr( $args['type'] ); ?>" value="<?php echo esc_attr( $value ); ?>"> |
| 4585 | 4585 | <?php |
| 4586 | 4586 | |
| 4587 | - break; |
|
| 4588 | - case "select": |
|
| 4589 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 4590 | - if ( $multiple ) { |
|
| 4591 | - if ( empty( $value ) ) { |
|
| 4592 | - $value = array(); |
|
| 4593 | - } |
|
| 4594 | - } |
|
| 4595 | - ?> |
|
| 4587 | + break; |
|
| 4588 | + case "select": |
|
| 4589 | + $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 4590 | + if ( $multiple ) { |
|
| 4591 | + if ( empty( $value ) ) { |
|
| 4592 | + $value = array(); |
|
| 4593 | + } |
|
| 4594 | + } |
|
| 4595 | + ?> |
|
| 4596 | 4596 | <label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4597 | 4597 | <select <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); if ( $multiple ) { echo "[]"; } ?>" |
| 4598 | 4598 | <?php if ( $multiple ) { |
| 4599 | - echo "multiple"; |
|
| 4600 | - } //@todo not implemented yet due to gutenberg not supporting it |
|
| 4601 | - ?>> |
|
| 4599 | + echo "multiple"; |
|
| 4600 | + } //@todo not implemented yet due to gutenberg not supporting it |
|
| 4601 | + ?>> |
|
| 4602 | 4602 | <?php |
| 4603 | 4603 | |
| 4604 | - if ( ! empty( $args['options'] ) ) { |
|
| 4605 | - foreach ( $args['options'] as $val => $label ) { |
|
| 4606 | - if ( $multiple ) { |
|
| 4607 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 4608 | - } else { |
|
| 4609 | - $selected = selected( $value, $val, false ); |
|
| 4610 | - } |
|
| 4611 | - echo "<option value='$val' " . $selected . ">$label</option>"; |
|
| 4612 | - } |
|
| 4613 | - } |
|
| 4614 | - ?> |
|
| 4604 | + if ( ! empty( $args['options'] ) ) { |
|
| 4605 | + foreach ( $args['options'] as $val => $label ) { |
|
| 4606 | + if ( $multiple ) { |
|
| 4607 | + $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 4608 | + } else { |
|
| 4609 | + $selected = selected( $value, $val, false ); |
|
| 4610 | + } |
|
| 4611 | + echo "<option value='$val' " . $selected . ">$label</option>"; |
|
| 4612 | + } |
|
| 4613 | + } |
|
| 4614 | + ?> |
|
| 4615 | 4615 | </select> |
| 4616 | 4616 | <?php |
| 4617 | - break; |
|
| 4618 | - case "checkbox": |
|
| 4619 | - ?> |
|
| 4617 | + break; |
|
| 4618 | + case "checkbox": |
|
| 4619 | + ?> |
|
| 4620 | 4620 | <input <?php echo $placeholder; ?> <?php checked( 1, $value, true ) ?> <?php echo $custom_attributes; ?> class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox" value="1"> |
| 4621 | 4621 | <label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4622 | 4622 | <?php |
| 4623 | - break; |
|
| 4624 | - case "textarea": |
|
| 4625 | - ?> |
|
| 4623 | + break; |
|
| 4624 | + case "textarea": |
|
| 4625 | + ?> |
|
| 4626 | 4626 | <label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4627 | 4627 | <textarea <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"><?php echo esc_attr( $value ); ?></textarea> |
| 4628 | 4628 | <?php |
| 4629 | 4629 | |
| 4630 | - break; |
|
| 4631 | - case "hidden": |
|
| 4632 | - ?> |
|
| 4630 | + break; |
|
| 4631 | + case "hidden": |
|
| 4632 | + ?> |
|
| 4633 | 4633 | <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" value="<?php echo esc_attr( $value ); ?>"> |
| 4634 | 4634 | <?php |
| 4635 | - break; |
|
| 4636 | - default: |
|
| 4637 | - echo "No input type found!"; // @todo we need to add more input types. |
|
| 4638 | - } |
|
| 4639 | - // after wrapper |
|
| 4640 | - ?></p><?php |
|
| 4641 | - } |
|
| 4635 | + break; |
|
| 4636 | + default: |
|
| 4637 | + echo "No input type found!"; // @todo we need to add more input types. |
|
| 4638 | + } |
|
| 4639 | + // after wrapper |
|
| 4640 | + ?></p><?php |
|
| 4641 | + } |
|
| 4642 | 4642 | |
| 4643 | - public function get_widget_icon($icon = 'box-top', $title = ''){ |
|
| 4644 | - if($icon=='box-top'){ |
|
| 4645 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
| 4646 | - }elseif($icon=='box-right'){ |
|
| 4647 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
| 4648 | - }elseif($icon=='box-bottom'){ |
|
| 4649 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
| 4650 | - }elseif($icon=='box-left'){ |
|
| 4651 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
| 4652 | - } |
|
| 4653 | - } |
|
| 4643 | + public function get_widget_icon($icon = 'box-top', $title = ''){ |
|
| 4644 | + if($icon=='box-top'){ |
|
| 4645 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
| 4646 | + }elseif($icon=='box-right'){ |
|
| 4647 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
| 4648 | + }elseif($icon=='box-bottom'){ |
|
| 4649 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
| 4650 | + }elseif($icon=='box-left'){ |
|
| 4651 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
| 4652 | + } |
|
| 4653 | + } |
|
| 4654 | 4654 | |
| 4655 | - /** |
|
| 4656 | - * Get the widget input description html. |
|
| 4657 | - * |
|
| 4658 | - * @param $args |
|
| 4659 | - * |
|
| 4660 | - * @return string |
|
| 4661 | - * @todo, need to make its own tooltip script |
|
| 4662 | - */ |
|
| 4663 | - public function widget_field_desc( $args ) { |
|
| 4664 | - |
|
| 4665 | - $description = ''; |
|
| 4666 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 4667 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 4668 | - $description = $this->desc_tip( $args['desc'] ); |
|
| 4669 | - } else { |
|
| 4670 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 4671 | - } |
|
| 4672 | - } |
|
| 4655 | + /** |
|
| 4656 | + * Get the widget input description html. |
|
| 4657 | + * |
|
| 4658 | + * @param $args |
|
| 4659 | + * |
|
| 4660 | + * @return string |
|
| 4661 | + * @todo, need to make its own tooltip script |
|
| 4662 | + */ |
|
| 4663 | + public function widget_field_desc( $args ) { |
|
| 4664 | + |
|
| 4665 | + $description = ''; |
|
| 4666 | + if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 4667 | + if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 4668 | + $description = $this->desc_tip( $args['desc'] ); |
|
| 4669 | + } else { |
|
| 4670 | + $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 4671 | + } |
|
| 4672 | + } |
|
| 4673 | 4673 | |
| 4674 | - return $description; |
|
| 4675 | - } |
|
| 4674 | + return $description; |
|
| 4675 | + } |
|
| 4676 | 4676 | |
| 4677 | - /** |
|
| 4678 | - * Get the widget input title html. |
|
| 4679 | - * |
|
| 4680 | - * @param $args |
|
| 4681 | - * |
|
| 4682 | - * @return string |
|
| 4683 | - */ |
|
| 4684 | - public function widget_field_title( $args ) { |
|
| 4685 | - $title = ''; |
|
| 4686 | - |
|
| 4687 | - if ( isset( $args['title'] ) && $args['title'] ) { |
|
| 4688 | - if ( ! empty( $args['device_type'] ) ) { |
|
| 4689 | - $args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title. |
|
| 4690 | - } |
|
| 4677 | + /** |
|
| 4678 | + * Get the widget input title html. |
|
| 4679 | + * |
|
| 4680 | + * @param $args |
|
| 4681 | + * |
|
| 4682 | + * @return string |
|
| 4683 | + */ |
|
| 4684 | + public function widget_field_title( $args ) { |
|
| 4685 | + $title = ''; |
|
| 4691 | 4686 | |
| 4692 | - if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
| 4693 | - $title = self::get_widget_icon( $args['icon'], $args['title'] ); |
|
| 4694 | - } else { |
|
| 4695 | - $title = esc_attr( $args['title'] ); |
|
| 4696 | - } |
|
| 4697 | - } |
|
| 4687 | + if ( isset( $args['title'] ) && $args['title'] ) { |
|
| 4688 | + if ( ! empty( $args['device_type'] ) ) { |
|
| 4689 | + $args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title. |
|
| 4690 | + } |
|
| 4698 | 4691 | |
| 4699 | - return $title; |
|
| 4700 | - } |
|
| 4692 | + if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
| 4693 | + $title = self::get_widget_icon( $args['icon'], $args['title'] ); |
|
| 4694 | + } else { |
|
| 4695 | + $title = esc_attr( $args['title'] ); |
|
| 4696 | + } |
|
| 4697 | + } |
|
| 4701 | 4698 | |
| 4702 | - /** |
|
| 4703 | - * Get the tool tip html. |
|
| 4704 | - * |
|
| 4705 | - * @param $tip |
|
| 4706 | - * @param bool $allow_html |
|
| 4707 | - * |
|
| 4708 | - * @return string |
|
| 4709 | - */ |
|
| 4710 | - function desc_tip( $tip, $allow_html = false ) { |
|
| 4711 | - if ( $allow_html ) { |
|
| 4712 | - $tip = $this->sanitize_tooltip( $tip ); |
|
| 4713 | - } else { |
|
| 4714 | - $tip = esc_attr( $tip ); |
|
| 4715 | - } |
|
| 4699 | + return $title; |
|
| 4700 | + } |
|
| 4716 | 4701 | |
| 4717 | - return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
| 4718 | - } |
|
| 4702 | + /** |
|
| 4703 | + * Get the tool tip html. |
|
| 4704 | + * |
|
| 4705 | + * @param $tip |
|
| 4706 | + * @param bool $allow_html |
|
| 4707 | + * |
|
| 4708 | + * @return string |
|
| 4709 | + */ |
|
| 4710 | + function desc_tip( $tip, $allow_html = false ) { |
|
| 4711 | + if ( $allow_html ) { |
|
| 4712 | + $tip = $this->sanitize_tooltip( $tip ); |
|
| 4713 | + } else { |
|
| 4714 | + $tip = esc_attr( $tip ); |
|
| 4715 | + } |
|
| 4719 | 4716 | |
| 4720 | - /** |
|
| 4721 | - * Sanitize a string destined to be a tooltip. |
|
| 4722 | - * |
|
| 4723 | - * @param string $var |
|
| 4724 | - * |
|
| 4725 | - * @return string |
|
| 4726 | - */ |
|
| 4727 | - public function sanitize_tooltip( $var ) { |
|
| 4728 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 4729 | - 'br' => array(), |
|
| 4730 | - 'em' => array(), |
|
| 4731 | - 'strong' => array(), |
|
| 4732 | - 'small' => array(), |
|
| 4733 | - 'span' => array(), |
|
| 4734 | - 'ul' => array(), |
|
| 4735 | - 'li' => array(), |
|
| 4736 | - 'ol' => array(), |
|
| 4737 | - 'p' => array(), |
|
| 4738 | - ) ) ); |
|
| 4739 | - } |
|
| 4717 | + return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
| 4718 | + } |
|
| 4740 | 4719 | |
| 4741 | - /** |
|
| 4742 | - * Processing widget options on save |
|
| 4743 | - * |
|
| 4744 | - * @param array $new_instance The new options |
|
| 4745 | - * @param array $old_instance The previous options |
|
| 4746 | - * |
|
| 4747 | - * @return array |
|
| 4748 | - * @todo we should add some sanitation here. |
|
| 4749 | - */ |
|
| 4750 | - public function update( $new_instance, $old_instance ) { |
|
| 4751 | - |
|
| 4752 | - //save the widget |
|
| 4753 | - $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 4754 | - |
|
| 4755 | - // set widget instance |
|
| 4756 | - $this->instance = $instance; |
|
| 4757 | - |
|
| 4758 | - if ( empty( $this->arguments ) ) { |
|
| 4759 | - $this->get_arguments(); |
|
| 4760 | - } |
|
| 4720 | + /** |
|
| 4721 | + * Sanitize a string destined to be a tooltip. |
|
| 4722 | + * |
|
| 4723 | + * @param string $var |
|
| 4724 | + * |
|
| 4725 | + * @return string |
|
| 4726 | + */ |
|
| 4727 | + public function sanitize_tooltip( $var ) { |
|
| 4728 | + return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 4729 | + 'br' => array(), |
|
| 4730 | + 'em' => array(), |
|
| 4731 | + 'strong' => array(), |
|
| 4732 | + 'small' => array(), |
|
| 4733 | + 'span' => array(), |
|
| 4734 | + 'ul' => array(), |
|
| 4735 | + 'li' => array(), |
|
| 4736 | + 'ol' => array(), |
|
| 4737 | + 'p' => array(), |
|
| 4738 | + ) ) ); |
|
| 4739 | + } |
|
| 4761 | 4740 | |
| 4762 | - // check for checkboxes |
|
| 4763 | - if ( ! empty( $this->arguments ) ) { |
|
| 4764 | - foreach ( $this->arguments as $argument ) { |
|
| 4765 | - if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 4766 | - $instance[ $argument['name'] ] = '0'; |
|
| 4767 | - } |
|
| 4768 | - } |
|
| 4769 | - } |
|
| 4741 | + /** |
|
| 4742 | + * Processing widget options on save |
|
| 4743 | + * |
|
| 4744 | + * @param array $new_instance The new options |
|
| 4745 | + * @param array $old_instance The previous options |
|
| 4746 | + * |
|
| 4747 | + * @return array |
|
| 4748 | + * @todo we should add some sanitation here. |
|
| 4749 | + */ |
|
| 4750 | + public function update( $new_instance, $old_instance ) { |
|
| 4770 | 4751 | |
| 4771 | - return $instance; |
|
| 4772 | - } |
|
| 4752 | + //save the widget |
|
| 4753 | + $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 4773 | 4754 | |
| 4774 | - /** |
|
| 4775 | - * Checks if the current call is a ajax call to get the block content. |
|
| 4776 | - * |
|
| 4777 | - * This can be used in your widget to return different content as the block content. |
|
| 4778 | - * |
|
| 4779 | - * @return bool |
|
| 4780 | - *@since 1.0.3 |
|
| 4781 | - */ |
|
| 4782 | - public function is_block_content_call() { |
|
| 4783 | - $result = false; |
|
| 4784 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 4785 | - $result = true; |
|
| 4786 | - } |
|
| 4755 | + // set widget instance |
|
| 4756 | + $this->instance = $instance; |
|
| 4787 | 4757 | |
| 4788 | - return $result; |
|
| 4789 | - } |
|
| 4758 | + if ( empty( $this->arguments ) ) { |
|
| 4759 | + $this->get_arguments(); |
|
| 4760 | + } |
|
| 4790 | 4761 | |
| 4791 | - /** |
|
| 4792 | - * Get an instance hash that will be unique to the type and settings. |
|
| 4793 | - * |
|
| 4794 | - * @return string |
|
| 4795 | - *@since 1.0.20 |
|
| 4796 | - */ |
|
| 4797 | - public function get_instance_hash(){ |
|
| 4798 | - $instance_string = $this->base_id.serialize($this->instance); |
|
| 4799 | - return hash('crc32b',$instance_string); |
|
| 4800 | - } |
|
| 4762 | + // check for checkboxes |
|
| 4763 | + if ( ! empty( $this->arguments ) ) { |
|
| 4764 | + foreach ( $this->arguments as $argument ) { |
|
| 4765 | + if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 4766 | + $instance[ $argument['name'] ] = '0'; |
|
| 4767 | + } |
|
| 4768 | + } |
|
| 4769 | + } |
|
| 4801 | 4770 | |
| 4802 | - /** |
|
| 4803 | - * Generate and return inline styles from CSS rules that will match the unique class of the instance. |
|
| 4804 | - * |
|
| 4805 | - * @param array $rules |
|
| 4806 | - * |
|
| 4807 | - * @return string |
|
| 4808 | - *@since 1.0.20 |
|
| 4809 | - */ |
|
| 4810 | - public function get_instance_style($rules = array()){ |
|
| 4811 | - $css = ''; |
|
| 4812 | - |
|
| 4813 | - if(!empty($rules)){ |
|
| 4814 | - $rules = array_unique($rules); |
|
| 4815 | - $instance_hash = $this->get_instance_hash(); |
|
| 4816 | - $css .= "<style>"; |
|
| 4817 | - foreach($rules as $rule){ |
|
| 4818 | - $css .= ".sdel-$instance_hash $rule"; |
|
| 4819 | - } |
|
| 4820 | - $css .= "</style>"; |
|
| 4821 | - } |
|
| 4771 | + return $instance; |
|
| 4772 | + } |
|
| 4822 | 4773 | |
| 4823 | - return $css; |
|
| 4824 | - } |
|
| 4774 | + /** |
|
| 4775 | + * Checks if the current call is a ajax call to get the block content. |
|
| 4776 | + * |
|
| 4777 | + * This can be used in your widget to return different content as the block content. |
|
| 4778 | + * |
|
| 4779 | + * @return bool |
|
| 4780 | + *@since 1.0.3 |
|
| 4781 | + */ |
|
| 4782 | + public function is_block_content_call() { |
|
| 4783 | + $result = false; |
|
| 4784 | + if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 4785 | + $result = true; |
|
| 4786 | + } |
|
| 4825 | 4787 | |
| 4826 | - /** |
|
| 4827 | - * Encode shortcodes tags. |
|
| 4828 | - * |
|
| 4829 | - * @param string $content Content to search for shortcode tags. |
|
| 4830 | - * |
|
| 4788 | + return $result; |
|
| 4789 | + } |
|
| 4790 | + |
|
| 4791 | + /** |
|
| 4792 | + * Get an instance hash that will be unique to the type and settings. |
|
| 4793 | + * |
|
| 4794 | + * @return string |
|
| 4795 | + *@since 1.0.20 |
|
| 4796 | + */ |
|
| 4797 | + public function get_instance_hash(){ |
|
| 4798 | + $instance_string = $this->base_id.serialize($this->instance); |
|
| 4799 | + return hash('crc32b',$instance_string); |
|
| 4800 | + } |
|
| 4801 | + |
|
| 4802 | + /** |
|
| 4803 | + * Generate and return inline styles from CSS rules that will match the unique class of the instance. |
|
| 4804 | + * |
|
| 4805 | + * @param array $rules |
|
| 4806 | + * |
|
| 4807 | + * @return string |
|
| 4808 | + *@since 1.0.20 |
|
| 4809 | + */ |
|
| 4810 | + public function get_instance_style($rules = array()){ |
|
| 4811 | + $css = ''; |
|
| 4812 | + |
|
| 4813 | + if(!empty($rules)){ |
|
| 4814 | + $rules = array_unique($rules); |
|
| 4815 | + $instance_hash = $this->get_instance_hash(); |
|
| 4816 | + $css .= "<style>"; |
|
| 4817 | + foreach($rules as $rule){ |
|
| 4818 | + $css .= ".sdel-$instance_hash $rule"; |
|
| 4819 | + } |
|
| 4820 | + $css .= "</style>"; |
|
| 4821 | + } |
|
| 4822 | + |
|
| 4823 | + return $css; |
|
| 4824 | + } |
|
| 4825 | + |
|
| 4826 | + /** |
|
| 4827 | + * Encode shortcodes tags. |
|
| 4828 | + * |
|
| 4829 | + * @param string $content Content to search for shortcode tags. |
|
| 4830 | + * |
|
| 4831 | 4831 | *@return string Content with shortcode tags removed. |
| 4832 | - *@since 1.0.28 |
|
| 4833 | - * |
|
| 4834 | - */ |
|
| 4835 | - public function encode_shortcodes( $content ) { |
|
| 4836 | - // Avoids existing encoded tags. |
|
| 4837 | - $trans = array( |
|
| 4838 | - '[' => '[', |
|
| 4839 | - ']' => ']', |
|
| 4840 | - '&#91;' => '[', |
|
| 4841 | - '&#93;' => ']', |
|
| 4842 | - '<' => '&0lt;', |
|
| 4843 | - '>' => '&0gt;', |
|
| 4844 | - '&lt;' => '&0lt;', |
|
| 4845 | - '&gt;' => '&0gt;', |
|
| 4846 | - ); |
|
| 4847 | - |
|
| 4848 | - $content = strtr( $content, $trans ); |
|
| 4849 | - |
|
| 4850 | - $trans = array( |
|
| 4851 | - '[' => '[', |
|
| 4852 | - ']' => ']', |
|
| 4853 | - '<' => '<', |
|
| 4854 | - '>' => '>', |
|
| 4855 | - '"' => '"', |
|
| 4856 | - "'" => ''', |
|
| 4857 | - ); |
|
| 4858 | - |
|
| 4859 | - $content = strtr( $content, $trans ); |
|
| 4860 | - |
|
| 4861 | - return $content; |
|
| 4862 | - } |
|
| 4832 | + *@since 1.0.28 |
|
| 4833 | + * |
|
| 4834 | + */ |
|
| 4835 | + public function encode_shortcodes( $content ) { |
|
| 4836 | + // Avoids existing encoded tags. |
|
| 4837 | + $trans = array( |
|
| 4838 | + '[' => '[', |
|
| 4839 | + ']' => ']', |
|
| 4840 | + '&#91;' => '[', |
|
| 4841 | + '&#93;' => ']', |
|
| 4842 | + '<' => '&0lt;', |
|
| 4843 | + '>' => '&0gt;', |
|
| 4844 | + '&lt;' => '&0lt;', |
|
| 4845 | + '&gt;' => '&0gt;', |
|
| 4846 | + ); |
|
| 4847 | + |
|
| 4848 | + $content = strtr( $content, $trans ); |
|
| 4849 | + |
|
| 4850 | + $trans = array( |
|
| 4851 | + '[' => '[', |
|
| 4852 | + ']' => ']', |
|
| 4853 | + '<' => '<', |
|
| 4854 | + '>' => '>', |
|
| 4855 | + '"' => '"', |
|
| 4856 | + "'" => ''', |
|
| 4857 | + ); |
|
| 4858 | + |
|
| 4859 | + $content = strtr( $content, $trans ); |
|
| 4860 | + |
|
| 4861 | + return $content; |
|
| 4862 | + } |
|
| 4863 | 4863 | |
| 4864 | - /** |
|
| 4865 | - * Remove encoded shortcod tags. |
|
| 4866 | - * |
|
| 4867 | - * @param string $content Content to search for shortcode tags. |
|
| 4868 | - * |
|
| 4864 | + /** |
|
| 4865 | + * Remove encoded shortcod tags. |
|
| 4866 | + * |
|
| 4867 | + * @param string $content Content to search for shortcode tags. |
|
| 4868 | + * |
|
| 4869 | 4869 | *@return string Content with decoded shortcode tags. |
| 4870 | - *@since 1.0.28 |
|
| 4871 | - * |
|
| 4872 | - */ |
|
| 4873 | - public function decode_shortcodes( $content ) { |
|
| 4874 | - $trans = array( |
|
| 4875 | - '[' => '[', |
|
| 4876 | - ']' => ']', |
|
| 4877 | - '&#91;' => '[', |
|
| 4878 | - '&#93;' => ']', |
|
| 4879 | - '<' => '<', |
|
| 4880 | - '>' => '>', |
|
| 4881 | - '&lt;' => '<', |
|
| 4882 | - '&gt;' => '>', |
|
| 4883 | - '"' => '"', |
|
| 4884 | - ''' => "'", |
|
| 4885 | - ); |
|
| 4886 | - |
|
| 4887 | - $content = strtr( $content, $trans ); |
|
| 4888 | - |
|
| 4889 | - $trans = array( |
|
| 4890 | - '[' => '[', |
|
| 4891 | - ']' => ']', |
|
| 4892 | - '&#091;' => '[', |
|
| 4893 | - '&#093;' => ']', |
|
| 4894 | - '&0lt;' => '<', |
|
| 4895 | - '&0gt;' => '>', |
|
| 4896 | - '&0lt;' => '<', |
|
| 4897 | - '&0gt;' => '>', |
|
| 4898 | - ); |
|
| 4899 | - |
|
| 4900 | - $content = strtr( $content, $trans ); |
|
| 4901 | - |
|
| 4902 | - return $content; |
|
| 4903 | - } |
|
| 4904 | - |
|
| 4905 | - public function block_visibility_fields( $args ) { |
|
| 4906 | - $value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : ''; |
|
| 4907 | - $content = '<div class="bs-vc-rule-template d-none">'; |
|
| 4908 | - $content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >'; |
|
| 4909 | - $content .= '<div class="row">'; |
|
| 4910 | - $content .= '<div class="col-sm-12">'; |
|
| 4911 | - $content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__( 'Remove Rule', 'ayecode-connect' ) . '"><i class="fas fa-circle-minus fs-6"></i></span></div>'; |
|
| 4912 | - $content .= aui()->select( |
|
| 4913 | - array( |
|
| 4914 | - 'id' => 'bsvc_rule_BSVCINDEX', |
|
| 4915 | - 'name' => 'bsvc_rule_BSVCINDEX', |
|
| 4916 | - 'label' => __( 'Rule', 'ayecode-connect' ), |
|
| 4917 | - 'placeholder' => __( 'Select Rule...', 'ayecode-connect' ), |
|
| 4918 | - 'class' => 'bsvc_rule form-select-sm no-select2', |
|
| 4919 | - 'options' => sd_visibility_rules_options(), |
|
| 4920 | - 'default' => '', |
|
| 4921 | - 'value' => '', |
|
| 4922 | - 'label_type' => '', |
|
| 4923 | - 'select2' => false, |
|
| 4924 | - 'input_group_left' => __( 'Rule:', 'ayecode-connect' ), |
|
| 4925 | - 'extra_attributes' => array( |
|
| 4926 | - 'data-minimum-results-for-search' => '-1' |
|
| 4927 | - ) |
|
| 4928 | - ) |
|
| 4929 | - ); |
|
| 4930 | - |
|
| 4931 | - $content .= '</div>'; |
|
| 4932 | - |
|
| 4933 | - if ( class_exists( 'GeoDirectory' ) ) { |
|
| 4934 | - $content .= '<div class="col-md-7 col-sm-12">'; |
|
| 4935 | - |
|
| 4936 | - $content .= aui()->select( |
|
| 4937 | - array( |
|
| 4938 | - 'id' => 'bsvc_gd_field_BSVCINDEX', |
|
| 4939 | - 'name' => 'bsvc_gd_field_BSVCINDEX', |
|
| 4940 | - 'label' => __( 'FIELD', 'ayecode-connect' ), |
|
| 4941 | - 'placeholder' => __( 'FIELD', 'ayecode-connect' ), |
|
| 4942 | - 'class' => 'bsvc_gd_field form-select-sm no-select2', |
|
| 4943 | - 'options' => sd_visibility_gd_field_options(), |
|
| 4944 | - 'default' => '', |
|
| 4945 | - 'value' => '', |
|
| 4946 | - 'label_type' => '', |
|
| 4947 | - 'select2' => false, |
|
| 4948 | - 'element_require' => '[%bsvc_rule_BSVCINDEX%]=="gd_field"', |
|
| 4949 | - 'extra_attributes' => array( |
|
| 4950 | - 'data-minimum-results-for-search' => '-1' |
|
| 4951 | - ) |
|
| 4952 | - ) |
|
| 4953 | - ); |
|
| 4954 | - |
|
| 4955 | - $content .= '</div>'; |
|
| 4956 | - $content .= '<div class="col-md-5 col-sm-12">'; |
|
| 4957 | - |
|
| 4958 | - $content .= aui()->select( |
|
| 4959 | - array( |
|
| 4960 | - 'id' => 'bsvc_gd_field_condition_BSVCINDEX', |
|
| 4961 | - 'name' => 'bsvc_gd_field_condition_BSVCINDEX', |
|
| 4962 | - 'label' => __( 'CONDITION', 'ayecode-connect' ), |
|
| 4963 | - 'placeholder' => __( 'CONDITION', 'ayecode-connect' ), |
|
| 4964 | - 'class' => 'bsvc_gd_field_condition form-select-sm no-select2', |
|
| 4965 | - 'options' => sd_visibility_field_condition_options(), |
|
| 4966 | - 'default' => '', |
|
| 4967 | - 'value' => '', |
|
| 4968 | - 'label_type' => '', |
|
| 4969 | - 'select2' => false, |
|
| 4970 | - 'element_require' => '[%bsvc_rule_BSVCINDEX%]=="gd_field"', |
|
| 4971 | - 'extra_attributes' => array( |
|
| 4972 | - 'data-minimum-results-for-search' => '-1' |
|
| 4973 | - ) |
|
| 4974 | - ) |
|
| 4975 | - ); |
|
| 4976 | - |
|
| 4977 | - $content .= '</div>'; |
|
| 4978 | - $content .= '<div class="col-sm-12">'; |
|
| 4979 | - |
|
| 4980 | - $content .= aui()->input( |
|
| 4981 | - array( |
|
| 4982 | - 'type' => 'text', |
|
| 4983 | - 'id' => 'bsvc_gd_field_search_BSVCINDEX', |
|
| 4984 | - 'name' => 'bsvc_gd_field_search_BSVCINDEX', |
|
| 4985 | - 'label' => __( 'VALUE TO MATCH', 'ayecode-connect' ), |
|
| 4986 | - 'class' => 'bsvc_gd_field_search form-control-sm', |
|
| 4987 | - 'placeholder' => __( 'VALUE TO MATCH', 'ayecode-connect' ), |
|
| 4988 | - 'label_type' => '', |
|
| 4989 | - 'value' => '', |
|
| 4990 | - 'element_require' => '([%bsvc_rule_BSVCINDEX%]=="gd_field" && [%bsvc_gd_field_condition_BSVCINDEX%] && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_empty" && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_not_empty")' |
|
| 4991 | - ) |
|
| 4992 | - ); |
|
| 4870 | + *@since 1.0.28 |
|
| 4871 | + * |
|
| 4872 | + */ |
|
| 4873 | + public function decode_shortcodes( $content ) { |
|
| 4874 | + $trans = array( |
|
| 4875 | + '[' => '[', |
|
| 4876 | + ']' => ']', |
|
| 4877 | + '&#91;' => '[', |
|
| 4878 | + '&#93;' => ']', |
|
| 4879 | + '<' => '<', |
|
| 4880 | + '>' => '>', |
|
| 4881 | + '&lt;' => '<', |
|
| 4882 | + '&gt;' => '>', |
|
| 4883 | + '"' => '"', |
|
| 4884 | + ''' => "'", |
|
| 4885 | + ); |
|
| 4886 | + |
|
| 4887 | + $content = strtr( $content, $trans ); |
|
| 4888 | + |
|
| 4889 | + $trans = array( |
|
| 4890 | + '[' => '[', |
|
| 4891 | + ']' => ']', |
|
| 4892 | + '&#091;' => '[', |
|
| 4893 | + '&#093;' => ']', |
|
| 4894 | + '&0lt;' => '<', |
|
| 4895 | + '&0gt;' => '>', |
|
| 4896 | + '&0lt;' => '<', |
|
| 4897 | + '&0gt;' => '>', |
|
| 4898 | + ); |
|
| 4899 | + |
|
| 4900 | + $content = strtr( $content, $trans ); |
|
| 4901 | + |
|
| 4902 | + return $content; |
|
| 4903 | + } |
|
| 4993 | 4904 | |
| 4994 | - $content .= '</div>'; |
|
| 4995 | - } |
|
| 4905 | + public function block_visibility_fields( $args ) { |
|
| 4906 | + $value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : ''; |
|
| 4907 | + $content = '<div class="bs-vc-rule-template d-none">'; |
|
| 4908 | + $content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >'; |
|
| 4909 | + $content .= '<div class="row">'; |
|
| 4910 | + $content .= '<div class="col-sm-12">'; |
|
| 4911 | + $content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__( 'Remove Rule', 'ayecode-connect' ) . '"><i class="fas fa-circle-minus fs-6"></i></span></div>'; |
|
| 4912 | + $content .= aui()->select( |
|
| 4913 | + array( |
|
| 4914 | + 'id' => 'bsvc_rule_BSVCINDEX', |
|
| 4915 | + 'name' => 'bsvc_rule_BSVCINDEX', |
|
| 4916 | + 'label' => __( 'Rule', 'ayecode-connect' ), |
|
| 4917 | + 'placeholder' => __( 'Select Rule...', 'ayecode-connect' ), |
|
| 4918 | + 'class' => 'bsvc_rule form-select-sm no-select2', |
|
| 4919 | + 'options' => sd_visibility_rules_options(), |
|
| 4920 | + 'default' => '', |
|
| 4921 | + 'value' => '', |
|
| 4922 | + 'label_type' => '', |
|
| 4923 | + 'select2' => false, |
|
| 4924 | + 'input_group_left' => __( 'Rule:', 'ayecode-connect' ), |
|
| 4925 | + 'extra_attributes' => array( |
|
| 4926 | + 'data-minimum-results-for-search' => '-1' |
|
| 4927 | + ) |
|
| 4928 | + ) |
|
| 4929 | + ); |
|
| 4930 | + |
|
| 4931 | + $content .= '</div>'; |
|
| 4932 | + |
|
| 4933 | + if ( class_exists( 'GeoDirectory' ) ) { |
|
| 4934 | + $content .= '<div class="col-md-7 col-sm-12">'; |
|
| 4935 | + |
|
| 4936 | + $content .= aui()->select( |
|
| 4937 | + array( |
|
| 4938 | + 'id' => 'bsvc_gd_field_BSVCINDEX', |
|
| 4939 | + 'name' => 'bsvc_gd_field_BSVCINDEX', |
|
| 4940 | + 'label' => __( 'FIELD', 'ayecode-connect' ), |
|
| 4941 | + 'placeholder' => __( 'FIELD', 'ayecode-connect' ), |
|
| 4942 | + 'class' => 'bsvc_gd_field form-select-sm no-select2', |
|
| 4943 | + 'options' => sd_visibility_gd_field_options(), |
|
| 4944 | + 'default' => '', |
|
| 4945 | + 'value' => '', |
|
| 4946 | + 'label_type' => '', |
|
| 4947 | + 'select2' => false, |
|
| 4948 | + 'element_require' => '[%bsvc_rule_BSVCINDEX%]=="gd_field"', |
|
| 4949 | + 'extra_attributes' => array( |
|
| 4950 | + 'data-minimum-results-for-search' => '-1' |
|
| 4951 | + ) |
|
| 4952 | + ) |
|
| 4953 | + ); |
|
| 4954 | + |
|
| 4955 | + $content .= '</div>'; |
|
| 4956 | + $content .= '<div class="col-md-5 col-sm-12">'; |
|
| 4957 | + |
|
| 4958 | + $content .= aui()->select( |
|
| 4959 | + array( |
|
| 4960 | + 'id' => 'bsvc_gd_field_condition_BSVCINDEX', |
|
| 4961 | + 'name' => 'bsvc_gd_field_condition_BSVCINDEX', |
|
| 4962 | + 'label' => __( 'CONDITION', 'ayecode-connect' ), |
|
| 4963 | + 'placeholder' => __( 'CONDITION', 'ayecode-connect' ), |
|
| 4964 | + 'class' => 'bsvc_gd_field_condition form-select-sm no-select2', |
|
| 4965 | + 'options' => sd_visibility_field_condition_options(), |
|
| 4966 | + 'default' => '', |
|
| 4967 | + 'value' => '', |
|
| 4968 | + 'label_type' => '', |
|
| 4969 | + 'select2' => false, |
|
| 4970 | + 'element_require' => '[%bsvc_rule_BSVCINDEX%]=="gd_field"', |
|
| 4971 | + 'extra_attributes' => array( |
|
| 4972 | + 'data-minimum-results-for-search' => '-1' |
|
| 4973 | + ) |
|
| 4974 | + ) |
|
| 4975 | + ); |
|
| 4976 | + |
|
| 4977 | + $content .= '</div>'; |
|
| 4978 | + $content .= '<div class="col-sm-12">'; |
|
| 4979 | + |
|
| 4980 | + $content .= aui()->input( |
|
| 4981 | + array( |
|
| 4982 | + 'type' => 'text', |
|
| 4983 | + 'id' => 'bsvc_gd_field_search_BSVCINDEX', |
|
| 4984 | + 'name' => 'bsvc_gd_field_search_BSVCINDEX', |
|
| 4985 | + 'label' => __( 'VALUE TO MATCH', 'ayecode-connect' ), |
|
| 4986 | + 'class' => 'bsvc_gd_field_search form-control-sm', |
|
| 4987 | + 'placeholder' => __( 'VALUE TO MATCH', 'ayecode-connect' ), |
|
| 4988 | + 'label_type' => '', |
|
| 4989 | + 'value' => '', |
|
| 4990 | + 'element_require' => '([%bsvc_rule_BSVCINDEX%]=="gd_field" && [%bsvc_gd_field_condition_BSVCINDEX%] && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_empty" && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_not_empty")' |
|
| 4991 | + ) |
|
| 4992 | + ); |
|
| 4993 | + |
|
| 4994 | + $content .= '</div>'; |
|
| 4995 | + } |
|
| 4996 | 4996 | |
| 4997 | - $content .= '</div>'; |
|
| 4998 | - |
|
| 4999 | - $content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __( 'Select User Roles:', 'ayecode-connect' ) . '</label>'; |
|
| 5000 | - $role_options = sd_user_roles_options(); |
|
| 5001 | - |
|
| 5002 | - $role_option_i = 0; |
|
| 5003 | - foreach ( $role_options as $role_option_key => $role_option_name ) { |
|
| 5004 | - $role_option_i++; |
|
| 5005 | - |
|
| 5006 | - $content .= '<div class="col-sm-6">'; |
|
| 5007 | - $content .= aui()->input( |
|
| 5008 | - array( |
|
| 5009 | - 'id' => 'bsvc_user_roles_BSVCINDEX_' . $role_option_i, |
|
| 5010 | - 'name' => 'bsvc_user_roles_BSVCINDEX[]', |
|
| 5011 | - 'type' => 'checkbox', |
|
| 5012 | - 'label' => $role_option_name, |
|
| 5013 | - 'label_type' => 'hidden', |
|
| 5014 | - 'class' => 'bsvc_user_roles', |
|
| 5015 | - 'value' => $role_option_key, |
|
| 5016 | - 'switch' => 'md', |
|
| 5017 | - 'no_wrap' => true |
|
| 5018 | - ) |
|
| 5019 | - ); |
|
| 5020 | - $content .= '</div>'; |
|
| 5021 | - } |
|
| 5022 | - $content .= '</div>'; |
|
| 5023 | - $content .= '</div>'; |
|
| 5024 | - $content .= '</div>'; |
|
| 5025 | - $content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">'; |
|
| 5026 | - $content .= '<div class="bs-vc-rule-sets"></div>'; |
|
| 5027 | - $content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __( 'Add Rule', 'ayecode-connect' ) . '</button></div></div>'; |
|
| 5028 | - $content .= '<div class="row"><div class="col-md-6 col-sm-12">'; |
|
| 5029 | - $content .= aui()->select( |
|
| 5030 | - array( |
|
| 5031 | - 'id' => 'bsvc_output', |
|
| 5032 | - 'name' => 'bsvc_output', |
|
| 5033 | - 'label' => __( 'What should happen if rules met.', 'ayecode-connect' ), |
|
| 5034 | - 'placeholder' => __( 'Default Output', 'ayecode-connect' ), |
|
| 5035 | - 'class' => 'bsvc_output form-select-sm no-select2', |
|
| 5036 | - 'options' => sd_visibility_output_options(), |
|
| 5037 | - 'default' => '', |
|
| 5038 | - 'value' => '', |
|
| 5039 | - 'label_type' => 'top', |
|
| 5040 | - 'select2' => false, |
|
| 5041 | - 'extra_attributes' => array( |
|
| 5042 | - 'data-minimum-results-for-search' => '-1' |
|
| 5043 | - ) |
|
| 5044 | - ) |
|
| 5045 | - ); |
|
| 5046 | - |
|
| 5047 | - $content .= '</div><div class="col-md-6 col-sm-12">'; |
|
| 5048 | - |
|
| 5049 | - $content .= aui()->select( |
|
| 5050 | - array( |
|
| 5051 | - 'id' => 'bsvc_page', |
|
| 5052 | - 'name' => 'bsvc_page', |
|
| 5053 | - 'label' => __( 'Page Content', 'ayecode-connect' ), |
|
| 5054 | - 'placeholder' => __( 'Select Page ID...', 'ayecode-connect' ), |
|
| 5055 | - 'class' => 'bsvc_page form-select-sm no-select2', |
|
| 5056 | - 'options' => sd_template_page_options(), |
|
| 5057 | - 'default' => '', |
|
| 5058 | - 'value' => '', |
|
| 5059 | - 'label_type' => 'top', |
|
| 5060 | - 'select2' => false, |
|
| 5061 | - 'element_require' => '[%bsvc_output%]=="page"' |
|
| 5062 | - ) |
|
| 5063 | - ); |
|
| 5064 | - |
|
| 5065 | - $content .= aui()->select( |
|
| 5066 | - array( |
|
| 5067 | - 'id' => 'bsvc_tmpl_part', |
|
| 5068 | - 'name' => 'bsvc_tmpl_part', |
|
| 5069 | - 'label' => __( 'Template Part', 'ayecode-connect' ), |
|
| 5070 | - 'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ), |
|
| 5071 | - 'class' => 'bsvc_tmpl_part form-select-sm no-select2', |
|
| 5072 | - 'options' => sd_template_part_options(), |
|
| 5073 | - 'default' => '', |
|
| 5074 | - 'value' => '', |
|
| 5075 | - 'label_type' => 'top', |
|
| 5076 | - 'select2' => false, |
|
| 5077 | - 'element_require' => '[%bsvc_output%]=="template_part"', |
|
| 5078 | - 'extra_attributes' => array( |
|
| 5079 | - 'data-minimum-results-for-search' => '-1' |
|
| 5080 | - ) |
|
| 5081 | - ) |
|
| 5082 | - ); |
|
| 5083 | - |
|
| 5084 | - $content .= aui()->select( |
|
| 5085 | - array( |
|
| 5086 | - 'id' => 'bsvc_message_type', |
|
| 5087 | - 'name' => 'bsvc_message_type', |
|
| 5088 | - 'label' => __( 'Custom Message Type', 'ayecode-connect' ), |
|
| 5089 | - 'placeholder' => __( 'Default (none)', 'ayecode-connect' ), |
|
| 5090 | - 'class' => 'bsvc_message_type form-select-sm no-select2', |
|
| 5091 | - 'options' => sd_aui_colors(), |
|
| 5092 | - 'default' => '', |
|
| 5093 | - 'value' => '', |
|
| 5094 | - 'label_type' => 'top', |
|
| 5095 | - 'select2' => false, |
|
| 5096 | - 'element_require' => '[%bsvc_output%]=="message"', |
|
| 5097 | - 'extra_attributes' => array( |
|
| 5098 | - 'data-minimum-results-for-search' => '-1' |
|
| 5099 | - ) |
|
| 5100 | - ) |
|
| 5101 | - ); |
|
| 5102 | - |
|
| 5103 | - $content .= '</div><div class="col-sm-12">'; |
|
| 5104 | - |
|
| 5105 | - $content .= aui()->input( |
|
| 5106 | - array( |
|
| 5107 | - 'type' => 'text', |
|
| 5108 | - 'id' => 'bsvc_message', |
|
| 5109 | - 'name' => 'bsvc_message', |
|
| 5110 | - 'label' => '', |
|
| 5111 | - 'class' => 'bsvc_message form-control-sm', |
|
| 5112 | - 'placeholder' => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ), |
|
| 5113 | - 'label_type' => '', |
|
| 5114 | - 'value' => '', |
|
| 5115 | - 'form_group_class' => ' ', |
|
| 5116 | - 'element_require' => '[%bsvc_output%]=="message"', |
|
| 5117 | - ) |
|
| 5118 | - ); |
|
| 5119 | - |
|
| 5120 | - $content .= '</div></div></form><input type="hidden" id="bsvc_raw_value" name="bsvc_raw_value" value="' . $value . '">'; |
|
| 5121 | - |
|
| 5122 | - return $content; |
|
| 5123 | - } |
|
| 5124 | - } |
|
| 4997 | + $content .= '</div>'; |
|
| 4998 | + |
|
| 4999 | + $content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __( 'Select User Roles:', 'ayecode-connect' ) . '</label>'; |
|
| 5000 | + $role_options = sd_user_roles_options(); |
|
| 5001 | + |
|
| 5002 | + $role_option_i = 0; |
|
| 5003 | + foreach ( $role_options as $role_option_key => $role_option_name ) { |
|
| 5004 | + $role_option_i++; |
|
| 5005 | + |
|
| 5006 | + $content .= '<div class="col-sm-6">'; |
|
| 5007 | + $content .= aui()->input( |
|
| 5008 | + array( |
|
| 5009 | + 'id' => 'bsvc_user_roles_BSVCINDEX_' . $role_option_i, |
|
| 5010 | + 'name' => 'bsvc_user_roles_BSVCINDEX[]', |
|
| 5011 | + 'type' => 'checkbox', |
|
| 5012 | + 'label' => $role_option_name, |
|
| 5013 | + 'label_type' => 'hidden', |
|
| 5014 | + 'class' => 'bsvc_user_roles', |
|
| 5015 | + 'value' => $role_option_key, |
|
| 5016 | + 'switch' => 'md', |
|
| 5017 | + 'no_wrap' => true |
|
| 5018 | + ) |
|
| 5019 | + ); |
|
| 5020 | + $content .= '</div>'; |
|
| 5021 | + } |
|
| 5022 | + $content .= '</div>'; |
|
| 5023 | + $content .= '</div>'; |
|
| 5024 | + $content .= '</div>'; |
|
| 5025 | + $content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">'; |
|
| 5026 | + $content .= '<div class="bs-vc-rule-sets"></div>'; |
|
| 5027 | + $content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __( 'Add Rule', 'ayecode-connect' ) . '</button></div></div>'; |
|
| 5028 | + $content .= '<div class="row"><div class="col-md-6 col-sm-12">'; |
|
| 5029 | + $content .= aui()->select( |
|
| 5030 | + array( |
|
| 5031 | + 'id' => 'bsvc_output', |
|
| 5032 | + 'name' => 'bsvc_output', |
|
| 5033 | + 'label' => __( 'What should happen if rules met.', 'ayecode-connect' ), |
|
| 5034 | + 'placeholder' => __( 'Default Output', 'ayecode-connect' ), |
|
| 5035 | + 'class' => 'bsvc_output form-select-sm no-select2', |
|
| 5036 | + 'options' => sd_visibility_output_options(), |
|
| 5037 | + 'default' => '', |
|
| 5038 | + 'value' => '', |
|
| 5039 | + 'label_type' => 'top', |
|
| 5040 | + 'select2' => false, |
|
| 5041 | + 'extra_attributes' => array( |
|
| 5042 | + 'data-minimum-results-for-search' => '-1' |
|
| 5043 | + ) |
|
| 5044 | + ) |
|
| 5045 | + ); |
|
| 5046 | + |
|
| 5047 | + $content .= '</div><div class="col-md-6 col-sm-12">'; |
|
| 5048 | + |
|
| 5049 | + $content .= aui()->select( |
|
| 5050 | + array( |
|
| 5051 | + 'id' => 'bsvc_page', |
|
| 5052 | + 'name' => 'bsvc_page', |
|
| 5053 | + 'label' => __( 'Page Content', 'ayecode-connect' ), |
|
| 5054 | + 'placeholder' => __( 'Select Page ID...', 'ayecode-connect' ), |
|
| 5055 | + 'class' => 'bsvc_page form-select-sm no-select2', |
|
| 5056 | + 'options' => sd_template_page_options(), |
|
| 5057 | + 'default' => '', |
|
| 5058 | + 'value' => '', |
|
| 5059 | + 'label_type' => 'top', |
|
| 5060 | + 'select2' => false, |
|
| 5061 | + 'element_require' => '[%bsvc_output%]=="page"' |
|
| 5062 | + ) |
|
| 5063 | + ); |
|
| 5064 | + |
|
| 5065 | + $content .= aui()->select( |
|
| 5066 | + array( |
|
| 5067 | + 'id' => 'bsvc_tmpl_part', |
|
| 5068 | + 'name' => 'bsvc_tmpl_part', |
|
| 5069 | + 'label' => __( 'Template Part', 'ayecode-connect' ), |
|
| 5070 | + 'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ), |
|
| 5071 | + 'class' => 'bsvc_tmpl_part form-select-sm no-select2', |
|
| 5072 | + 'options' => sd_template_part_options(), |
|
| 5073 | + 'default' => '', |
|
| 5074 | + 'value' => '', |
|
| 5075 | + 'label_type' => 'top', |
|
| 5076 | + 'select2' => false, |
|
| 5077 | + 'element_require' => '[%bsvc_output%]=="template_part"', |
|
| 5078 | + 'extra_attributes' => array( |
|
| 5079 | + 'data-minimum-results-for-search' => '-1' |
|
| 5080 | + ) |
|
| 5081 | + ) |
|
| 5082 | + ); |
|
| 5083 | + |
|
| 5084 | + $content .= aui()->select( |
|
| 5085 | + array( |
|
| 5086 | + 'id' => 'bsvc_message_type', |
|
| 5087 | + 'name' => 'bsvc_message_type', |
|
| 5088 | + 'label' => __( 'Custom Message Type', 'ayecode-connect' ), |
|
| 5089 | + 'placeholder' => __( 'Default (none)', 'ayecode-connect' ), |
|
| 5090 | + 'class' => 'bsvc_message_type form-select-sm no-select2', |
|
| 5091 | + 'options' => sd_aui_colors(), |
|
| 5092 | + 'default' => '', |
|
| 5093 | + 'value' => '', |
|
| 5094 | + 'label_type' => 'top', |
|
| 5095 | + 'select2' => false, |
|
| 5096 | + 'element_require' => '[%bsvc_output%]=="message"', |
|
| 5097 | + 'extra_attributes' => array( |
|
| 5098 | + 'data-minimum-results-for-search' => '-1' |
|
| 5099 | + ) |
|
| 5100 | + ) |
|
| 5101 | + ); |
|
| 5102 | + |
|
| 5103 | + $content .= '</div><div class="col-sm-12">'; |
|
| 5104 | + |
|
| 5105 | + $content .= aui()->input( |
|
| 5106 | + array( |
|
| 5107 | + 'type' => 'text', |
|
| 5108 | + 'id' => 'bsvc_message', |
|
| 5109 | + 'name' => 'bsvc_message', |
|
| 5110 | + 'label' => '', |
|
| 5111 | + 'class' => 'bsvc_message form-control-sm', |
|
| 5112 | + 'placeholder' => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ), |
|
| 5113 | + 'label_type' => '', |
|
| 5114 | + 'value' => '', |
|
| 5115 | + 'form_group_class' => ' ', |
|
| 5116 | + 'element_require' => '[%bsvc_output%]=="message"', |
|
| 5117 | + ) |
|
| 5118 | + ); |
|
| 5119 | + |
|
| 5120 | + $content .= '</div></div></form><input type="hidden" id="bsvc_raw_value" name="bsvc_raw_value" value="' . $value . '">'; |
|
| 5121 | + |
|
| 5122 | + return $content; |
|
| 5123 | + } |
|
| 5124 | + } |
|
| 5125 | 5125 | } |