init(); } /** * Load Textdomain * * Load plugin localization files. * * Fired by `init` action hook. * * @since 1.0.0 * * @access public */ public function i18n() { load_plugin_textdomain( 'wp-bottom-menu' ); } /** * Initialize the plugin * * Load the files required to run the plugin. * * @since 1.0.0 * * @access public */ function init(){ $this->i18n(); $this->include_files(); $this->promote_hub(); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'wp_footer', array($this, 'wp_bottom_menu' ) ); add_filter( 'plugin_action_links', array($this, 'wp_bottom_menu_action_links'), 10, 2 ); add_action( 'customize_controls_enqueue_scripts', function(){ // customizer js wp_enqueue_script( 'wp-bottom-menu-customize', WP_BOTTOM_MENU_DIR_URL . 'assets/js/customizer.js', array( 'jquery', 'customize-controls' ), false, true ); // select2 wp_enqueue_script( 'select2', WP_BOTTOM_MENU_DIR_URL . 'assets/vendors/select2/select2.min.js', [], false, false ); wp_enqueue_style( 'select2', WP_BOTTOM_MENU_DIR_URL . 'assets/vendors/select2/select2.min.css', array(), WP_BOTTOM_MENU_VERSION, 'all' ); wp_add_inline_script( 'wp-bottom-menu-customize', ' jQuery( document ).ready(function() { jQuery(".wp-bottom-menu-select2").select2({ placeholder: "Select an option" }); }); '); } ); // Load WooCommerce Fragments if ( class_exists( 'WooCommerce' ) ){ add_filter( 'woocommerce_add_to_cart_fragments', array($this, 'wp_bottom_menu_add_to_cart_fragment'), 10, 1 ); } } function include_files(){ require_once( WP_BOTTOM_MENU_DIR_PATH . 'inc/customizer/customizer-repeater/functions.php' ); require_once( WP_BOTTOM_MENU_DIR_PATH . 'inc/customizer/customizer.php' ); require_once( WP_BOTTOM_MENU_DIR_PATH . 'inc/customizer/condition.php' ); } function promote_hub(){ // Hub promote notice if ( isset( $_GET['hub_promote'] ) && 'false' === $_GET['hub_promote'] ) { set_transient( 'hub_promote', [], 4 * WEEK_IN_SECONDS ); } if ( false === get_transient( 'hub_promote' ) ){ add_action( 'admin_notices', function() { if ( 'Hub' === wp_get_theme()->get( 'Name' ) || 'Hub Child' === wp_get_theme()->get( 'Name' ) ) { return; } ?>

Looking for an ultra fast WP theme?

WP Bottom Menu developers recommend Hub:

Join Hub Learn More Hide Notification

display_condition() ){ wp_enqueue_style( 'wp-bottom-menu', WP_BOTTOM_MENU_DIR_URL . 'assets/css/style.css', array(), WP_BOTTOM_MENU_VERSION, 'all' ); wp_enqueue_script( 'wp-bottom-menu', WP_BOTTOM_MENU_DIR_URL . 'assets/js/main.js', array(), WP_BOTTOM_MENU_VERSION, true ); if ( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome' ){ wp_enqueue_style( 'font-awesome', WP_BOTTOM_MENU_DIR_URL . 'inc/customizer-repeater/css/font-awesome.min.css', array(), CUSTOMIZER_REPEATER_VERSION ); } if ( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome2' ){ wp_enqueue_style( 'font-awesome-wpbm', WP_BOTTOM_MENU_DIR_URL . 'assets/vendors/fontawesome/all.min.css', array(), '6.1.1' ); } } } // wp bottom menu function wp_bottom_menu() { // check the display condition if ( !$this->display_condition() ){ return; } ?>
"wpbm-homepage" ,"subtitle" => "fa-home", "title" => "Home", "id" => "customizer_repeater_1" ), array("choice" => "wpbm-woo-account" ,"subtitle" => "fa-user", "title" => "Account", "id" => "customizer_repeater_2" ), array("choice" => "wpbm-woo-cart" ,"subtitle" => "fa-shopping-cart", "title" => "Cart", "id" => "customizer_repeater_3" ), array("choice" => "wpbm-woo-search" ,"subtitle" => "fa-search", "title" => "Search", "id" => "customizer_repeater_4" ), ) ) ); /*This returns a json so we have to decode it*/ $customizer_repeater_wpbm_decoded = json_decode($customizer_repeater_wpbm); $wpbm_woo_search = false; $wpbm_post_search = false; $wpbm_link_target = get_option( 'wpbottommenu_target' ) ? 'target=_blank' : ''; foreach($customizer_repeater_wpbm_decoded as $repeater_item){ if($repeater_item->choice == "wpbm-woo-search" or $repeater_item->choice == "wpbm-post-search"):?> choice){ case "wpbm-homepage": $wpbm_item_url = esc_url( home_url() ); if ( is_front_page() ){ $wpbm_item_active = 'active'; } break; case "wpbm-woo-cart": if ( class_exists( 'WooCommerce' ) ) { $wpbm_item_url = esc_url( wc_get_page_permalink( 'cart' ) ); } else { $wpbm_item_url = '#'; } break; case "wpbm-woo-account": if ( class_exists( 'WooCommerce' ) ) { $wpbm_item_url = esc_url( wc_get_page_permalink( 'myaccount' ) ); } else { $wpbm_item_url = '#'; } break; default: $wpbm_item_url = esc_url( $repeater_item->link ); } if ( url_to_postid($wpbm_item_url) === get_the_ID() ){ $wpbm_item_active = 'active'; } ?> >
choice == "wpbm-woo-cart" ) : ?>
cart->get_cart_contents_count() ); ?>
subtitle ); ?>
choice == "wpbm-woo-cart" && class_exists( 'WooCommerce' ) ): ?> cart->get_cart_total(); ?> title; ?>
choice == "wpbm-woo-search" && !$wpbm_woo_search ) $wpbm_woo_search = true; if ( $repeater_item->choice == "wpbm-post-search" && !$wpbm_post_search ) $wpbm_post_search = true; } ?>
get_condition(); } // woocommerce cart fragment function wp_bottom_menu_add_to_cart_fragment( $fragments ) { $fragments['div.wp-bottom-menu-cart-count'] = '
' . WC()->cart->get_cart_contents_count() . '
'; $fragments['span.wp-bottom-menu-cart-total'] = '' . WC()->cart->get_cart_total() . ''; return $fragments; } // plugin action links function wp_bottom_menu_action_links( $links_array, $plugin_file_name ){ if( strpos( $plugin_file_name, basename(__FILE__) ) ) { array_unshift( $links_array, 'Settings' ); } return $links_array; } } // class WPBottomMenu::instance(); function wp_bottom_menu_plugin_activate() { flush_rewrite_rules(); } register_activation_hook( __FILE__, 'wp_bottom_menu_plugin_activate' ); function wp_bottom_menu_plugin_deactivate() { /* If you want all settings to be deleted when the plugin is deactive, activate this field. delete_option(' customizer_repeater_wpbm' ); delete_option( 'wpbottommenu_display_px' ); delete_option( 'wpbottommenu_display_always' ); delete_option( 'wpbottommenu_fontsize' ); delete_option( 'wpbottommenu_iconsize' ); delete_option( 'wpbottommenu_textcolor' ); delete_option( 'wpbottommenu_htextcolor' ); delete_option( 'wpbottommenu_iconcolor' ); delete_option( 'wpbottommenu_hiconcolor' ); delete_option( 'wpbottommenu_bgcolor' ); delete_option( 'wpbottommenu_zindex' ); delete_option( 'wpbottommenu_disable_title' ); delete_option( 'wpbottommenu_iconset' ); delete_option( 'wpbottommenu_placeholder_text' ); delete_option( 'wpbottommenu_show_cart_count' ); delete_option( 'wpbottommenu_show_cart_total' ); delete_option( 'wpbottommenu_cart_count_bgcolor' ); delete_option( 'wpbottommenu_hide_pages' ); delete_option( 'wpbottommenu_wrapper_padding' ); */ flush_rewrite_rules(); } register_deactivation_hook( __FILE__, 'wp_bottom_menu_plugin_deactivate' );