PluginProbe
WP Bottom Menu / 2.2.3
WP Bottom Menu v2.2.3
trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1 1.1.1 1.1.2 1.2 1.3 1.3.2 1.4 1.4.2 1.4.3 2.0 2.0.1 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.2 2.2.1 2.2.2 All 27 releases
← All changes | wp-bottom-menu.php +310 -353 1.22.2.3 View file →
@@ -1,11 +1,11 @@
1 1 <?php
2 2 /**
3 3 * Plugin Name: WP Bottom Menu
4 4 * Description: WP Bottom Menu allows you to add a woocommerce supported bottom menu to your site.
5 - * Version: 1.2
6 - * Author: J4
7 - * Author URI: https://j4cob.net
5 + * Version: 2.2.3
6 + * Author: J4 & LiquidThemes
7 + * Author URI: https://hub.liquid-themes.com/
8 8 * License: GPL v2 or later
9 9 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
10 10 * Text Domain: wp-bottom-menu
11 11 * Domain Path: /languages
@@ -22,50 +22,195 @@
22 22 */
23 23
24 24 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
25 25
26 -define( 'WP_BOTTOM_MENU_VERSION', '1.2' );
26 +define( 'WP_BOTTOM_MENU_VERSION', '2.2.3' );
27 27 define( 'WP_BOTTOM_MENU_DIR_URL', plugin_dir_url( __FILE__ ) );
28 28 define( 'WP_BOTTOM_MENU_DIR_PATH', plugin_dir_path( __FILE__ ) );
29 29
30 30
31 -if ( class_exists( 'WPBottomMenu' ) ){
32 - $wpbottommenu = new WPBottomMenu;
33 -}
31 +final class WPBottomMenu{
34 32
35 -class WPBottomMenu{
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;
36 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 + */
37 72 public function __construct() {
38 - $this->includes();
39 - $this->_hooks();
73 + $this->init();
40 74 }
41 75
42 - function _hooks(){
43 - add_action( 'wp_enqueue_scripts', array( $this, 'add_theme_scripts' ) );
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' ) );
44 108 add_action( 'wp_footer', array($this, 'wp_bottom_menu' ) );
45 - add_action( 'customize_register', array($this, 'wp_bottom_menu_customize_register' ) );
46 - add_action( 'wp_footer', array($this, 'wpbottommenu_customize_css') );
47 109 add_filter( 'plugin_action_links', array($this, 'wp_bottom_menu_action_links'), 10, 2 );
48 - if (class_exists( 'WooCommerce' )){
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 + wp_redirect( admin_url( 'customize.php?autofocus[panel]=wpbottommenu_panel' ) );
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' ) ){
49 140 add_filter( 'woocommerce_add_to_cart_fragments', array($this, 'wp_bottom_menu_add_to_cart_fragment'), 10, 1 );
50 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 + }
165 + }
166 + });
167 +
51 168 }
52 169
53 - function includes(){
54 - require_once(WP_BOTTOM_MENU_DIR_PATH.'inc/customizer-repeater/functions.php');
170 + function include_files(){
171 +
172 + require_once( WP_BOTTOM_MENU_DIR_PATH . 'inc/customizer/customizer-repeater/functions.php' );
173 + require_once( WP_BOTTOM_MENU_DIR_PATH . 'inc/customizer/customizer.php' );
174 + require_once( WP_BOTTOM_MENU_DIR_PATH . 'inc/customizer/condition.php' );
175 +
55 176 }
56 177
57 178 // enqueue scripts
58 - function add_theme_scripts() {
59 - wp_enqueue_style( 'wp-bottom-menu-style', WP_BOTTOM_MENU_DIR_URL . 'inc/style.css', array(), WP_BOTTOM_MENU_VERSION, 'all');
60 - wp_enqueue_script( 'wp-bottom-menu-js', WP_BOTTOM_MENU_DIR_URL . 'inc/main.js', array(), WP_BOTTOM_MENU_VERSION, true);
61 - if(get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome'){
62 - wp_enqueue_style( 'font-awesome', WP_BOTTOM_MENU_DIR_URL . 'inc/customizer-repeater/css/font-awesome.min.css', array(), CUSTOMIZER_REPEATER_VERSION );
179 + function enqueue_scripts() {
180 +
181 + // check the display condition
182 + if ( $this->display_condition() ){
183 +
184 + wp_enqueue_style( 'wp-bottom-menu', WP_BOTTOM_MENU_DIR_URL . 'assets/css/style.css', array(), WP_BOTTOM_MENU_VERSION, 'all' );
185 + wp_enqueue_script( 'wp-bottom-menu', WP_BOTTOM_MENU_DIR_URL . 'assets/js/main.js', array(), WP_BOTTOM_MENU_VERSION, true );
186 +
187 + if ( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome' ){
188 + wp_enqueue_style( 'font-awesome', WP_BOTTOM_MENU_DIR_URL . 'inc/customizer/customizer-repeater/css/font-awesome.min.css', array(), CUSTOMIZER_REPEATER_VERSION );
189 + }
190 + if ( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome2' ){
191 + wp_enqueue_style( 'font-awesome-wpbm', WP_BOTTOM_MENU_DIR_URL . 'assets/vendors/fontawesome/all.min.css', array(), '6.1.1' );
192 + }
193 +
194 + wp_localize_script( 'wp-bottom-menu', 'WPBM',
195 + array(
196 + 'ajaxurl' => admin_url( 'admin-ajax.php' ),
197 + 'siteurl' => site_url(),
198 + )
199 + );
200 +
63 201 }
202 +
64 203 }
65 204
66 205 // wp bottom menu
67 206 function wp_bottom_menu() {
207 +
208 + // check the display condition
209 + if ( !$this->display_condition() ){
210 + return;
211 + }
212 +
68 213 ?>
69 214 <div class="wp-bottom-menu" id="wp-bottom-menu">
70 215
71 216 <?php
@@ -77,340 +222,182 @@
77 222 ) ) );
78 223 /*This returns a json so we have to decode it*/
79 224
80 225 $customizer_repeater_wpbm_decoded = json_decode($customizer_repeater_wpbm);
81 - $wpbmsf;
82 - foreach($customizer_repeater_wpbm_decoded as $repeater_item){
226 + $wpbm_woo_search = $wpbm_post_search = $wpbm_custom_search = $wpbm_custom_menu = false;
227 + $search_icon = 'fa-search';
228 + $wpbm_link_target = get_option( 'wpbottommenu_target' ) ? 'target=_blank' : '';
229 + foreach ( $customizer_repeater_wpbm_decoded as $repeater_item ) {
83 230
84 - if($repeater_item->choice == "wpbm-woo-search" or $repeater_item->choice == "wpbm-post-search"):?>
85 - <a href="javascript:void(0);" title="<?php echo $repeater_item->title; ?>" class="wp-bottom-menu-item wp-bottom-menu-search-form-trigger">
231 + $tag = 'a';
232 +
233 + if ( $repeater_item->choice == "wpbm-woo-search" || $repeater_item->choice == "wpbm-post-search" || $repeater_item->choice == "wpbm-custom-search" ):
234 + $tag = 'div';
235 + if ( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome' ) {
236 + $search_icon = 'fa ' . $repeater_item->subtitle;
237 + } elseif ( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome2' || get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'svg' ) {
238 + $search_icon = $repeater_item->subtitle;
239 + }
240 + ?>
241 + <<?php echo $tag; ?> title="<?php echo esc_attr( $repeater_item->title ); ?>" class="wp-bottom-menu-item wp-bottom-menu-search-form-trigger">
242 + <?php elseif ( $repeater_item->choice == "wpbm-menu" ): ?>
243 + <?php $tag = 'div'; ?>
244 + <<?php echo $tag; ?> title="<?php echo esc_attr( $repeater_item->title ); ?>" class="wp-bottom-menu-item wp-bottom-menu-nav-trigger">
245 + <?php elseif ( $repeater_item->choice == "wpbm-onclick" ): ?>
246 + <?php $tag = 'div'; ?>
247 + <<?php echo $tag; ?> onclick="<?php echo $repeater_item->text; ?>" title="<?php echo esc_attr( $repeater_item->title ); ?>" class="wp-bottom-menu-item">
86 248 <?php else: ?>
87 - <a href="<?php
249 + <?php
250 + $wpbm_item_url = '';
251 + $classes = array('wp-bottom-menu-item');
88 252 switch($repeater_item->choice){
89 253 case "wpbm-homepage":
90 - echo esc_url( home_url() );
254 + $wpbm_item_url = esc_url( home_url() );
255 + if ( is_front_page() ){
256 + array_push( $classes, 'active' );
257 + }
91 258 break;
92 259 case "wpbm-woo-cart":
93 260 if ( class_exists( 'WooCommerce' ) ) {
94 - echo esc_url( wc_get_page_permalink( 'cart' ) );
261 + $wpbm_item_url = esc_url( wc_get_page_permalink( 'cart' ) );
95 262 } else {
96 - echo '#';
263 + $wpbm_item_url = '#';
97 264 }
98 265 break;
99 266 case "wpbm-woo-account":
100 267 if ( class_exists( 'WooCommerce' ) ) {
101 - echo esc_url( wc_get_page_permalink( 'myaccount' ) );
268 + $wpbm_item_url = esc_url( wc_get_page_permalink( 'myaccount' ) );
102 269 } else {
103 - echo '#';
270 + $wpbm_item_url = '#';
104 271 }
105 272 break;
106 -
273 + case "wpbm-page-back":
274 + $wpbm_item_url = 'javascript:void(0)';
275 + array_push( $classes, 'wpbm-page-back' );
276 + break;
107 277 default:
108 - echo esc_url( $repeater_item->link );
278 + $wpbm_item_url = esc_url( $repeater_item->link );
109 279 }
110 - ?>" class="wp-bottom-menu-item">
280 +
281 + if ( url_to_postid($wpbm_item_url) === get_the_ID() ){
282 + array_push( $classes, 'active' );
283 + } elseif ( class_exists('WooCommerce') && is_shop() && url_to_postid($wpbm_item_url) === 0 ) {
284 + if ( $wpbm_item_url !== home_url() ) {
285 + array_push( $classes, 'active' );
286 + }
287 + }
288 +
289 + ?>
290 + <<?php echo $tag; ?> href="<?php echo $wpbm_item_url; ?>" class="<?php echo esc_attr( join( ' ', $classes ) ); ?>" <?php echo esc_attr( $wpbm_link_target ); ?>>
111 291 <?php endif; ?>
112 292
113 293 <div class="wp-bottom-menu-icon-wrapper">
114 - <?php if(get_option( 'wpbottommenu_show_cart_count', false )): ?>
115 - <?php if ( class_exists( 'WooCommerce' ) and $repeater_item->choice == "wpbm-woo-cart") : ?>
116 - <div class="wp-bottom-menu-cart-count"><?php echo WC()->cart->get_cart_contents_count(); ?></div>
294 + <?php if( get_option( 'wpbottommenu_show_cart_count', false ) ): ?>
295 + <?php if ( class_exists( 'WooCommerce' ) && $repeater_item->choice == "wpbm-woo-cart" ) : ?>
296 + <div class="wp-bottom-menu-cart-count"><?php echo esc_html( WC()->cart->get_cart_contents_count() ); ?></div>
117 297 <?php endif; ?>
118 298 <?php endif; ?>
119 299
120 - <?php if(get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome'): ?>
121 - <i class="wp-bottom-menu-item-icons fa <?php echo $repeater_item->subtitle; ?>"></i>
300 + <?php if( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome' ): ?>
301 + <i class="wp-bottom-menu-item-icons fa <?php echo esc_attr( $repeater_item->subtitle ); ?>"></i>
302 + <?php elseif( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome2' ): ?>
303 + <i class="wp-bottom-menu-item-icons <?php echo esc_attr( $repeater_item->subtitle ); ?>"></i>
122 304 <?php else: ?>
123 - <?php echo html_entity_decode($repeater_item->subtitle); ?>
305 + <?php echo html_entity_decode( $repeater_item->subtitle ); ?>
124 306 <?php endif; ?>
125 307 </div>
126 - <?php if(!get_option( 'wpbottommenu_disable_title', false )): ?>
127 - <?php if(get_option( 'wpbottommenu_show_cart_total', false ) and $repeater_item->choice == "wpbm-woo-cart" and class_exists( 'WooCommerce' )): ?>
128 - <span class="wp-bottom-menu-cart-total"><?php WC()->cart->get_cart_total(); ?></span>
129 - <?php else: ?>
130 - <span><?php echo $repeater_item->title; ?></span>
308 + <?php if( !get_option( 'wpbottommenu_disable_title', false ) ): ?>
309 + <?php if( get_option( 'wpbottommenu_show_cart_total', false ) && $repeater_item->choice == "wpbm-woo-cart" && class_exists( 'WooCommerce' ) ): ?>
310 + <span class="wp-bottom-menu-cart-total"><?php WC()->cart->get_cart_total(); ?></span>
311 + <?php elseif( get_option( 'wpbottommenu_show_account_name' ) && $repeater_item->choice == "wpbm-woo-account" && class_exists( 'WooCommerce' ) && is_user_logged_in() ): ?>
312 + <?php echo wp_get_current_user()->first_name ? wp_get_current_user()->first_name : wp_get_current_user()->user_login; ?>
313 + <?php else: ?>
314 + <span><?php echo $this->translated_menu_title($repeater_item->title); ?></span>
131 315 <?php endif; ?>
132 316 <?php endif; ?>
133 317
134 - </a>
318 + </<?php echo $tag; ?>>
135 319 <?php
136 - $wpbmsf = $repeater_item->choice;
137 320
321 + if ( $repeater_item->choice == "wpbm-woo-search" && !$wpbm_woo_search )
322 + $wpbm_woo_search = true;
323 +
324 + if ( $repeater_item->choice == "wpbm-post-search" && !$wpbm_post_search )
325 + $wpbm_post_search = true;
326 +
327 + if ( $repeater_item->choice == "wpbm-custom-search" && !$wpbm_custom_search )
328 + $wpbm_custom_search = true;
329 +
330 + if ( $repeater_item->choice == "wpbm-menu" && !$wpbm_custom_menu )
331 + $wpbm_custom_menu = true;
332 +
138 333 }
139 334 ?>
140 335 </div>
141 336
142 - <div class="wp-bottom-menu-search-form-wrapper" id="wp-bottom-menu-search-form-wrapper">
143 - <form role="search" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>" class="wp-bottom-menu-search-form">
144 - <i class="fa fa-search"></i>
145 - <input type="hidden" name="post_type" value="<?php if($wpbmsf=="wpbm-woo-search" and class_exists( 'WooCommerce' )) echo esc_attr("product"); else echo esc_attr("post"); ?>" />
146 - <input type="search" class="search-field" placeholder="<?php if(get_option( 'wpbottommenu_placeholder_text', 'Search' )) echo get_option( 'wpbottommenu_placeholder_text', 'Search' ); else echo esc_attr_x( 'Search', 'wp-bottom-menu' ); ?>" value="<?php echo get_search_query(); ?>" name="s" />
147 - </form>
148 - </div><?php
337 + <?php if ( $wpbm_custom_menu ) : ?>
338 + <div class="wp-bottom-menu-nav-wrapper">
339 + <span class="wpbm-nav-close">&times;</span>
340 + <?php
341 + if ( has_nav_menu( 'wpbm_custom' ) ) {
342 + wp_nav_menu( array(
343 + 'menu' => 'wpbm_custom',
344 + 'container' => 'ul',
345 + 'menu_id' => 'wpbm-nav',
346 + 'menu_class' => 'wpbm-nav-items',
347 + ) );
348 + } else {
349 + esc_html_e( 'Add a menu in "WP Dashboard->Appearance->Menus" and select Display location "WP Bottom Menu"', 'wp-bottom-menu' );
350 + }
351 + ?>
352 + </div>
353 + <?php endif;
354 +
355 + if ( $wpbm_woo_search || $wpbm_post_search || $wpbm_custom_search ): ?>
356 + <div class="wp-bottom-menu-search-form-wrapper" id="wp-bottom-menu-search-form-wrapper">
357 + <form role="search" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>" class="wp-bottom-menu-search-form">
358 + <?php if ( get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'svg' ) : ?>
359 + <?php echo html_entity_decode( $search_icon ); ?>
360 + <?php else : ?>
361 + <i class="<?php echo esc_attr( $search_icon ); ?>"></i>
362 + <?php endif; ?>
363 + <?php if ( $wpbm_woo_search && class_exists( 'WooCommerce' ) ) { ?>
364 + <input type="hidden" name="post_type" value="product" />
365 + <?php } elseif ( $wpbm_post_search ) { ?>
366 + <input type="hidden" name="post_type" value="post" />
367 + <?php } else {
368 + $search_cpt = get_option( 'wpbottommenu_search_cpt', 'all' );
369 + if ( $search_cpt === 'all' || empty( $search_cpt ) ){
370 + ?><input type="hidden" name="post_type" value="all" /><?php
371 + } else {
372 + $search_cpt = explode(',', $search_cpt);
373 + foreach( $search_cpt as $cpt ){
374 + if ( !empty( $cpt ) ){
375 + ?><input type="hidden" name="post_type[]" value="<?php echo esc_attr( $cpt ); ?>" /><?php
376 + }
377 + }
378 + }
379 + } ?>
380 + <input type="search" class="search-field" placeholder="<?php if( get_option( 'wpbottommenu_placeholder_text', 'Search' ) ) echo get_option( 'wpbottommenu_placeholder_text', 'Search' ); else echo esc_attr_x( 'Search', 'wp-bottom-menu' ); ?>" value="<?php echo get_search_query(); ?>" name="s" />
381 + </form>
382 + </div>
383 + <?php endif;
149 384
150 - }
151 - // customizer api
152 - function wp_bottom_menu_customize_register( $wp_customize ) {
153 -
154 - // Add Theme Options Panel.
155 - $wp_customize->add_panel( 'wpbottommenu_panel',
156 - array(
157 - 'title' => esc_html__( 'WP Bottom Menu', 'wp-bottom-menu' ),
158 - 'priority' => 20
159 - )
160 - );
161 -
162 - //
163 - // Section: Settings
164 - //
385 + }
165 386
166 - $wp_customize->add_section( 'wpbottommenu_section_settings', array(
167 - 'title' => esc_html__( 'Settings', 'wp-bottom-menu' ),
168 - 'priority' => 120,
169 - 'panel' => 'wpbottommenu_panel',
170 - ));
387 + function translated_menu_title( $title ) {
388 + if ( function_exists('pll__') ) {
389 + return pll__( $title );
390 + }
171 391
172 - $wp_customize->add_setting( 'wpbottommenu_iconset', array(
173 - 'default' => 'fontawesome',
174 - 'type' => 'option',
175 - ) );
176 -
177 - $wp_customize->add_control( 'wpbottommenu_iconset', array(
178 - 'type' => 'select',
179 - 'section' => 'wpbottommenu_section_settings',
180 - 'label' => __( 'Select Icon Type', 'wp-bottom-menu' ),
181 - 'description' => __( '<u>Custom SVG:</u> Paste SVG Icon code.<br><u>FontAwesome:</u> Enable FontAwesome Library.', 'wp-bottom-menu' ),
182 - 'choices' => array(
183 - 'svg' => __( 'Custom SVG' ),
184 - 'fontawesome' => __( 'FontAwesome (v4.7)' ),
185 - ),
186 - ) );
392 + return $title;
393 + }
187 394
188 - $wp_customize->add_setting( 'wpbottommenu_display_px' , array(
189 - 'default' => '1024',
190 - 'type' => 'option',
191 - ));
192 -
193 - $wp_customize->add_control('wpbottommenu_display_px', array(
194 - 'label' => __( 'Active The Menu (px)', 'wp-bottom-menu' ),
195 - 'section' => 'wpbottommenu_section_settings',
196 - 'settings' => 'wpbottommenu_display_px',
197 - 'type' => 'number',
198 - ));
199 -
200 - $wp_customize->add_setting( 'wpbottommenu_display_always' , array(
201 - 'default' => false,
202 - 'type' => 'option',
203 - ));
204 -
205 - $wp_customize->add_control('wpbottommenu_display_always', array(
206 - 'label' => __( 'Active for any screen size?', 'wp-bottom-menu' ),
207 - 'section' => 'wpbottommenu_section_settings',
208 - 'settings' => 'wpbottommenu_display_always',
209 - 'type' => 'checkbox',
210 - ));
211 -
212 - $wp_customize->add_setting( 'wpbottommenu_zindex' , array(
213 - 'default' => '9999',
214 - 'type' => 'option',
215 - ));
216 -
217 - $wp_customize->add_control('wpbottommenu_zindex', array(
218 - 'label' => __( 'Menu Z-Index', 'wp-bottom-menu' ),
219 - 'description' => esc_html__( 'Recommended value: 9999', 'wp-bottom-menu' ),
220 - 'section' => 'wpbottommenu_section_settings',
221 - 'settings' => 'wpbottommenu_zindex',
222 - 'type' => 'number',
223 - ));
224 -
225 - //
226 - // Section: Customize
227 - //
395 + function display_condition(){
228 396
229 - $wp_customize->add_section('wpbottommenu_section_customize', array(
230 - 'title' => __('Customize', 'wp-bottom-menu'),
231 - 'priority' => 130,
232 - 'panel' => 'wpbottommenu_panel'
233 - ));
234 -
235 - $wp_customize->add_setting( 'wpbottommenu_placeholder_text' , array(
236 - 'default' => 'Search',
237 - 'type' => 'option',
238 - ));
239 -
240 - $wp_customize->add_control( 'wpbottommenu_placeholder_text', array(
241 - 'label' => __( 'Search Input Placeholder Text', 'wp-bottom-menu' ),
242 - 'section' => 'wpbottommenu_section_customize',
243 - 'settings' => 'wpbottommenu_placeholder_text',
244 - 'type' => 'text',
245 - ));
246 -
247 - $wp_customize->add_setting( 'wpbottommenu_fontsize' , array(
248 - 'default' => '12',
249 - 'type' => 'option',
250 - ));
251 -
252 - $wp_customize->add_control( 'wpbottommenu_fontsize', array(
253 - 'label' => __( 'Menu Font Size (px)', 'wp-bottom-menu' ),
254 - 'section' => 'wpbottommenu_section_customize',
255 - 'settings' => 'wpbottommenu_fontsize',
256 - 'type' => 'number',
257 - ));
258 -
259 - $wp_customize->add_setting( 'wpbottommenu_iconsize' , array(
260 - 'default' => '24',
261 - 'type' => 'option',
262 - ));
263 -
264 - $wp_customize->add_control( 'wpbottommenu_iconsize', array(
265 - 'label' => __( 'Menu Icon Size (px)', 'wp-bottom-menu' ),
266 - 'section' => 'wpbottommenu_section_customize',
267 - 'settings' => 'wpbottommenu_iconsize',
268 - 'type' => 'number',
269 - ));
270 -
271 - $wp_customize->add_setting( 'wpbottommenu_iconcolor', array(
272 - 'default' => '#000000',
273 - 'section' => 'wpbottommenu_section_customize',
274 - 'sanitize_callback' => 'sanitize_hex_color',
275 - 'type' => 'option'
276 - ));
277 -
278 - $wp_customize->add_setting( 'wpbottommenu_textcolor', array(
279 - 'default' => '#000000',
280 - 'section' => 'wpbottommenu_section_customize',
281 - 'sanitize_callback' => 'sanitize_hex_color',
282 - 'type' => 'option'
283 - ));
284 -
285 - $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_textcolor', array(
286 - 'label' => __( 'Menu Text Color', 'wp-bottom-menu' ),
287 - 'section' => 'wpbottommenu_section_customize',
288 - )));
289 -
290 - $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_iconcolor', array(
291 - 'label' => __( 'Menu Icon Color', 'wp-bottom-menu' ),
292 - 'section' => 'wpbottommenu_section_customize',
293 - )));
294 -
295 - $wp_customize->add_setting( 'wpbottommenu_bgcolor', array(
296 - 'default' => '#ffffff',
297 - 'section' => 'wpbottommenu_section_customize',
298 - 'sanitize_callback' => 'sanitize_hex_color',
299 - 'type' => 'option'
300 - ));
301 -
302 - $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_bgcolor', array(
303 - 'label' => __( 'Menu Background Color', 'wp-bottom-menu' ),
304 - 'section' => 'wpbottommenu_section_customize',
305 - )));
306 -
307 - $wp_customize->add_setting( 'wpbottommenu_disable_title' , array(
308 - 'default' => false,
309 - 'type' => 'option',
310 - ));
311 -
312 - $wp_customize->add_control('wpbottommenu_disable_title', array(
313 - 'label' => __( 'Disable title?', 'wp-bottom-menu' ),
314 - 'section' => 'wpbottommenu_section_customize',
315 - 'settings' => 'wpbottommenu_disable_title',
316 - 'type' => 'checkbox',
317 - ));
318 -
319 - $wp_customize->add_setting( 'wpbottommenu_cart_separator' , array(
320 - 'type' => 'option',
321 - ));
322 -
323 - $wp_customize->add_control('wpbottommenu_cart_separator', array(
324 - 'label' => __( 'Customize Cart Item', 'wp-bottom-menu' ),
325 - 'section' => 'wpbottommenu_section_customize',
326 - 'settings' => 'wpbottommenu_cart_separator',
327 - 'type' => 'hidden',
328 - ));
329 -
330 - $wp_customize->add_setting( 'wpbottommenu_show_cart_count' , array(
331 - 'default' => false,
332 - 'type' => 'option',
333 - ));
334 -
335 - $wp_customize->add_control('wpbottommenu_show_cart_count', array(
336 - 'label' => __( 'Show Cart Count', 'wp-bottom-menu' ),
337 - 'section' => 'wpbottommenu_section_customize',
338 - 'settings' => 'wpbottommenu_show_cart_count',
339 - 'type' => 'checkbox',
340 - ));
341 -
342 - $wp_customize->add_setting( 'wpbottommenu_cart_count_bgcolor', array(
343 - 'default' => '#ff0000',
344 - 'section' => 'wpbottommenu_section_customize',
345 - 'sanitize_callback' => 'sanitize_hex_color',
346 - 'type' => 'option'
347 - ));
348 -
349 - $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_cart_count_bgcolor', array(
350 - 'description' => __('Cart Count Background Color', 'wp-bottom-menu'),
351 - 'section' => 'wpbottommenu_section_customize',
352 - )));
353 -
354 - $wp_customize->add_setting( 'wpbottommenu_show_cart_total' , array(
355 - 'default' => false,
356 - 'type' => 'option',
357 - ));
358 -
359 - $wp_customize->add_control('wpbottommenu_show_cart_total', array(
360 - 'label' => __( 'Show Cart Total', 'wp-bottom-menu' ),
361 - 'description' => 'This option override cart menu title.',
362 - 'section' => 'wpbottommenu_section_customize',
363 - 'settings' => 'wpbottommenu_show_cart_total',
364 - 'type' => 'checkbox',
365 - ));
366 -
367 - //
368 - // Section: Menu Items
369 - //
397 + $condition = new \WPBottomMenu_Condition();
398 + return $condition->get_condition();
370 399
371 - $wp_customize->add_section('wpbottommenu_section_menuitems', array(
372 - 'title' => __('Menu Items', 'wp-bottom-menu'),
373 - 'priority' => 140,
374 - 'panel' => 'wpbottommenu_panel'
375 - ));
376 -
377 - $wp_customize->add_setting( 'customizer_repeater_wpbm', array(
378 - 'sanitize_callback' => 'customizer_repeater_sanitize',
379 - 'type' => 'option',
380 - 'default' => json_encode( array(
381 - array("choice" => "wpbm-homepage" ,"subtitle" => "fa-home", "title" => "Home", "id" => "customizer_repeater_1" ),
382 - array("choice" => "wpbm-woo-account" ,"subtitle" => "fa-user", "title" => "Account", "id" => "customizer_repeater_2" ),
383 - array("choice" => "wpbm-woo-cart" ,"subtitle" => "fa-shopping-cart", "title" => "Cart", "id" => "customizer_repeater_3" ),
384 - array("choice" => "wpbm-woo-search" ,"subtitle" => "fa-search", "title" => "Search", "id" => "customizer_repeater_4" ),
385 - ))
386 - ));
387 -
388 - $wp_customize->add_control( new Customizer_Repeater( $wp_customize, 'customizer_repeater_wpbm', array(
389 - 'label' => esc_html__('Menu Item','customizer-repeater'),
390 - 'section' => 'wpbottommenu_section_menuitems',
391 - 'customizer_repeater_title_control' => true,
392 - 'customizer_repeater_link_control' => true,
393 - 'customizer_repeater_subtitle_control' => true,
394 - )));
395 -
396 - $wp_customize->add_setting( 'wpbottommenu_howuseicon' , array(
397 - 'type' => 'option',
398 - ));
399 -
400 - $wp_customize->add_control( 'wpbottommenu_howuseicon', array(
401 - 'label' => __( 'How to use Icons?', 'wp-bottom-menu' ),
402 - 'description' => sprintf(
403 - __( '<u>For FontAwesome:</u> Add the names from (%1$s) to the "Icon" field.<br>Example:<code>fa-home</code><hr><u>For SVG Icons:</u> simply paste your SVG code in the "Icon" field. SVG Icon Library: %2$s<br>Enable to use SVG <code>Settings > Select Icon Type > Custom SVG</code> ', 'wp-bottom-menu' ),
404 - sprintf( '<a target="_blank" href="https://fontawesome.com/v4.7.0/icons/" rel="nofollow">%s</a>', esc_html__( 'FontAwesome', 'wp-bottom-menu' ) ),
405 - sprintf( '<a target="_blank" href="https://remixicon.com" rel="nofollow">%s</a>', esc_html__( 'Remix Icon', 'wp-bottom-menu' ) )
406 - ),
407 - 'section' => 'wpbottommenu_section_menuitems',
408 - 'settings' => 'wpbottommenu_howuseicon',
409 - 'type' => 'hidden',
410 - ));
411 -
412 -
413 400 }
414 401
415 402 // woocommerce cart fragment
416 403 function wp_bottom_menu_add_to_cart_fragment( $fragments ) {
@@ -425,55 +412,21 @@
425 412 array_unshift( $links_array, '<a href="' . admin_url( 'customize.php?autofocus[panel]=wpbottommenu_panel' ) . '">Settings</a>' );
426 413 }
427 414 return $links_array;
428 415 }
429 -
430 - // customize css
431 - function wpbottommenu_customize_css(){
432 - ?>
433 - <style type="text/css">
434 - <?php if (!get_option( 'wpbottommenu_display_always', false )): ?>
435 - @media (max-width: <?php echo get_option( 'wpbottommenu_display_px', '1024' ); ?>px){
436 - .wp-bottom-menu{
437 - display:flex;
438 - }
439 - .wp-bottom-menu-search-form-wrapper{
440 - display: block;
441 - }
442 - }
443 - <?php else: ?>
444 - .wp-bottom-menu{
445 - display:flex;
446 - }
447 - .wp-bottom-menu-search-form-wrapper{
448 - display: block;
449 - }
450 - <?php endif; ?>
451 -
452 - :root{
453 - --wpbottommenu-font-size: <?php echo get_option( 'wpbottommenu_fontsize', '12' );?>px;
454 - --wpbottommenu-icon-size: <?php echo get_option( 'wpbottommenu_iconsize', '24' );?>px;
455 - --wpbottommenu-text-color: <?php echo get_option( 'wpbottommenu_textcolor', '#000000' );?>;
456 - --wpbottommenu-icon-color: <?php echo get_option( 'wpbottommenu_iconcolor', '#000000' );?>;
457 - --wpbottommenu-bgcolor: <?php echo get_option( 'wpbottommenu_bgcolor', '#ffffff' );?>;
458 - --wpbottommenu-zindex: <?php echo get_option( 'wpbottommenu_zindex', '9999' ); ?>;
459 - --wpbottommenu-cart-count-bgcolor: <?php echo get_option( 'wpbottommenu_cart_count_bgcolor', '#ff0000' );?>;
460 - }
461 -
462 - </style>
463 - <?php
464 - }
465 416
466 417 } // class
418 +WPBottomMenu::instance();
467 419
468 420
469 -function wp_bottom_menu_pluginprefix_activate() {
421 +function wp_bottom_menu_plugin_activate() {
470 422 flush_rewrite_rules();
471 423 }
472 -register_activation_hook( __FILE__, 'wp_bottom_menu_pluginprefix_activate' );
424 +register_activation_hook( __FILE__, 'wp_bottom_menu_plugin_activate' );
473 425
474 -function wp_bottom_menu_pluginprefix_deactivate() {
426 +function wp_bottom_menu_plugin_deactivate() {
475 427 /* If you want all settings to be deleted when the plugin is deactive, activate this field.
428 + TODO : Add reset all settings option
476 429
477 430 delete_option(' customizer_repeater_wpbm' );
478 431 delete_option( 'wpbottommenu_display_px' );
479 432 delete_option( 'wpbottommenu_display_always' );
@@ -479,9 +432,11 @@
479 432 delete_option( 'wpbottommenu_display_always' );
480 433 delete_option( 'wpbottommenu_fontsize' );
481 434 delete_option( 'wpbottommenu_iconsize' );
482 435 delete_option( 'wpbottommenu_textcolor' );
436 + delete_option( 'wpbottommenu_htextcolor' );
483 437 delete_option( 'wpbottommenu_iconcolor' );
438 + delete_option( 'wpbottommenu_hiconcolor' );
484 439 delete_option( 'wpbottommenu_bgcolor' );
485 440 delete_option( 'wpbottommenu_zindex' );
486 441 delete_option( 'wpbottommenu_disable_title' );
487 442 delete_option( 'wpbottommenu_iconset' );
@@ -488,8 +443,10 @@
488 443 delete_option( 'wpbottommenu_placeholder_text' );
489 444 delete_option( 'wpbottommenu_show_cart_count' );
490 445 delete_option( 'wpbottommenu_show_cart_total' );
491 446 delete_option( 'wpbottommenu_cart_count_bgcolor' );
447 + delete_option( 'wpbottommenu_hide_pages' );
448 + delete_option( 'wpbottommenu_wrapper_padding' );
492 449 */
493 450 flush_rewrite_rules();
494 451 }
495 -register_deactivation_hook( __FILE__, 'wp_bottom_menu_pluginprefix_deactivate' );
452 +register_deactivation_hook( __FILE__, 'wp_bottom_menu_plugin_deactivate' );