This repository has been archived by the owner on Sep 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 863
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #411 from AdamChlan/customizer-mobile-nav
Add Customizer Option for Topbar or Offcanvas Mobile Menu
- Loading branch information
Showing
6 changed files
with
86 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* Allow users to select Topbar or Offcanvas menu. Adds body class of offcanvas or topbar based on which they choose. | ||
* | ||
* @package WordPress | ||
* @subpackage FoundationPress | ||
* @since FoundationPress 1.0.0 | ||
*/ | ||
|
||
if ( ! function_exists( 'wpt_register_theme_customizer' ) ) : | ||
function wpt_register_theme_customizer( $wp_customize ) { | ||
// Create custom panels | ||
$wp_customize->add_panel( 'mobile_menu_settings', array( | ||
'priority' => 1000, | ||
'theme_supports' => '', | ||
'title' => __( 'Mobile Menu Settings', 'foundationpress' ), | ||
'description' => __( 'Controls the mobile menu', 'foundationpress' ), | ||
) ); | ||
|
||
// Create custom nav field | ||
$wp_customize->add_section( 'mobile_menu_layout' , array( | ||
'title' => __('Offcanvas or Topbar','foundationpress'), | ||
'panel' => 'mobile_menu_settings', | ||
'priority' => 1000, | ||
)); | ||
|
||
// Set default | ||
$wp_customize->add_setting( | ||
'wpt_mobile_menu', | ||
array( | ||
'default' => __( 'offcanvas', 'foundationpress' ), | ||
) | ||
); | ||
|
||
// Add radio button options | ||
$wp_customize->add_control( | ||
new WP_Customize_Control( | ||
$wp_customize, | ||
'mobile_menu_layout', | ||
array( | ||
'type' => 'radio', | ||
'label' => __('Offcanvas or Topbar', 'foundationpress'), | ||
'section' => 'mobile_menu_layout', | ||
'settings' => 'wpt_mobile_menu', | ||
'choices' => array( | ||
'offcanvas' => 'Offcanvas', | ||
'topbar' => 'Topbar', | ||
), | ||
) | ||
) | ||
); | ||
} | ||
add_action( 'customize_register', 'wpt_register_theme_customizer' ); | ||
|
||
// Add class to body to help w/ CSS | ||
add_filter( 'body_class', 'mobile_nav_class' ); | ||
function mobile_nav_class( $classes ) { | ||
if ( get_theme_mod( 'wpt_mobile_menu' ) == 'offcanvas' ) : | ||
$classes[] = 'offcanvas'; | ||
elseif ( get_theme_mod( 'wpt_mobile_menu' ) == 'topbar' ) : | ||
$classes[] = 'topbar'; | ||
endif; | ||
return $classes; | ||
} | ||
endif; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters