| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: WP Bottom Menu |
| 4 |
* Description: WP Bottom Menu allows you to add a woocommerce supported bottom menu to your site. |
| 5 |
* Version: 2.3.0 |
| 6 |
* Author: J4 & LiquidThemes |
| 7 |
* Author URI: https://hub.liquid-themes.com/ |
| 8 |
* License: GPL v2 or later |
| 9 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 10 |
* Text Domain: wp-bottom-menu |
| 11 |
* Domain Path: /languages |
| 12 |
* |
| 13 |
* WP Bottom Menu is free software: you can redistribute it and/or modify |
| 14 |
* it under the terms of the GNU General Public License as published by |
| 15 |
* the Free Software Foundation, either version 2 of the License, or |
| 16 |
* any later version. |
| 17 |
* |
| 18 |
* WP Bottom Menu is distributed in the hope that it will be useful, |
| 19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
* GNU General Public License for more details. |
| 22 |
*/ |
| 23 |
|
| 24 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 25 |
|
| 26 |
define( 'WP_BOTTOM_MENU_VERSION', '2.3.0' ); |
| 27 |
define( 'WP_BOTTOM_MENU_DIR_URL', plugin_dir_url( __FILE__ ) ); |
| 28 |
define( 'WP_BOTTOM_MENU_DIR_PATH', plugin_dir_path( __FILE__ ) ); |
| 29 |
|
| 30 |
|
| 31 |
final class WPBottomMenu{ |
| 32 |
|
| 33 |
/** |
| 34 |
* Instance |
| 35 |
* |
| 36 |
* @since 1.0.0 |
| 37 |
* |
| 38 |
* @access private |
| 39 |
* @static |
| 40 |
* |
| 41 |
* @var WPBottomMenu The single instance of the class. |
| 42 |
*/ |
| 43 |
private static $_instance = null; |
| 44 |
|
| 45 |
/** |
| 46 |
* Instance |
| 47 |
* |
| 48 |
* Ensures only one instance of the class is loaded or can be loaded. |
| 49 |
* |
| 50 |
* @since 1.0.0 |
| 51 |
* |
| 52 |
* @access public |
| 53 |
* @static |
| 54 |
* |
| 55 |
* @return WPBottomMenu An instance of the class. |
| 56 |
*/ |
| 57 |
public static function instance() { |
| 58 |
|
| 59 |
if ( is_null( self::$_instance ) ) { |
| 60 |
self::$_instance = new self(); |
| 61 |
} |
| 62 |
return self::$_instance; |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Constructor |
| 67 |
* |
| 68 |
* @since 1.0.0 |
| 69 |
* |
| 70 |
* @access public |
| 71 |
*/ |
| 72 |
public function __construct() { |
| 73 |
$this->init(); |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Load Textdomain |
| 78 |
* |
| 79 |
* Load plugin localization files. |
| 80 |
* |
| 81 |
* Fired by `init` action hook. |
| 82 |
* |
| 83 |
* @since 1.0.0 |
| 84 |
* |
| 85 |
* @access public |
| 86 |
*/ |
| 87 |
public function i18n() { |
| 88 |
|
| 89 |
load_plugin_textdomain( 'wp-bottom-menu' ); |
| 90 |
|
| 91 |
} |
| 92 |
|
| 93 |
/** |
| 94 |
* Initialize the plugin |
| 95 |
* |
| 96 |
* Load the files required to run the plugin. |
| 97 |
* |
| 98 |
* @since 1.0.0 |
| 99 |
* |
| 100 |
* @access public |
| 101 |
*/ |
| 102 |
function init(){ |
| 103 |
|
| 104 |
$this->i18n(); |
| 105 |
$this->include_files(); |
| 106 |
|
| 107 |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
| 108 |
add_action( 'wp_footer', array($this, 'wp_bottom_menu' ) ); |
| 109 |
add_filter( 'plugin_action_links', array($this, 'wp_bottom_menu_action_links'), 10, 2 ); |
| 110 |
|
| 111 |
// Admin menu - Settings > WP Bottom Menu |
| 112 |
add_action( 'admin_menu', function() { |
| 113 |
add_submenu_page( |
| 114 |
'options-general.php', 'WP Bottom Menu', 'WP Bottom Menu', 'manage_options', 'wp-bottom-menu', |
| 115 |
function(){ |
| 116 |
echo '<script>window.location.href = "' . esc_url( admin_url( 'customize.php?autofocus[panel]=wpbottommenu_panel' ) ) . '";</script>'; |
| 117 |
} |
| 118 |
); |
| 119 |
} ); |
| 120 |
|
| 121 |
add_action( 'customize_controls_enqueue_scripts', function(){ |
| 122 |
|
| 123 |
// customizer js |
| 124 |
wp_enqueue_script( 'wp-bottom-menu-customize', WP_BOTTOM_MENU_DIR_URL . 'assets/js/customizer.js', array( 'jquery', 'customize-controls' ), false, true ); |
| 125 |
|
| 126 |
// select2 |
| 127 |
wp_enqueue_script( 'select2', WP_BOTTOM_MENU_DIR_URL . 'assets/vendors/select2/select2.min.js', [], false, false ); |
| 128 |
wp_enqueue_style( 'select2', WP_BOTTOM_MENU_DIR_URL . 'assets/vendors/select2/select2.min.css', array(), WP_BOTTOM_MENU_VERSION, 'all' ); |
| 129 |
wp_add_inline_script( 'wp-bottom-menu-customize', ' |
| 130 |
jQuery( document ).ready(function() { |
| 131 |
jQuery(".wp-bottom-menu-select2").select2({ |
| 132 |
placeholder: "Select an option" |
| 133 |
}); |
| 134 |
}); |
| 135 |
'); |
| 136 |
} ); |
| 137 |
|
| 138 |
// Load WooCommerce Fragments |
| 139 |
if ( class_exists( 'WooCommerce' ) ){ |
| 140 |
add_filter( 'woocommerce_add_to_cart_fragments', array($this, 'wp_bottom_menu_add_to_cart_fragment'), 10, 1 ); |
| 141 |
} |
| 142 |
|
| 143 |
// Register Nav Menus |
| 144 |
add_action( 'after_setup_theme', function() { |
| 145 |
register_nav_menus( array( |
| 146 |
'wpbm_custom' => __( 'WP Bottom Menu', 'wp-bottom-menu' ), |
| 147 |
) ); |
| 148 |
} ); |
| 149 |
|
| 150 |
// Polylang register translatable strings |
| 151 |
add_action('init', function(){ |
| 152 |
if ( function_exists('pll_register_string') ) { |
| 153 |
$customizer_repeater_wpbm = get_option('customizer_repeater_wpbm', json_encode( array( |
| 154 |
array("choice" => "wpbm-homepage" ,"subtitle" => "fa-home", "title" => "Home", "id" => "customizer_repeater_1" ), |
| 155 |
array("choice" => "wpbm-woo-account" ,"subtitle" => "fa-user", "title" => "Account", "id" => "customizer_repeater_2" ), |
| 156 |
array("choice" => "wpbm-woo-cart" ,"subtitle" => "fa-shopping-cart", "title" => "Cart", "id" => "customizer_repeater_3" ), |
| 157 |
array("choice" => "wpbm-woo-search" ,"subtitle" => "fa-search", "title" => "Search", "id" => "customizer_repeater_4" ), |
| 158 |
) ) ); |
| 159 |
|
| 160 |
$customizer_repeater_wpbm_decoded = json_decode($customizer_repeater_wpbm); |
| 161 |
|
| 162 |
foreach ( $customizer_repeater_wpbm_decoded as $repeater_item ) { |
| 163 |
pll_register_string( 'Menu Item', $repeater_item->title, 'WP Bottom Menu' ); |
| 164 |
pll_register_string( 'Menu Link', $repeater_item->link, 'WP Bottom Menu' ); |
| 165 |
} |
| 166 |
} |
| 167 |
}); |
| 168 |
|
| 169 |
} |
| 170 |
|
| 171 |
function include_files(){ |
| 172 |
|
| 173 |
require_once( WP_BOTTOM_MENU_DIR_PATH . 'inc/customizer/customizer-repeater/functions.php' ); |
| 174 |
require_once( WP_BOTTOM_MENU_DIR_PATH . 'inc/customizer/customizer.php' ); |
| 175 |
require_once( WP_BOTTOM_MENU_DIR_PATH . 'inc/customizer/condition.php' ); |
| 176 |
|
| 177 |
} |
| 178 |
|
| 179 |
// enqueue scripts |
| 180 |
function enqueue_scripts() { |
| 181 |
|
| 182 |
// check the display condition |
| 183 |
if ( $this->display_condition() ){ |
| 184 |
|
| 185 |
wp_enqueue_style( 'wp-bottom-menu', WP_BOTTOM_MENU_DIR_URL . 'assets/css/style.css', array(), WP_BOTTOM_MENU_VERSION, 'all' ); |
| 186 |
wp_enqueue_script( 'wp-bottom-menu', WP_BOTTOM_MENU_DIR_URL . 'assets/js/main.js', array(), WP_BOTTOM_MENU_VERSION, true ); |
| 187 |
|
| 188 |
if ( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome' ){ |
| 189 |
wp_enqueue_style( 'font-awesome', WP_BOTTOM_MENU_DIR_URL . 'inc/customizer/customizer-repeater/css/font-awesome.min.css', array(), CUSTOMIZER_REPEATER_VERSION ); |
| 190 |
} |
| 191 |
if ( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome2' ){ |
| 192 |
wp_enqueue_style( 'font-awesome-wpbm', WP_BOTTOM_MENU_DIR_URL . 'assets/vendors/fontawesome/all.min.css', array(), '6.1.1' ); |
| 193 |
} |
| 194 |
|
| 195 |
wp_localize_script( 'wp-bottom-menu', 'WPBM', |
| 196 |
array( |
| 197 |
'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 198 |
'siteurl' => site_url(), |
| 199 |
) |
| 200 |
); |
| 201 |
|
| 202 |
} |
| 203 |
|
| 204 |
} |
| 205 |
|
| 206 |
// wp bottom menu |
| 207 |
function wp_bottom_menu() { |
| 208 |
|
| 209 |
// check the display condition |
| 210 |
if ( !$this->display_condition() ){ |
| 211 |
return; |
| 212 |
} |
| 213 |
|
| 214 |
$svg_allowed_tags = array( |
| 215 |
'svg' => array( |
| 216 |
'xmlns' => true, 'width' => true, 'height' => true, 'viewbox' => true, |
| 217 |
'fill' => true, 'stroke' => true, 'stroke-width' => true, |
| 218 |
'stroke-linecap' => true, 'stroke-linejoin' => true, 'class' => true, |
| 219 |
), |
| 220 |
'path' => array( |
| 221 |
'd' => true, 'stroke' => true, 'fill' => true, 'stroke-width' => true, |
| 222 |
'fill-rule' => true, 'clip-rule' => true, |
| 223 |
), |
| 224 |
'span' => array( |
| 225 |
'class' => true, 'data-tippy-content' => true, 'title' => true, |
| 226 |
), |
| 227 |
'i' => array( 'class' => true ), |
| 228 |
); |
| 229 |
|
| 230 |
?> |
| 231 |
<div class="wp-bottom-menu" id="wp-bottom-menu"> |
| 232 |
|
| 233 |
<?php |
| 234 |
$customizer_repeater_wpbm = get_option('customizer_repeater_wpbm', json_encode( array( |
| 235 |
array("choice" => "wpbm-homepage" ,"subtitle" => "fa-home", "title" => "Home", "id" => "customizer_repeater_1" ), |
| 236 |
array("choice" => "wpbm-woo-account" ,"subtitle" => "fa-user", "title" => "Account", "id" => "customizer_repeater_2" ), |
| 237 |
array("choice" => "wpbm-woo-cart" ,"subtitle" => "fa-shopping-cart", "title" => "Cart", "id" => "customizer_repeater_3" ), |
| 238 |
array("choice" => "wpbm-woo-search" ,"subtitle" => "fa-search", "title" => "Search", "id" => "customizer_repeater_4" ), |
| 239 |
) ) ); |
| 240 |
/*This returns a json so we have to decode it*/ |
| 241 |
|
| 242 |
$customizer_repeater_wpbm_decoded = json_decode($customizer_repeater_wpbm); |
| 243 |
$wpbm_woo_search = $wpbm_post_search = $wpbm_custom_search = $wpbm_custom_menu = false; |
| 244 |
$search_icon = 'fa-search'; |
| 245 |
$wpbm_link_target = get_option( 'wpbottommenu_target' ) ? 'target=_blank' : ''; |
| 246 |
foreach ( $customizer_repeater_wpbm_decoded as $repeater_item ) { |
| 247 |
|
| 248 |
$tag = 'a'; |
| 249 |
|
| 250 |
if ( $repeater_item->choice == "wpbm-woo-search" || $repeater_item->choice == "wpbm-post-search" || $repeater_item->choice == "wpbm-custom-search" ): |
| 251 |
$tag = 'div'; |
| 252 |
if ( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome' ) { |
| 253 |
$search_icon = 'fa ' . $repeater_item->subtitle; |
| 254 |
} elseif ( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome2' || get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'svg' ) { |
| 255 |
$search_icon = $repeater_item->subtitle; |
| 256 |
} |
| 257 |
?> |
| 258 |
<<?php echo esc_attr( $tag ); ?> title="<?php echo esc_attr( $repeater_item->title ); ?>" class="wp-bottom-menu-item wp-bottom-menu-search-form-trigger"> |
| 259 |
<?php elseif ( $repeater_item->choice == "wpbm-menu" ): ?> |
| 260 |
<?php $tag = 'div'; ?> |
| 261 |
<<?php echo esc_attr( $tag ); ?> title="<?php echo esc_attr( $repeater_item->title ); ?>" class="wp-bottom-menu-item wp-bottom-menu-nav-trigger"> |
| 262 |
<?php elseif ( $repeater_item->choice == "wpbm-onclick" ): ?> |
| 263 |
<?php $tag = 'div'; ?> |
| 264 |
<<?php echo esc_attr( $tag ); ?> onclick="<?php echo esc_attr( $repeater_item->text ); ?>" title="<?php echo esc_attr( $repeater_item->title ); ?>" class="wp-bottom-menu-item"> |
| 265 |
<?php else: ?> |
| 266 |
<?php |
| 267 |
$wpbm_item_url = ''; |
| 268 |
$classes = array('wp-bottom-menu-item'); |
| 269 |
switch($repeater_item->choice){ |
| 270 |
case "wpbm-homepage": |
| 271 |
$wpbm_item_url = esc_url( home_url() ); |
| 272 |
if ( is_front_page() ){ |
| 273 |
array_push( $classes, 'active' ); |
| 274 |
} |
| 275 |
break; |
| 276 |
case "wpbm-woo-cart": |
| 277 |
if ( class_exists( 'WooCommerce' ) ) { |
| 278 |
$wpbm_item_url = esc_url( wc_get_page_permalink( 'cart' ) ); |
| 279 |
} else { |
| 280 |
$wpbm_item_url = '#'; |
| 281 |
} |
| 282 |
break; |
| 283 |
case "wpbm-woo-account": |
| 284 |
if ( class_exists( 'WooCommerce' ) ) { |
| 285 |
$wpbm_item_url = esc_url( wc_get_page_permalink( 'myaccount' ) ); |
| 286 |
} else { |
| 287 |
$wpbm_item_url = '#'; |
| 288 |
} |
| 289 |
break; |
| 290 |
case "wpbm-page-back": |
| 291 |
$wpbm_item_url = 'javascript:void(0)'; |
| 292 |
array_push( $classes, 'wpbm-page-back' ); |
| 293 |
break; |
| 294 |
default: |
| 295 |
$wpbm_item_url = esc_url( $this->translated_menu_title($repeater_item->link) ); |
| 296 |
} |
| 297 |
|
| 298 |
if ( url_to_postid($wpbm_item_url) === get_the_ID() ){ |
| 299 |
array_push( $classes, 'active' ); |
| 300 |
} elseif ( class_exists('WooCommerce') && is_shop() && url_to_postid($wpbm_item_url) === 0 ) { |
| 301 |
if ( $wpbm_item_url !== home_url() ) { |
| 302 |
array_push( $classes, 'active' ); |
| 303 |
} |
| 304 |
} |
| 305 |
|
| 306 |
?> |
| 307 |
<<?php echo esc_attr( $tag ); ?> href="<?php echo esc_url( $wpbm_item_url ); ?>" class="<?php echo esc_attr( join( ' ', $classes ) ); ?>" <?php echo esc_attr( $wpbm_link_target ); ?>> |
| 308 |
<?php endif; ?> |
| 309 |
|
| 310 |
<div class="wp-bottom-menu-icon-wrapper"> |
| 311 |
<?php if( get_option( 'wpbottommenu_show_cart_count', false ) ): ?> |
| 312 |
<?php if ( class_exists( 'WooCommerce' ) && $repeater_item->choice == "wpbm-woo-cart" ) : ?> |
| 313 |
<div class="wp-bottom-menu-cart-count"><?php echo esc_html( WC()->cart->get_cart_contents_count() ); ?></div> |
| 314 |
<?php endif; ?> |
| 315 |
<?php endif; ?> |
| 316 |
|
| 317 |
<?php if( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome' ): ?> |
| 318 |
<i class="wp-bottom-menu-item-icons fa <?php echo esc_attr( $repeater_item->subtitle ); ?>"></i> |
| 319 |
<?php elseif( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome2' ): ?> |
| 320 |
<i class="wp-bottom-menu-item-icons <?php echo esc_attr( $repeater_item->subtitle ); ?>"></i> |
| 321 |
<?php else: ?> |
| 322 |
<?php echo wp_kses( html_entity_decode( $repeater_item->subtitle ), $svg_allowed_tags ); ?> |
| 323 |
<?php endif; ?> |
| 324 |
</div> |
| 325 |
<?php if( !get_option( 'wpbottommenu_disable_title', false ) ): ?> |
| 326 |
<?php if( get_option( 'wpbottommenu_show_cart_total', false ) && $repeater_item->choice == "wpbm-woo-cart" && class_exists( 'WooCommerce' ) ): ?> |
| 327 |
<span class="wp-bottom-menu-cart-total"><?php WC()->cart->get_cart_total(); ?></span> |
| 328 |
<?php elseif( get_option( 'wpbottommenu_show_account_name' ) && $repeater_item->choice == "wpbm-woo-account" && class_exists( 'WooCommerce' ) && is_user_logged_in() ): ?> |
| 329 |
<?php echo esc_html( wp_get_current_user()->first_name ? wp_get_current_user()->first_name : wp_get_current_user()->user_login ); ?> |
| 330 |
<?php else: ?> |
| 331 |
<span><?php echo esc_html( $this->translated_menu_title($repeater_item->title) ); ?></span> |
| 332 |
<?php endif; ?> |
| 333 |
<?php endif; ?> |
| 334 |
|
| 335 |
</<?php echo esc_attr( $tag ); ?>> |
| 336 |
<?php |
| 337 |
|
| 338 |
if ( $repeater_item->choice == "wpbm-woo-search" && !$wpbm_woo_search ) |
| 339 |
$wpbm_woo_search = true; |
| 340 |
|
| 341 |
if ( $repeater_item->choice == "wpbm-post-search" && !$wpbm_post_search ) |
| 342 |
$wpbm_post_search = true; |
| 343 |
|
| 344 |
if ( $repeater_item->choice == "wpbm-custom-search" && !$wpbm_custom_search ) |
| 345 |
$wpbm_custom_search = true; |
| 346 |
|
| 347 |
if ( $repeater_item->choice == "wpbm-menu" && !$wpbm_custom_menu ) |
| 348 |
$wpbm_custom_menu = true; |
| 349 |
|
| 350 |
} |
| 351 |
?> |
| 352 |
</div> |
| 353 |
|
| 354 |
<?php if ( $wpbm_custom_menu ) : ?> |
| 355 |
<div class="wp-bottom-menu-nav-wrapper"> |
| 356 |
<span class="wpbm-nav-close">×</span> |
| 357 |
<?php |
| 358 |
if ( has_nav_menu( 'wpbm_custom' ) ) { |
| 359 |
wp_nav_menu( array( |
| 360 |
'theme_location' => 'wpbm_custom', |
| 361 |
'container' => 'ul', |
| 362 |
'menu_id' => 'wpbm-nav', |
| 363 |
'menu_class' => 'wpbm-nav-items', |
| 364 |
) ); |
| 365 |
} else { |
| 366 |
esc_html_e( 'Add a menu in "WP Dashboard->Appearance->Menus" and select Display location "WP Bottom Menu"', 'wp-bottom-menu' ); |
| 367 |
} |
| 368 |
?> |
| 369 |
</div> |
| 370 |
<?php endif; |
| 371 |
|
| 372 |
if ( $wpbm_woo_search || $wpbm_post_search || $wpbm_custom_search ): ?> |
| 373 |
<div class="wp-bottom-menu-search-form-wrapper" id="wp-bottom-menu-search-form-wrapper"> |
| 374 |
<form role="search" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>" class="wp-bottom-menu-search-form"> |
| 375 |
<?php if ( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'svg' ) : ?> |
| 376 |
<?php echo wp_kses( html_entity_decode( $search_icon ), $svg_allowed_tags ); ?> |
| 377 |
<?php else : ?> |
| 378 |
<i class="<?php echo esc_attr( $search_icon ); ?>"></i> |
| 379 |
<?php endif; ?> |
| 380 |
<?php if ( $wpbm_woo_search && class_exists( 'WooCommerce' ) ) { ?> |
| 381 |
<input type="hidden" name="post_type" value="product" /> |
| 382 |
<?php } elseif ( $wpbm_post_search ) { ?> |
| 383 |
<input type="hidden" name="post_type" value="post" /> |
| 384 |
<?php } else { |
| 385 |
$search_cpt = get_option( 'wpbottommenu_search_cpt', 'all' ); |
| 386 |
if ( $search_cpt === 'all' || empty( $search_cpt ) ){ |
| 387 |
?><input type="hidden" name="post_type" value="all" /><?php |
| 388 |
} else { |
| 389 |
$search_cpt = explode(',', $search_cpt); |
| 390 |
foreach( $search_cpt as $cpt ){ |
| 391 |
if ( !empty( $cpt ) ){ |
| 392 |
?><input type="hidden" name="post_type[]" value="<?php echo esc_attr( $cpt ); ?>" /><?php |
| 393 |
} |
| 394 |
} |
| 395 |
} |
| 396 |
} ?> |
| 397 |
<input type="search" class="search-field" placeholder="<?php if( get_option( 'wpbottommenu_placeholder_text', 'Search' ) ) echo esc_attr( get_option( 'wpbottommenu_placeholder_text', 'Search' ) ); else echo esc_attr_x( 'Search', 'placeholder', 'wp-bottom-menu' ); ?>" value="<?php echo get_search_query(); ?>" name="s" /> |
| 398 |
</form> |
| 399 |
</div> |
| 400 |
<?php endif; |
| 401 |
|
| 402 |
} |
| 403 |
|
| 404 |
function translated_menu_title( $title ) { |
| 405 |
if ( function_exists('pll__') ) { |
| 406 |
return pll__( $title ); |
| 407 |
} |
| 408 |
|
| 409 |
return $title; |
| 410 |
} |
| 411 |
|
| 412 |
function display_condition(){ |
| 413 |
|
| 414 |
$condition = new \WPBottomMenu_Condition(); |
| 415 |
return $condition->get_condition(); |
| 416 |
|
| 417 |
} |
| 418 |
|
| 419 |
// woocommerce cart fragment |
| 420 |
function wp_bottom_menu_add_to_cart_fragment( $fragments ) { |
| 421 |
$fragments['div.wp-bottom-menu-cart-count'] = '<div class="wp-bottom-menu-cart-count">' . WC()->cart->get_cart_contents_count() . '</div>'; |
| 422 |
$fragments['span.wp-bottom-menu-cart-total'] = '<span class="wp-bottom-menu-cart-total">' . WC()->cart->get_cart_total() . '</span>'; |
| 423 |
return $fragments; |
| 424 |
} |
| 425 |
|
| 426 |
// plugin action links |
| 427 |
function wp_bottom_menu_action_links( $links_array, $plugin_file_name ){ |
| 428 |
if( strpos( $plugin_file_name, basename(__FILE__) ) ) { |
| 429 |
array_unshift( $links_array, '<a href="' . admin_url( 'customize.php?autofocus[panel]=wpbottommenu_panel' ) . '">Settings</a>' ); |
| 430 |
} |
| 431 |
return $links_array; |
| 432 |
} |
| 433 |
|
| 434 |
} // class |
| 435 |
WPBottomMenu::instance(); |
| 436 |
|
| 437 |
|
| 438 |
function wp_bottom_menu_plugin_activate() { |
| 439 |
flush_rewrite_rules(); |
| 440 |
} |
| 441 |
register_activation_hook( __FILE__, 'wp_bottom_menu_plugin_activate' ); |
| 442 |
|
| 443 |
function wp_bottom_menu_plugin_deactivate() { |
| 444 |
/* If you want all settings to be deleted when the plugin is deactive, activate this field. |
| 445 |
TODO : Add reset all settings option |
| 446 |
|
| 447 |
delete_option(' customizer_repeater_wpbm' ); |
| 448 |
delete_option( 'wpbottommenu_display_px' ); |
| 449 |
delete_option( 'wpbottommenu_display_always' ); |
| 450 |
delete_option( 'wpbottommenu_fontsize' ); |
| 451 |
delete_option( 'wpbottommenu_iconsize' ); |
| 452 |
delete_option( 'wpbottommenu_textcolor' ); |
| 453 |
delete_option( 'wpbottommenu_htextcolor' ); |
| 454 |
delete_option( 'wpbottommenu_iconcolor' ); |
| 455 |
delete_option( 'wpbottommenu_hiconcolor' ); |
| 456 |
delete_option( 'wpbottommenu_bgcolor' ); |
| 457 |
delete_option( 'wpbottommenu_zindex' ); |
| 458 |
delete_option( 'wpbottommenu_disable_title' ); |
| 459 |
delete_option( 'wpbottommenu_iconset' ); |
| 460 |
delete_option( 'wpbottommenu_placeholder_text' ); |
| 461 |
delete_option( 'wpbottommenu_show_cart_count' ); |
| 462 |
delete_option( 'wpbottommenu_show_cart_total' ); |
| 463 |
delete_option( 'wpbottommenu_cart_count_bgcolor' ); |
| 464 |
delete_option( 'wpbottommenu_hide_pages' ); |
| 465 |
delete_option( 'wpbottommenu_wrapper_padding' ); |
| 466 |
*/ |
| 467 |
flush_rewrite_rules(); |
| 468 |
} |
| 469 |
register_deactivation_hook( __FILE__, 'wp_bottom_menu_plugin_deactivate' ); |