| 1 |
<?php |
| 2 |
|
| 3 |
defined ( 'ABSPATH' ) || die (); |
| 4 |
|
| 5 |
class WPBottomMenu_Customizer{ |
| 6 |
|
| 7 |
public static function init(){ |
| 8 |
|
| 9 |
add_action( 'customize_register', [ __CLASS__, 'register' ] ); |
| 10 |
add_action( 'wp_footer', [ __CLASS__, 'wpbottommenu_customize_css' ] ); |
| 11 |
|
| 12 |
} |
| 13 |
|
| 14 |
/** |
| 15 |
* Register customizer options |
| 16 |
* |
| 17 |
* @param WP_Customize_Manager $wp_customize |
| 18 |
* @since 1.0.0 |
| 19 |
* |
| 20 |
*/ |
| 21 |
public static function register( $wp_customize ) { |
| 22 |
|
| 23 |
if( !class_exists('Customize_Control_Multiple_Select') ){ |
| 24 |
require_once( WP_BOTTOM_MENU_DIR_PATH . 'inc/multiple-select/multiple-select.php'); |
| 25 |
} |
| 26 |
|
| 27 |
// Add Theme Options Panel. |
| 28 |
$wp_customize->add_panel( 'wpbottommenu_panel', |
| 29 |
array( |
| 30 |
'title' => esc_html__( 'WP Bottom Menu', 'wp-bottom-menu' ), |
| 31 |
'priority' => 20 |
| 32 |
) |
| 33 |
); |
| 34 |
|
| 35 |
// |
| 36 |
// Section: Settings |
| 37 |
// |
| 38 |
|
| 39 |
$wp_customize->add_section( 'wpbottommenu_section_settings', array( |
| 40 |
'title' => esc_html__( 'Settings', 'wp-bottom-menu' ), |
| 41 |
'priority' => 120, |
| 42 |
'panel' => 'wpbottommenu_panel', |
| 43 |
)); |
| 44 |
|
| 45 |
$wp_customize->add_setting( 'wpbottommenu_iconset', array( |
| 46 |
'default' => 'fontawesome', |
| 47 |
'type' => 'option', |
| 48 |
) ); |
| 49 |
|
| 50 |
$wp_customize->add_control( 'wpbottommenu_iconset', array( |
| 51 |
'type' => 'select', |
| 52 |
'section' => 'wpbottommenu_section_settings', |
| 53 |
'label' => __( 'Select Icon Type', 'wp-bottom-menu' ), |
| 54 |
'description' => __( '<u>Custom SVG:</u> Paste SVG Icon code.<br><u>FontAwesome:</u> Enable FontAwesome Library.', 'wp-bottom-menu' ), |
| 55 |
'choices' => array( |
| 56 |
'svg' => __( 'Custom SVG' ), |
| 57 |
'fontawesome' => __( 'FontAwesome (v4.7)' ), |
| 58 |
'fontawesome2' => __( 'FontAwesome (v6.1.1)' ), |
| 59 |
), |
| 60 |
) ); |
| 61 |
|
| 62 |
$wp_customize->add_setting( 'wpbottommenu_display_px' , array( |
| 63 |
'default' => '1024', |
| 64 |
'type' => 'option', |
| 65 |
)); |
| 66 |
|
| 67 |
$wp_customize->add_control('wpbottommenu_display_px', array( |
| 68 |
'label' => __( 'Active The Menu (px)', 'wp-bottom-menu' ), |
| 69 |
'section' => 'wpbottommenu_section_settings', |
| 70 |
'settings' => 'wpbottommenu_display_px', |
| 71 |
'type' => 'number', |
| 72 |
)); |
| 73 |
|
| 74 |
$wp_customize->add_setting( 'wpbottommenu_display_always' , array( |
| 75 |
'default' => false, |
| 76 |
'type' => 'option', |
| 77 |
)); |
| 78 |
|
| 79 |
$wp_customize->add_control('wpbottommenu_display_always', array( |
| 80 |
'label' => __( 'Active for any screen size?', 'wp-bottom-menu' ), |
| 81 |
'section' => 'wpbottommenu_section_settings', |
| 82 |
'settings' => 'wpbottommenu_display_always', |
| 83 |
'type' => 'checkbox', |
| 84 |
)); |
| 85 |
|
| 86 |
$wp_customize->add_setting( 'wpbottommenu_target' , array( |
| 87 |
'default' => false, |
| 88 |
'type' => 'option', |
| 89 |
)); |
| 90 |
|
| 91 |
$wp_customize->add_control('wpbottommenu_target', array( |
| 92 |
'label' => __( 'Open links in a new tab', 'wp-bottom-menu' ), |
| 93 |
'section' => 'wpbottommenu_section_settings', |
| 94 |
'settings' => 'wpbottommenu_target', |
| 95 |
'type' => 'checkbox', |
| 96 |
)); |
| 97 |
|
| 98 |
$wp_customize->add_setting( 'wpbottommenu_zindex' , array( |
| 99 |
'default' => '9999', |
| 100 |
'type' => 'option', |
| 101 |
)); |
| 102 |
|
| 103 |
$wp_customize->add_control('wpbottommenu_zindex', array( |
| 104 |
'label' => __( 'Menu Z-Index', 'wp-bottom-menu' ), |
| 105 |
'description' => esc_html__( 'Recommended value: 9999', 'wp-bottom-menu' ), |
| 106 |
'section' => 'wpbottommenu_section_settings', |
| 107 |
'settings' => 'wpbottommenu_zindex', |
| 108 |
'type' => 'number', |
| 109 |
)); |
| 110 |
|
| 111 |
$wp_customize->add_setting( 'wpbottommenu_search_cpt' , array( |
| 112 |
'default' => 'all', |
| 113 |
'type' => 'option', |
| 114 |
)); |
| 115 |
|
| 116 |
$wp_customize->add_control('wpbottommenu_search_cpt', array( |
| 117 |
'label' => __( 'Custom search post types', 'wp-bottom-menu' ), |
| 118 |
'description' => esc_html__( 'Add your post type with a comma. Example: post,product,my-post-type', 'wp-bottom-menu' ), |
| 119 |
'section' => 'wpbottommenu_section_settings', |
| 120 |
'settings' => 'wpbottommenu_search_cpt', |
| 121 |
'type' => 'text', |
| 122 |
'input_attrs' => array( |
| 123 |
'placeholder' => 'all', |
| 124 |
), |
| 125 |
)); |
| 126 |
|
| 127 |
// |
| 128 |
// Section: Conditions |
| 129 |
// |
| 130 |
|
| 131 |
$wp_customize->add_section( 'wpbottommenu_section_conditions', array( |
| 132 |
'title' => esc_html__( 'Conditions', 'wp-bottom-menu' ), |
| 133 |
'priority' => 120, |
| 134 |
'panel' => 'wpbottommenu_panel', |
| 135 |
)); |
| 136 |
|
| 137 |
$wp_customize->add_setting( 'wpbottommenu_condition_reverse' , array( |
| 138 |
'default' => false, |
| 139 |
'type' => 'option', |
| 140 |
)); |
| 141 |
|
| 142 |
$wp_customize->add_control('wpbottommenu_condition_reverse', array( |
| 143 |
'label' => __( 'Reverse the condition?', 'wp-bottom-menu' ), |
| 144 |
'description' => __( 'Currently the WP Bottom Menu will appear under the conditions you selected. Check this if you want it to be hidden under the conditions you choose.', 'wp-bottom-menu' ), |
| 145 |
'section' => 'wpbottommenu_section_conditions', |
| 146 |
'settings' => 'wpbottommenu_condition_reverse', |
| 147 |
'type' => 'checkbox', |
| 148 |
)); |
| 149 |
|
| 150 |
$wp_customize->add_setting( 'wpbottommenu_condition', array( |
| 151 |
'default' => 'entire', |
| 152 |
'type' => 'option', |
| 153 |
) ); |
| 154 |
|
| 155 |
$wp_customize->add_control( 'wpbottommenu_condition', array( |
| 156 |
'type' => 'select', |
| 157 |
'section' => 'wpbottommenu_section_conditions', |
| 158 |
'label' => __( 'Select the Archive', 'wp-bottom-menu' ), |
| 159 |
'description' => __( 'Select a condition' ), |
| 160 |
'choices' => array( |
| 161 |
'entire' => __( 'Entire Site' ), |
| 162 |
'archives' => __( 'Archives' ), |
| 163 |
'singular' => __( 'Singular' ), |
| 164 |
'woocommerce' => __( 'Woocommerce' ), |
| 165 |
), |
| 166 |
) ); |
| 167 |
|
| 168 |
$wp_customize->add_setting( 'wpbottommenu_archives_condition', array( |
| 169 |
'default' => 'all', |
| 170 |
'type' => 'option', |
| 171 |
) ); |
| 172 |
|
| 173 |
$wp_customize->add_control( 'wpbottommenu_archives_condition', array( |
| 174 |
'type' => 'select', |
| 175 |
'section' => 'wpbottommenu_section_conditions', |
| 176 |
'label' => __( 'Archive Elements', 'wp-bottom-menu' ), |
| 177 |
'description' => __( 'Select a condition' ), |
| 178 |
'choices' => array( |
| 179 |
'all' => __( 'All' ), |
| 180 |
'author' => __( 'Author' ), |
| 181 |
'cats' => __( 'Category' ), |
| 182 |
'tags' => __( 'Tags' ), |
| 183 |
), |
| 184 |
) ); |
| 185 |
|
| 186 |
$wp_customize->add_setting( 'wpbottommenu_woocommerce_condition', array( |
| 187 |
'default' => 'all', |
| 188 |
'type' => 'option', |
| 189 |
) ); |
| 190 |
|
| 191 |
$wp_customize->add_control( 'wpbottommenu_woocommerce_condition', array( |
| 192 |
'type' => 'select', |
| 193 |
'section' => 'wpbottommenu_section_conditions', |
| 194 |
'label' => __( 'WooCommerce Elements', 'wp-bottom-menu' ), |
| 195 |
'description' => __( 'Select a condition' ), |
| 196 |
'choices' => array( |
| 197 |
'all' => __( 'All' ), |
| 198 |
'archive' => __( 'Product Archives' ), |
| 199 |
'shop' => __( 'Shop Page' ), |
| 200 |
'cats' => __( 'Product Categories' ), |
| 201 |
'tags' => __( 'Product Tags' ), |
| 202 |
'products' => __( 'Single Products' ), |
| 203 |
'product' => __( 'Single Product' ), |
| 204 |
), |
| 205 |
) ); |
| 206 |
|
| 207 |
$wp_customize->add_setting( 'wpbottommenu_singular_condition', array( |
| 208 |
'default' => 'all', |
| 209 |
'type' => 'option', |
| 210 |
) ); |
| 211 |
|
| 212 |
$wp_customize->add_control( 'wpbottommenu_singular_condition', array( |
| 213 |
'type' => 'select', |
| 214 |
'section' => 'wpbottommenu_section_conditions', |
| 215 |
'label' => __( 'Singular Elements', 'wp-bottom-menu' ), |
| 216 |
'description' => __( 'Select a condition' ), |
| 217 |
'choices' => array( |
| 218 |
'all' => __( 'All' ), |
| 219 |
'front-page' => __( 'Front Page' ), |
| 220 |
'post' => __( 'Post' ), |
| 221 |
'pages' => __( 'Pages' ), |
| 222 |
'search' => __( 'Seach Results' ), |
| 223 |
'page-404' => __( '404 Page' ), |
| 224 |
), |
| 225 |
) ); |
| 226 |
|
| 227 |
$wp_customize->add_setting( 'wpbottommenu_singular_page_condition', array( |
| 228 |
//'sanitize_callback' => 'wpbottommenu_sanitize_dropdown_pages', |
| 229 |
'type' => 'option', |
| 230 |
) ); |
| 231 |
|
| 232 |
$wp_customize->add_control( new Customize_Control_Multiple_Select( $wp_customize, 'wpbottommenu_singular_page_condition', array( |
| 233 |
'type' => 'multiple-select', |
| 234 |
'section' => 'wpbottommenu_section_conditions', |
| 235 |
'label' => __( 'Single Pages', 'wp-bottom-menu' ), |
| 236 |
'description' => __( 'Select a page' ), |
| 237 |
'choices' => self::get_available_custom_post( 'page' ), |
| 238 |
) ) ); |
| 239 |
|
| 240 |
$wp_customize->add_setting( 'wpbottommenu_singular_post_condition', array( |
| 241 |
'default' => 'all', |
| 242 |
'type' => 'option', |
| 243 |
) ); |
| 244 |
|
| 245 |
$wp_customize->add_control( new Customize_Control_Multiple_Select( $wp_customize, 'wpbottommenu_singular_post_condition', array( |
| 246 |
'type' => 'multiple-select', |
| 247 |
'section' => 'wpbottommenu_section_conditions', |
| 248 |
'label' => __( 'Single Post', 'wp-bottom-menu' ), |
| 249 |
'description' => __( 'Select a condition' ), |
| 250 |
'choices' => self::get_available_custom_post( 'post' ), |
| 251 |
) ) ); |
| 252 |
|
| 253 |
$wp_customize->add_setting( 'wpbottommenu_singular_product_condition', array( |
| 254 |
'default' => 'all', |
| 255 |
'type' => 'option', |
| 256 |
) ); |
| 257 |
|
| 258 |
$wp_customize->add_control( new Customize_Control_Multiple_Select( $wp_customize, 'wpbottommenu_singular_product_condition', array( |
| 259 |
'type' => 'multiple-select', |
| 260 |
'section' => 'wpbottommenu_section_conditions', |
| 261 |
'label' => __( 'Single Product', 'wp-bottom-menu' ), |
| 262 |
'description' => __( 'Select products' ), |
| 263 |
'choices' => self::get_available_custom_post( 'product' ), |
| 264 |
) ) ); |
| 265 |
|
| 266 |
// User role condition |
| 267 |
$wp_customize->add_setting( 'wpbottommenu_user_role_condition', array( |
| 268 |
'default' => 'all', |
| 269 |
'type' => 'option', |
| 270 |
) ); |
| 271 |
|
| 272 |
$wp_customize->add_control( new Customize_Control_Multiple_Select( $wp_customize, 'wpbottommenu_user_role_condition', array( |
| 273 |
'type' => 'multiple-select', |
| 274 |
'section' => 'wpbottommenu_section_conditions', |
| 275 |
'label' => __( 'Select User Roles Condition', 'wp-bottom-menu' ), |
| 276 |
'description' => __( 'WP Bottom Menu will only appear in the user roles you select.' ), |
| 277 |
'choices' => wpbm_get_user_roles() |
| 278 |
) ) ); |
| 279 |
|
| 280 |
// |
| 281 |
// Section: Customize |
| 282 |
// |
| 283 |
|
| 284 |
$wp_customize->add_section('wpbottommenu_section_customize', array( |
| 285 |
'title' => __('Customize', 'wp-bottom-menu'), |
| 286 |
'priority' => 130, |
| 287 |
'panel' => 'wpbottommenu_panel' |
| 288 |
)); |
| 289 |
|
| 290 |
$wp_customize->add_setting( 'wpbottommenu_placeholder_text' , array( |
| 291 |
'default' => 'Search', |
| 292 |
'type' => 'option', |
| 293 |
)); |
| 294 |
|
| 295 |
$wp_customize->add_control( 'wpbottommenu_placeholder_text', array( |
| 296 |
'label' => __( 'Search Input Placeholder Text', 'wp-bottom-menu' ), |
| 297 |
'section' => 'wpbottommenu_section_customize', |
| 298 |
'settings' => 'wpbottommenu_placeholder_text', |
| 299 |
'type' => 'text', |
| 300 |
)); |
| 301 |
|
| 302 |
$wp_customize->add_setting( 'wpbottommenu_fontsize' , array( |
| 303 |
'default' => '12', |
| 304 |
'type' => 'option', |
| 305 |
)); |
| 306 |
|
| 307 |
$wp_customize->add_control( 'wpbottommenu_fontsize', array( |
| 308 |
'label' => __( 'Menu Font Size (px)', 'wp-bottom-menu' ), |
| 309 |
'section' => 'wpbottommenu_section_customize', |
| 310 |
'settings' => 'wpbottommenu_fontsize', |
| 311 |
'type' => 'number', |
| 312 |
)); |
| 313 |
|
| 314 |
$wp_customize->add_setting( 'wpbottommenu_iconsize' , array( |
| 315 |
'default' => '24', |
| 316 |
'type' => 'option', |
| 317 |
)); |
| 318 |
|
| 319 |
$wp_customize->add_control( 'wpbottommenu_iconsize', array( |
| 320 |
'label' => __( 'Menu Icon Size (px)', 'wp-bottom-menu' ), |
| 321 |
'section' => 'wpbottommenu_section_customize', |
| 322 |
'settings' => 'wpbottommenu_iconsize', |
| 323 |
'type' => 'number', |
| 324 |
)); |
| 325 |
|
| 326 |
$wp_customize->add_setting( 'wpbottommenu_wrapper_padding' , array( |
| 327 |
'default' => '10', |
| 328 |
'type' => 'option', |
| 329 |
)); |
| 330 |
|
| 331 |
$wp_customize->add_control( 'wpbottommenu_wrapper_padding', array( |
| 332 |
'label' => __( 'Menu Padding (px)', 'wp-bottom-menu' ), |
| 333 |
'section' => 'wpbottommenu_section_customize', |
| 334 |
'settings' => 'wpbottommenu_wrapper_padding', |
| 335 |
'type' => 'number', |
| 336 |
)); |
| 337 |
|
| 338 |
$wp_customize->add_setting( 'wpbottommenu_textcolor', array( |
| 339 |
'default' => '#555555', |
| 340 |
'section' => 'wpbottommenu_section_customize', |
| 341 |
'sanitize_callback' => 'sanitize_hex_color', |
| 342 |
'type' => 'option' |
| 343 |
)); |
| 344 |
|
| 345 |
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_textcolor', array( |
| 346 |
'label' => __( 'Menu Text Color', 'wp-bottom-menu' ), |
| 347 |
'section' => 'wpbottommenu_section_customize', |
| 348 |
))); |
| 349 |
|
| 350 |
$wp_customize->add_setting( 'wpbottommenu_htextcolor', array( |
| 351 |
'default' => '#000000', |
| 352 |
'section' => 'wpbottommenu_section_customize', |
| 353 |
'sanitize_callback' => 'sanitize_hex_color', |
| 354 |
'type' => 'option' |
| 355 |
)); |
| 356 |
|
| 357 |
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_htextcolor', array( |
| 358 |
'label' => __( 'Menu Hover/Active Text Color', 'wp-bottom-menu' ), |
| 359 |
'section' => 'wpbottommenu_section_customize', |
| 360 |
))); |
| 361 |
|
| 362 |
$wp_customize->add_setting( 'wpbottommenu_iconcolor', array( |
| 363 |
'default' => '#555555', |
| 364 |
'section' => 'wpbottommenu_section_customize', |
| 365 |
'sanitize_callback' => 'sanitize_hex_color', |
| 366 |
'type' => 'option' |
| 367 |
)); |
| 368 |
|
| 369 |
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_iconcolor', array( |
| 370 |
'label' => __( 'Menu Icon Color', 'wp-bottom-menu' ), |
| 371 |
'section' => 'wpbottommenu_section_customize', |
| 372 |
))); |
| 373 |
|
| 374 |
$wp_customize->add_setting( 'wpbottommenu_hiconcolor', array( |
| 375 |
'default' => '#000000', |
| 376 |
'section' => 'wpbottommenu_section_customize', |
| 377 |
'sanitize_callback' => 'sanitize_hex_color', |
| 378 |
'type' => 'option' |
| 379 |
)); |
| 380 |
|
| 381 |
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_hiconcolor', array( |
| 382 |
'label' => __( 'Menu Hover/Active Icon Color', 'wp-bottom-menu' ), |
| 383 |
'section' => 'wpbottommenu_section_customize', |
| 384 |
))); |
| 385 |
|
| 386 |
$wp_customize->add_setting( 'wpbottommenu_bgcolor', array( |
| 387 |
'default' => '#ffffff', |
| 388 |
'section' => 'wpbottommenu_section_customize', |
| 389 |
'sanitize_callback' => 'sanitize_hex_color', |
| 390 |
'type' => 'option' |
| 391 |
)); |
| 392 |
|
| 393 |
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_bgcolor', array( |
| 394 |
'label' => __( 'Menu Background Color', 'wp-bottom-menu' ), |
| 395 |
'section' => 'wpbottommenu_section_customize', |
| 396 |
))); |
| 397 |
|
| 398 |
$wp_customize->add_setting( 'wpbottommenu_disable_title' , array( |
| 399 |
'default' => false, |
| 400 |
'type' => 'option', |
| 401 |
)); |
| 402 |
|
| 403 |
$wp_customize->add_control('wpbottommenu_disable_title', array( |
| 404 |
'label' => __( 'Disable title?', 'wp-bottom-menu' ), |
| 405 |
'section' => 'wpbottommenu_section_customize', |
| 406 |
'settings' => 'wpbottommenu_disable_title', |
| 407 |
'type' => 'checkbox', |
| 408 |
)); |
| 409 |
|
| 410 |
$wp_customize->add_setting( 'wpbottommenu_cart_separator' , array( |
| 411 |
'type' => 'option', |
| 412 |
)); |
| 413 |
|
| 414 |
$wp_customize->add_control('wpbottommenu_cart_separator', array( |
| 415 |
'label' => __( 'Customize Cart Item', 'wp-bottom-menu' ), |
| 416 |
'section' => 'wpbottommenu_section_customize', |
| 417 |
'settings' => 'wpbottommenu_cart_separator', |
| 418 |
'type' => 'hidden', |
| 419 |
)); |
| 420 |
|
| 421 |
$wp_customize->add_setting( 'wpbottommenu_show_cart_count' , array( |
| 422 |
'default' => false, |
| 423 |
'type' => 'option', |
| 424 |
)); |
| 425 |
|
| 426 |
$wp_customize->add_control('wpbottommenu_show_cart_count', array( |
| 427 |
'label' => __( 'Show Cart Count', 'wp-bottom-menu' ), |
| 428 |
'section' => 'wpbottommenu_section_customize', |
| 429 |
'settings' => 'wpbottommenu_show_cart_count', |
| 430 |
'type' => 'checkbox', |
| 431 |
)); |
| 432 |
|
| 433 |
$wp_customize->add_setting( 'wpbottommenu_cart_count_bgcolor', array( |
| 434 |
'default' => '#ff0000', |
| 435 |
'section' => 'wpbottommenu_section_customize', |
| 436 |
'sanitize_callback' => 'sanitize_hex_color', |
| 437 |
'type' => 'option' |
| 438 |
)); |
| 439 |
|
| 440 |
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wpbottommenu_cart_count_bgcolor', array( |
| 441 |
'description' => __('Cart Count Background Color', 'wp-bottom-menu'), |
| 442 |
'section' => 'wpbottommenu_section_customize', |
| 443 |
))); |
| 444 |
|
| 445 |
$wp_customize->add_setting( 'wpbottommenu_show_cart_total' , array( |
| 446 |
'default' => false, |
| 447 |
'type' => 'option', |
| 448 |
)); |
| 449 |
|
| 450 |
$wp_customize->add_control('wpbottommenu_show_cart_total', array( |
| 451 |
'label' => __( 'Show Cart Total', 'wp-bottom-menu' ), |
| 452 |
'description' => __( 'This option override cart menu title.', 'wp-bottom-menu' ), |
| 453 |
'section' => 'wpbottommenu_section_customize', |
| 454 |
'settings' => 'wpbottommenu_show_cart_total', |
| 455 |
'type' => 'checkbox', |
| 456 |
)); |
| 457 |
|
| 458 |
$wp_customize->add_setting( 'wpbottommenu_show_account_name' , array( |
| 459 |
'default' => false, |
| 460 |
'type' => 'option', |
| 461 |
)); |
| 462 |
|
| 463 |
$wp_customize->add_control('wpbottommenu_show_account_name', array( |
| 464 |
'label' => __( 'Show Account Name', 'wp-bottom-menu' ), |
| 465 |
'description' => __( 'This option override account menu title. First name is shown, if there is no first name, the username is shown.', 'wp-bottom-menu' ), |
| 466 |
'section' => 'wpbottommenu_section_customize', |
| 467 |
'settings' => 'wpbottommenu_show_account_name', |
| 468 |
'type' => 'checkbox', |
| 469 |
)); |
| 470 |
|
| 471 |
// |
| 472 |
// Section: Menu Items |
| 473 |
// |
| 474 |
|
| 475 |
$wp_customize->add_section('wpbottommenu_section_menuitems', array( |
| 476 |
'title' => __('Menu Items', 'wp-bottom-menu'), |
| 477 |
'priority' => 140, |
| 478 |
'panel' => 'wpbottommenu_panel' |
| 479 |
)); |
| 480 |
|
| 481 |
$wp_customize->add_setting( 'customizer_repeater_wpbm', array( |
| 482 |
'sanitize_callback' => 'customizer_repeater_sanitize', |
| 483 |
'type' => 'option', |
| 484 |
'default' => json_encode( array( |
| 485 |
array("choice" => "wpbm-homepage" ,"subtitle" => "fa-home", "title" => "Home", "id" => "customizer_repeater_1" ), |
| 486 |
array("choice" => "wpbm-woo-account" ,"subtitle" => "fa-user", "title" => "Account", "id" => "customizer_repeater_2" ), |
| 487 |
array("choice" => "wpbm-woo-cart" ,"subtitle" => "fa-shopping-cart", "title" => "Cart", "id" => "customizer_repeater_3" ), |
| 488 |
array("choice" => "wpbm-woo-search" ,"subtitle" => "fa-search", "title" => "Search", "id" => "customizer_repeater_4" ), |
| 489 |
)) |
| 490 |
)); |
| 491 |
|
| 492 |
$wp_customize->add_control( new Customizer_Repeater( $wp_customize, 'customizer_repeater_wpbm', array( |
| 493 |
'label' => esc_html__('Menu Item','customizer-repeater'), |
| 494 |
'section' => 'wpbottommenu_section_menuitems', |
| 495 |
'customizer_repeater_title_control' => true, |
| 496 |
'customizer_repeater_link_control' => true, |
| 497 |
'customizer_repeater_text_control' => true, |
| 498 |
'customizer_repeater_subtitle_control' => true, |
| 499 |
))); |
| 500 |
|
| 501 |
$wp_customize->add_setting( 'wpbottommenu_howuseicon' , array( |
| 502 |
'type' => 'option', |
| 503 |
)); |
| 504 |
|
| 505 |
$wp_customize->add_control( 'wpbottommenu_howuseicon', array( |
| 506 |
'label' => __( 'How to use Icons?', 'wp-bottom-menu' ), |
| 507 |
'description' => sprintf( |
| 508 |
__( '<u>For FontAwesome:</u> Add the names from (%1$s) to the "Icon" field.<br>Example:<code>fa-home</code><hr><u>For FontAwesome v6:</u> Add the names from (%3$s) to the "Icon" field.<br>Example:<code>fa-solid fa-house</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' ), |
| 509 |
sprintf( '<a target="_blank" href="https://fontawesome.com/v4.7.0/icons/" rel="nofollow">%s</a>', esc_html__( 'FontAwesome', 'wp-bottom-menu' ) ), |
| 510 |
sprintf( '<a target="_blank" href="https://remixicon.com" rel="nofollow">%s</a>', esc_html__( 'Remix Icon', 'wp-bottom-menu' ) ), |
| 511 |
sprintf( '<a target="_blank" href="https://fontawesome.com/search?m=free&o=r rel="nofollow">%s</a>', esc_html__( 'FontAwesome v6', 'wp-bottom-menu' ) ) |
| 512 |
), |
| 513 |
'section' => 'wpbottommenu_section_menuitems', |
| 514 |
'settings' => 'wpbottommenu_howuseicon', |
| 515 |
'type' => 'hidden', |
| 516 |
)); |
| 517 |
|
| 518 |
|
| 519 |
} |
| 520 |
|
| 521 |
/** |
| 522 |
* Render styles |
| 523 |
* |
| 524 |
* @since 1.0.0 |
| 525 |
* |
| 526 |
*/ |
| 527 |
public static function wpbottommenu_customize_css(){ |
| 528 |
|
| 529 |
// check condition |
| 530 |
$condition = new \WPBottomMenu_Condition(); |
| 531 |
if ( !$condition->get_condition() ){ |
| 532 |
return; |
| 533 |
} |
| 534 |
|
| 535 |
?> |
| 536 |
<style type="text/css"> |
| 537 |
<?php if (!get_option( 'wpbottommenu_display_always', false )): ?> |
| 538 |
@media (max-width: <?php echo get_option( 'wpbottommenu_display_px', '1024' ); ?>px){ |
| 539 |
.wp-bottom-menu{ |
| 540 |
display:flex; |
| 541 |
} |
| 542 |
.wp-bottom-menu-search-form-wrapper{ |
| 543 |
display: block; |
| 544 |
} |
| 545 |
} |
| 546 |
<?php else: ?> |
| 547 |
.wp-bottom-menu{ |
| 548 |
display:flex; |
| 549 |
} |
| 550 |
.wp-bottom-menu-search-form-wrapper{ |
| 551 |
display: block; |
| 552 |
} |
| 553 |
<?php endif; ?> |
| 554 |
|
| 555 |
:root{ |
| 556 |
--wpbottommenu-font-size: <?php echo get_option( 'wpbottommenu_fontsize', '12' );?>px; |
| 557 |
--wpbottommenu-icon-size: <?php echo get_option( 'wpbottommenu_iconsize', '24' );?>px; |
| 558 |
--wpbottommenu-text-color: <?php echo get_option( 'wpbottommenu_textcolor', '#555555' );?>; |
| 559 |
--wpbottommenu-h-text-color: <?php echo get_option( 'wpbottommenu_htextcolor', '#000000' );?>; |
| 560 |
--wpbottommenu-icon-color: <?php echo get_option( 'wpbottommenu_iconcolor', '#555555' );?>; |
| 561 |
--wpbottommenu-h-icon-color: <?php echo get_option( 'wpbottommenu_hiconcolor', '#000000' );?>; |
| 562 |
--wpbottommenu-bgcolor: <?php echo get_option( 'wpbottommenu_bgcolor', '#ffffff' );?>; |
| 563 |
--wpbottommenu-zindex: <?php echo get_option( 'wpbottommenu_zindex', '9999' ); ?>; |
| 564 |
--wpbottommenu-cart-count-bgcolor: <?php echo get_option( 'wpbottommenu_cart_count_bgcolor', '#ff0000' );?>; |
| 565 |
--wpbottommenu-wrapper-padding: <?php echo get_option( 'wpbottommenu_wrapper_padding', '10' );?>px 0; |
| 566 |
} |
| 567 |
|
| 568 |
</style> |
| 569 |
<?php |
| 570 |
} |
| 571 |
|
| 572 |
private static function get_available_custom_post( $type ) { |
| 573 |
$posts = get_posts( array( |
| 574 |
'post_type' => $type, |
| 575 |
'posts_per_page' => -1, |
| 576 |
) ); |
| 577 |
|
| 578 |
$options = []; |
| 579 |
|
| 580 |
foreach ( $posts as $post ) { |
| 581 |
$options[ $post->ID ] = $post->post_title; |
| 582 |
} |
| 583 |
|
| 584 |
return $options; |
| 585 |
} |
| 586 |
|
| 587 |
} |
| 588 |
WPBottomMenu_Customizer::init(); |