| 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: 1.3 |
| 6 |
* Author: J4 |
| 7 |
* Author URI: https://j4cob.net |
| 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', '1.3' ); |
| 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 |
if ( class_exists( 'WPBottomMenu' ) ){ |
| 32 |
$wpbottommenu = new WPBottomMenu; |
| 33 |
} |
| 34 |
|
| 35 |
class WPBottomMenu{ |
| 36 |
|
| 37 |
public function __construct() { |
| 38 |
$this->includes(); |
| 39 |
$this->_hooks(); |
| 40 |
} |
| 41 |
|
| 42 |
function _hooks(){ |
| 43 |
add_action( 'wp_enqueue_scripts', array( $this, 'add_theme_scripts' ) ); |
| 44 |
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 |
add_filter( 'plugin_action_links', array($this, 'wp_bottom_menu_action_links'), 10, 2 ); |
| 48 |
if (class_exists( 'WooCommerce' )){ |
| 49 |
add_filter( 'woocommerce_add_to_cart_fragments', array($this, 'wp_bottom_menu_add_to_cart_fragment'), 10, 1 ); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
function includes(){ |
| 54 |
require_once(WP_BOTTOM_MENU_DIR_PATH.'inc/customizer-repeater/functions.php'); |
| 55 |
} |
| 56 |
|
| 57 |
// 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 ); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
// wp bottom menu |
| 67 |
function wp_bottom_menu() { |
| 68 |
|
| 69 |
|
| 70 |
// Check pages to hide |
| 71 |
if ( is_array( get_option( 'wpbottommenu_hide_pages' ) ) ){ |
| 72 |
foreach(get_option( 'wpbottommenu_hide_pages' ) as $page){ |
| 73 |
if ($page == get_the_ID()) |
| 74 |
return; |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
?> |
| 79 |
<div class="wp-bottom-menu" id="wp-bottom-menu"> |
| 80 |
|
| 81 |
<?php |
| 82 |
$customizer_repeater_wpbm = get_option('customizer_repeater_wpbm', json_encode( array( |
| 83 |
array("choice" => "wpbm-homepage" ,"subtitle" => "fa-home", "title" => "Home", "id" => "customizer_repeater_1" ), |
| 84 |
array("choice" => "wpbm-woo-account" ,"subtitle" => "fa-user", "title" => "Account", "id" => "customizer_repeater_2" ), |
| 85 |
array("choice" => "wpbm-woo-cart" ,"subtitle" => "fa-shopping-cart", "title" => "Cart", "id" => "customizer_repeater_3" ), |
| 86 |
array("choice" => "wpbm-woo-search" ,"subtitle" => "fa-search", "title" => "Search", "id" => "customizer_repeater_4" ), |
| 87 |
) ) ); |
| 88 |
/*This returns a json so we have to decode it*/ |
| 89 |
|
| 90 |
$customizer_repeater_wpbm_decoded = json_decode($customizer_repeater_wpbm); |
| 91 |
$wpbmsf; |
| 92 |
foreach($customizer_repeater_wpbm_decoded as $repeater_item){ |
| 93 |
|
| 94 |
if($repeater_item->choice == "wpbm-woo-search" or $repeater_item->choice == "wpbm-post-search"):?> |
| 95 |
<a href="javascript:void(0);" title="<?php echo $repeater_item->title; ?>" class="wp-bottom-menu-item wp-bottom-menu-search-form-trigger"> |
| 96 |
<?php else: ?> |
| 97 |
<a href="<?php |
| 98 |
switch($repeater_item->choice){ |
| 99 |
case "wpbm-homepage": |
| 100 |
echo esc_url( home_url() ); |
| 101 |
break; |
| 102 |
case "wpbm-woo-cart": |
| 103 |
if ( class_exists( 'WooCommerce' ) ) { |
| 104 |
echo esc_url( wc_get_page_permalink( 'cart' ) ); |
| 105 |
} else { |
| 106 |
echo '#'; |
| 107 |
} |
| 108 |
break; |
| 109 |
case "wpbm-woo-account": |
| 110 |
if ( class_exists( 'WooCommerce' ) ) { |
| 111 |
echo esc_url( wc_get_page_permalink( 'myaccount' ) ); |
| 112 |
} else { |
| 113 |
echo '#'; |
| 114 |
} |
| 115 |
break; |
| 116 |
|
| 117 |
default: |
| 118 |
echo esc_url( $repeater_item->link ); |
| 119 |
} |
| 120 |
?>" class="wp-bottom-menu-item"> |
| 121 |
<?php endif; ?> |
| 122 |
|
| 123 |
<div class="wp-bottom-menu-icon-wrapper"> |
| 124 |
<?php if(get_option( 'wpbottommenu_show_cart_count', false )): ?> |
| 125 |
<?php if ( class_exists( 'WooCommerce' ) and $repeater_item->choice == "wpbm-woo-cart") : ?> |
| 126 |
<div class="wp-bottom-menu-cart-count"><?php echo WC()->cart->get_cart_contents_count(); ?></div> |
| 127 |
<?php endif; ?> |
| 128 |
<?php endif; ?> |
| 129 |
|
| 130 |
<?php if(get_option( 'wpbottommenu_iconset', 'fontawesome' ) == 'fontawesome'): ?> |
| 131 |
<i class="wp-bottom-menu-item-icons fa <?php echo $repeater_item->subtitle; ?>"></i> |
| 132 |
<?php else: ?> |
| 133 |
<?php echo html_entity_decode($repeater_item->subtitle); ?> |
| 134 |
<?php endif; ?> |
| 135 |
</div> |
| 136 |
<?php if(!get_option( 'wpbottommenu_disable_title', false )): ?> |
| 137 |
<?php if(get_option( 'wpbottommenu_show_cart_total', false ) and $repeater_item->choice == "wpbm-woo-cart" and class_exists( 'WooCommerce' )): ?> |
| 138 |
<span class="wp-bottom-menu-cart-total"><?php WC()->cart->get_cart_total(); ?></span> |
| 139 |
<?php else: ?> |
| 140 |
<span><?php echo $repeater_item->title; ?></span> |
| 141 |
<?php endif; ?> |
| 142 |
<?php endif; ?> |
| 143 |
|
| 144 |
</a> |
| 145 |
<?php |
| 146 |
$wpbmsf = $repeater_item->choice; |
| 147 |
|
| 148 |
} |
| 149 |
?> |
| 150 |
</div> |
| 151 |
|
| 152 |
<div class="wp-bottom-menu-search-form-wrapper" id="wp-bottom-menu-search-form-wrapper"> |
| 153 |
<form role="search" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>" class="wp-bottom-menu-search-form"> |
| 154 |
<i class="fa fa-search"></i> |
| 155 |
<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"); ?>" /> |
| 156 |
<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" /> |
| 157 |
</form> |
| 158 |
</div><?php |
| 159 |
|
| 160 |
} |
| 161 |
// customizer api |
| 162 |
function wp_bottom_menu_customize_register( $wp_customize ) { |
| 163 |
|
| 164 |
if( !class_exists('Customize_Control_Multiple_Select') ){ |
| 165 |
require_once( WP_BOTTOM_MENU_DIR_PATH . 'inc/page-control/page-control.php'); |
| 166 |
} |
| 167 |
|
| 168 |
// Add Theme Options Panel. |
| 169 |
$wp_customize->add_panel( 'wpbottommenu_panel', |
| 170 |
array( |
| 171 |
'title' => esc_html__( 'WP Bottom Menu', 'wp-bottom-menu' ), |
| 172 |
'priority' => 20 |
| 173 |
) |
| 174 |
); |
| 175 |
|
| 176 |
// |
| 177 |
// Section: Settings |
| 178 |
// |
| 179 |
|
| 180 |
$wp_customize->add_section( 'wpbottommenu_section_settings', array( |
| 181 |
'title' => esc_html__( 'Settings', 'wp-bottom-menu' ), |
| 182 |
'priority' => 120, |
| 183 |
'panel' => 'wpbottommenu_panel', |
| 184 |
)); |
| 185 |
|
| 186 |
$wp_customize->add_setting( 'wpbottommenu_iconset', array( |
| 187 |
'default' => 'fontawesome', |
| 188 |
'type' => 'option', |
| 189 |
) ); |
| 190 |
|
| 191 |
$wp_customize->add_control( 'wpbottommenu_iconset', array( |
| 192 |
'type' => 'select', |
| 193 |
'section' => 'wpbottommenu_section_settings', |
| 194 |
'label' => __( 'Select Icon Type', 'wp-bottom-menu' ), |
| 195 |
'description' => __( '<u>Custom SVG:</u> Paste SVG Icon code.<br><u>FontAwesome:</u> Enable FontAwesome Library.', 'wp-bottom-menu' ), |
| 196 |
'choices' => array( |
| 197 |
'svg' => __( 'Custom SVG' ), |
| 198 |
'fontawesome' => __( 'FontAwesome (v4.7)' ), |
| 199 |
), |
| 200 |
) ); |
| 201 |
|
| 202 |
$wp_customize->add_setting( 'wpbottommenu_display_px' , array( |
| 203 |
'default' => '1024', |
| 204 |
'type' => 'option', |
| 205 |
)); |
| 206 |
|
| 207 |
$wp_customize->add_control('wpbottommenu_display_px', array( |
| 208 |
'label' => __( 'Active The Menu (px)', 'wp-bottom-menu' ), |
| 209 |
'section' => 'wpbottommenu_section_settings', |
| 210 |
'settings' => 'wpbottommenu_display_px', |
| 211 |
'type' => 'number', |
| 212 |
)); |
| 213 |
|
| 214 |
$wp_customize->add_setting( 'wpbottommenu_display_always' , array( |
| 215 |
'default' => false, |
| 216 |
'type' => 'option', |
| 217 |
)); |
| 218 |
|
| 219 |
$wp_customize->add_control('wpbottommenu_display_always', array( |
| 220 |
'label' => __( 'Active for any screen size?', 'wp-bottom-menu' ), |
| 221 |
'section' => 'wpbottommenu_section_settings', |
| 222 |
'settings' => 'wpbottommenu_display_always', |
| 223 |
'type' => 'checkbox', |
| 224 |
)); |
| 225 |
|
| 226 |
$wp_customize->add_setting( 'wpbottommenu_zindex' , array( |
| 227 |
'default' => '9999', |
| 228 |
'type' => 'option', |
| 229 |
)); |
| 230 |
|
| 231 |
$wp_customize->add_control('wpbottommenu_zindex', array( |
| 232 |
'label' => __( 'Menu Z-Index', 'wp-bottom-menu' ), |
| 233 |
'description' => esc_html__( 'Recommended value: 9999', 'wp-bottom-menu' ), |
| 234 |
'section' => 'wpbottommenu_section_settings', |
| 235 |
'settings' => 'wpbottommenu_zindex', |
| 236 |
'type' => 'number', |
| 237 |
)); |
| 238 |
|
| 239 |
// Hide Pages |
| 240 |
$wp_customize->add_setting( 'wpbottommenu_hide_pages', array( |
| 241 |
'type' => 'option', |
| 242 |
'capability' => 'edit_theme_options', |
| 243 |
'sanitize_callback' => 'wpbm_pages_sanitize' |
| 244 |
) ); |
| 245 |
|
| 246 |
$wp_customize->add_control( |
| 247 |
new Customize_Control_Multiple_Select( |
| 248 |
$wp_customize, |
| 249 |
'multiple_select_setting', |
| 250 |
array( |
| 251 |
'settings' => 'wpbottommenu_hide_pages', |
| 252 |
'label' => __('Hide Menu', 'wp-bottom-menu'), |
| 253 |
'description' => __('The menu will be hidden on the pages you have selected. You can choose multiple.', 'wp-bottom-menu'), |
| 254 |
'section' => 'wpbottommenu_section_settings', |
| 255 |
'type' => 'multiple-select', |
| 256 |
'choices' => wpbm_pages() |
| 257 |
) |
| 258 |
) |
| 259 |
); |
| 260 |
|
| 261 |
// |
| 262 |
// Section: Customize |
| 263 |
// |
| 264 |
|
| 265 |
$wp_customize->add_section('wpbottommenu_section_customize', array( |
| 266 |
'title' => __('Customize', 'wp-bottom-menu'), |
| 267 |
'priority' => 130, |
| 268 |
'panel' => 'wpbottommenu_panel' |
| 269 |
)); |
| 270 |
|
| 271 |
$wp_customize->add_setting( 'wpbottommenu_placeholder_text' , array( |
| 272 |
'default' => 'Search', |
| 273 |
'type' => 'option', |
| 274 |
)); |
| 275 |
|
| 276 |
$wp_customize->add_control( 'wpbottommenu_placeholder_text', array( |
| 277 |
'label' => __( 'Search Input Placeholder Text', 'wp-bottom-menu' ), |
| 278 |
'section' => 'wpbottommenu_section_customize', |
| 279 |
'settings' => 'wpbottommenu_placeholder_text', |
| 280 |
'type' => 'text', |
| 281 |
)); |
| 282 |
|
| 283 |
$wp_customize->add_setting( 'wpbottommenu_fontsize' , array( |
| 284 |
'default' => '12', |
| 285 |
'type' => 'option', |
| 286 |
)); |
| 287 |
|
| 288 |
$wp_customize->add_control( 'wpbottommenu_fontsize', array( |
| 289 |
'label' => __( 'Menu Font Size (px)', 'wp-bottom-menu' ), |
| 290 |
'section' => 'wpbottommenu_section_customize', |
| 291 |
'settings' => 'wpbottommenu_fontsize', |
| 292 |
'type' => 'number', |
| 293 |
)); |
| 294 |
|
| 295 |
$wp_customize->add_setting( 'wpbottommenu_iconsize' , array( |
| 296 |
'default' => '24', |
| 297 |
'type' => 'option', |
| 298 |
)); |
| 299 |
|
| 300 |
$wp_customize->add_control( 'wpbottommenu_iconsize', array( |
| 301 |
'label' => __( 'Menu Icon Size (px)', 'wp-bottom-menu' ), |
| 302 |
'section' => 'wpbottommenu_section_customize', |
| 303 |
'settings' => 'wpbottommenu_iconsize', |
| 304 |
'type' => 'number', |
| 305 |
)); |
| 306 |
|
| 307 |
$wp_customize->add_setting( 'wpbottommenu_wrapper_padding' , array( |
| 308 |
'default' => '10', |
| 309 |
'type' => 'option', |
| 310 |
)); |
| 311 |
|
| 312 |
$wp_customize->add_control( 'wpbottommenu_wrapper_padding', array( |
| 313 |
'label' => __( 'Menu Padding (px)', 'wp-bottom-menu' ), |
| 314 |
'section' => 'wpbottommenu_section_customize', |
| 315 |
'settings' => 'wpbottommenu_wrapper_padding', |
| 316 |
'type' => 'number', |
| 317 |
)); |
| 318 |
|
| 319 |
$wp_customize->add_setting( 'wpbottommenu_iconcolor', array( |
| 320 |
'default' => '#000000', |
| 321 |
'section' => 'wpbottommenu_section_customize', |
| 322 |
'sanitize_callback' => 'sanitize_hex_color', |
| 323 |
'type' => 'option' |
| 324 |
)); |
| 325 |
|
| 326 |
$wp_customize->add_setting( 'wpbottommenu_textcolor', array( |
| 327 |
'default' => '#000000', |
| 328 |
'section' => 'wpbottommenu_section_customize', |
| 329 |
'sanitize_callback' => 'sanitize_hex_color', |
| 330 |
'type' => 'option' |
| 331 |
)); |
| 332 |
|
| 333 |
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_textcolor', array( |
| 334 |
'label' => __( 'Menu Text Color', 'wp-bottom-menu' ), |
| 335 |
'section' => 'wpbottommenu_section_customize', |
| 336 |
))); |
| 337 |
|
| 338 |
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_iconcolor', array( |
| 339 |
'label' => __( 'Menu Icon Color', 'wp-bottom-menu' ), |
| 340 |
'section' => 'wpbottommenu_section_customize', |
| 341 |
))); |
| 342 |
|
| 343 |
$wp_customize->add_setting( 'wpbottommenu_bgcolor', array( |
| 344 |
'default' => '#ffffff', |
| 345 |
'section' => 'wpbottommenu_section_customize', |
| 346 |
'sanitize_callback' => 'sanitize_hex_color', |
| 347 |
'type' => 'option' |
| 348 |
)); |
| 349 |
|
| 350 |
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_bgcolor', array( |
| 351 |
'label' => __( 'Menu Background Color', 'wp-bottom-menu' ), |
| 352 |
'section' => 'wpbottommenu_section_customize', |
| 353 |
))); |
| 354 |
|
| 355 |
$wp_customize->add_setting( 'wpbottommenu_disable_title' , array( |
| 356 |
'default' => false, |
| 357 |
'type' => 'option', |
| 358 |
)); |
| 359 |
|
| 360 |
$wp_customize->add_control('wpbottommenu_disable_title', array( |
| 361 |
'label' => __( 'Disable title?', 'wp-bottom-menu' ), |
| 362 |
'section' => 'wpbottommenu_section_customize', |
| 363 |
'settings' => 'wpbottommenu_disable_title', |
| 364 |
'type' => 'checkbox', |
| 365 |
)); |
| 366 |
|
| 367 |
$wp_customize->add_setting( 'wpbottommenu_cart_separator' , array( |
| 368 |
'type' => 'option', |
| 369 |
)); |
| 370 |
|
| 371 |
$wp_customize->add_control('wpbottommenu_cart_separator', array( |
| 372 |
'label' => __( 'Customize Cart Item', 'wp-bottom-menu' ), |
| 373 |
'section' => 'wpbottommenu_section_customize', |
| 374 |
'settings' => 'wpbottommenu_cart_separator', |
| 375 |
'type' => 'hidden', |
| 376 |
)); |
| 377 |
|
| 378 |
$wp_customize->add_setting( 'wpbottommenu_show_cart_count' , array( |
| 379 |
'default' => false, |
| 380 |
'type' => 'option', |
| 381 |
)); |
| 382 |
|
| 383 |
$wp_customize->add_control('wpbottommenu_show_cart_count', array( |
| 384 |
'label' => __( 'Show Cart Count', 'wp-bottom-menu' ), |
| 385 |
'section' => 'wpbottommenu_section_customize', |
| 386 |
'settings' => 'wpbottommenu_show_cart_count', |
| 387 |
'type' => 'checkbox', |
| 388 |
)); |
| 389 |
|
| 390 |
$wp_customize->add_setting( 'wpbottommenu_cart_count_bgcolor', array( |
| 391 |
'default' => '#ff0000', |
| 392 |
'section' => 'wpbottommenu_section_customize', |
| 393 |
'sanitize_callback' => 'sanitize_hex_color', |
| 394 |
'type' => 'option' |
| 395 |
)); |
| 396 |
|
| 397 |
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_cart_count_bgcolor', array( |
| 398 |
'description' => __('Cart Count Background Color', 'wp-bottom-menu'), |
| 399 |
'section' => 'wpbottommenu_section_customize', |
| 400 |
))); |
| 401 |
|
| 402 |
$wp_customize->add_setting( 'wpbottommenu_show_cart_total' , array( |
| 403 |
'default' => false, |
| 404 |
'type' => 'option', |
| 405 |
)); |
| 406 |
|
| 407 |
$wp_customize->add_control('wpbottommenu_show_cart_total', array( |
| 408 |
'label' => __( 'Show Cart Total', 'wp-bottom-menu' ), |
| 409 |
'description' => 'This option override cart menu title.', |
| 410 |
'section' => 'wpbottommenu_section_customize', |
| 411 |
'settings' => 'wpbottommenu_show_cart_total', |
| 412 |
'type' => 'checkbox', |
| 413 |
)); |
| 414 |
|
| 415 |
// |
| 416 |
// Section: Menu Items |
| 417 |
// |
| 418 |
|
| 419 |
$wp_customize->add_section('wpbottommenu_section_menuitems', array( |
| 420 |
'title' => __('Menu Items', 'wp-bottom-menu'), |
| 421 |
'priority' => 140, |
| 422 |
'panel' => 'wpbottommenu_panel' |
| 423 |
)); |
| 424 |
|
| 425 |
$wp_customize->add_setting( 'customizer_repeater_wpbm', array( |
| 426 |
'sanitize_callback' => 'customizer_repeater_sanitize', |
| 427 |
'type' => 'option', |
| 428 |
'default' => json_encode( array( |
| 429 |
array("choice" => "wpbm-homepage" ,"subtitle" => "fa-home", "title" => "Home", "id" => "customizer_repeater_1" ), |
| 430 |
array("choice" => "wpbm-woo-account" ,"subtitle" => "fa-user", "title" => "Account", "id" => "customizer_repeater_2" ), |
| 431 |
array("choice" => "wpbm-woo-cart" ,"subtitle" => "fa-shopping-cart", "title" => "Cart", "id" => "customizer_repeater_3" ), |
| 432 |
array("choice" => "wpbm-woo-search" ,"subtitle" => "fa-search", "title" => "Search", "id" => "customizer_repeater_4" ), |
| 433 |
)) |
| 434 |
)); |
| 435 |
|
| 436 |
$wp_customize->add_control( new Customizer_Repeater( $wp_customize, 'customizer_repeater_wpbm', array( |
| 437 |
'label' => esc_html__('Menu Item','customizer-repeater'), |
| 438 |
'section' => 'wpbottommenu_section_menuitems', |
| 439 |
'customizer_repeater_title_control' => true, |
| 440 |
'customizer_repeater_link_control' => true, |
| 441 |
'customizer_repeater_subtitle_control' => true, |
| 442 |
))); |
| 443 |
|
| 444 |
$wp_customize->add_setting( 'wpbottommenu_howuseicon' , array( |
| 445 |
'type' => 'option', |
| 446 |
)); |
| 447 |
|
| 448 |
$wp_customize->add_control( 'wpbottommenu_howuseicon', array( |
| 449 |
'label' => __( 'How to use Icons?', 'wp-bottom-menu' ), |
| 450 |
'description' => sprintf( |
| 451 |
__( '<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' ), |
| 452 |
sprintf( '<a target="_blank" href="https://fontawesome.com/v4.7.0/icons/" rel="nofollow">%s</a>', esc_html__( 'FontAwesome', 'wp-bottom-menu' ) ), |
| 453 |
sprintf( '<a target="_blank" href="https://remixicon.com" rel="nofollow">%s</a>', esc_html__( 'Remix Icon', 'wp-bottom-menu' ) ) |
| 454 |
), |
| 455 |
'section' => 'wpbottommenu_section_menuitems', |
| 456 |
'settings' => 'wpbottommenu_howuseicon', |
| 457 |
'type' => 'hidden', |
| 458 |
)); |
| 459 |
|
| 460 |
|
| 461 |
} |
| 462 |
|
| 463 |
// woocommerce cart fragment |
| 464 |
function wp_bottom_menu_add_to_cart_fragment( $fragments ) { |
| 465 |
$fragments['div.wp-bottom-menu-cart-count'] = '<div class="wp-bottom-menu-cart-count">' . WC()->cart->get_cart_contents_count() . '</div>'; |
| 466 |
$fragments['span.wp-bottom-menu-cart-total'] = '<span class="wp-bottom-menu-cart-total">' . WC()->cart->get_cart_total() . '</span>'; |
| 467 |
return $fragments; |
| 468 |
} |
| 469 |
|
| 470 |
// plugin action links |
| 471 |
function wp_bottom_menu_action_links( $links_array, $plugin_file_name ){ |
| 472 |
if( strpos( $plugin_file_name, basename(__FILE__) ) ) { |
| 473 |
array_unshift( $links_array, '<a href="' . admin_url( 'customize.php?autofocus[panel]=wpbottommenu_panel' ) . '">Settings</a>' ); |
| 474 |
} |
| 475 |
return $links_array; |
| 476 |
} |
| 477 |
|
| 478 |
// customize css |
| 479 |
function wpbottommenu_customize_css(){ |
| 480 |
?> |
| 481 |
<style type="text/css"> |
| 482 |
<?php if (!get_option( 'wpbottommenu_display_always', false )): ?> |
| 483 |
@media (max-width: <?php echo get_option( 'wpbottommenu_display_px', '1024' ); ?>px){ |
| 484 |
.wp-bottom-menu{ |
| 485 |
display:flex; |
| 486 |
} |
| 487 |
.wp-bottom-menu-search-form-wrapper{ |
| 488 |
display: block; |
| 489 |
} |
| 490 |
} |
| 491 |
<?php else: ?> |
| 492 |
.wp-bottom-menu{ |
| 493 |
display:flex; |
| 494 |
} |
| 495 |
.wp-bottom-menu-search-form-wrapper{ |
| 496 |
display: block; |
| 497 |
} |
| 498 |
<?php endif; ?> |
| 499 |
|
| 500 |
:root{ |
| 501 |
--wpbottommenu-font-size: <?php echo get_option( 'wpbottommenu_fontsize', '12' );?>px; |
| 502 |
--wpbottommenu-icon-size: <?php echo get_option( 'wpbottommenu_iconsize', '24' );?>px; |
| 503 |
--wpbottommenu-text-color: <?php echo get_option( 'wpbottommenu_textcolor', '#000000' );?>; |
| 504 |
--wpbottommenu-icon-color: <?php echo get_option( 'wpbottommenu_iconcolor', '#000000' );?>; |
| 505 |
--wpbottommenu-bgcolor: <?php echo get_option( 'wpbottommenu_bgcolor', '#ffffff' );?>; |
| 506 |
--wpbottommenu-zindex: <?php echo get_option( 'wpbottommenu_zindex', '9999' ); ?>; |
| 507 |
--wpbottommenu-cart-count-bgcolor: <?php echo get_option( 'wpbottommenu_cart_count_bgcolor', '#ff0000' );?>; |
| 508 |
--wpbottommenu-wrapper-padding: <?php echo get_option( 'wpbottommenu_wrapper_padding', '10' );?>px 0; |
| 509 |
} |
| 510 |
|
| 511 |
</style> |
| 512 |
<?php |
| 513 |
} |
| 514 |
|
| 515 |
} // class |
| 516 |
|
| 517 |
|
| 518 |
function wp_bottom_menu_pluginprefix_activate() { |
| 519 |
flush_rewrite_rules(); |
| 520 |
} |
| 521 |
register_activation_hook( __FILE__, 'wp_bottom_menu_pluginprefix_activate' ); |
| 522 |
|
| 523 |
function wp_bottom_menu_pluginprefix_deactivate() { |
| 524 |
/* If you want all settings to be deleted when the plugin is deactive, activate this field. |
| 525 |
|
| 526 |
delete_option(' customizer_repeater_wpbm' ); |
| 527 |
delete_option( 'wpbottommenu_display_px' ); |
| 528 |
delete_option( 'wpbottommenu_display_always' ); |
| 529 |
delete_option( 'wpbottommenu_fontsize' ); |
| 530 |
delete_option( 'wpbottommenu_iconsize' ); |
| 531 |
delete_option( 'wpbottommenu_textcolor' ); |
| 532 |
delete_option( 'wpbottommenu_iconcolor' ); |
| 533 |
delete_option( 'wpbottommenu_bgcolor' ); |
| 534 |
delete_option( 'wpbottommenu_zindex' ); |
| 535 |
delete_option( 'wpbottommenu_disable_title' ); |
| 536 |
delete_option( 'wpbottommenu_iconset' ); |
| 537 |
delete_option( 'wpbottommenu_placeholder_text' ); |
| 538 |
delete_option( 'wpbottommenu_show_cart_count' ); |
| 539 |
delete_option( 'wpbottommenu_show_cart_total' ); |
| 540 |
delete_option( 'wpbottommenu_cart_count_bgcolor' ); |
| 541 |
delete_option( 'wpbottommenu_hide_pages' ); |
| 542 |
delete_option( 'wpbottommenu_wrapper_padding' ); |
| 543 |
*/ |
| 544 |
flush_rewrite_rules(); |
| 545 |
} |
| 546 |
register_deactivation_hook( __FILE__, 'wp_bottom_menu_pluginprefix_deactivate' ); |