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:
- The Best Selling Theme of the Year
- Free Support + Updates + Plugins
- Elementor + WP Bakery + WP Bottom Menu Support
- 800+ Award-Winning Templates
- And Many More!
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;
}
?>
get_condition();
}
// woocommerce cart fragment
function wp_bottom_menu_add_to_cart_fragment( $fragments ) {
$fragments['div.wp-bottom-menu-cart-count'] = '';
$fragments['span.wp-bottom-menu-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' );