Last active
August 29, 2015 14:17
-
-
Save PeterBooker/55048729ab968a161953 to your computer and use it in GitHub Desktop.
Foundation 5 Top Bar Custom Menu Walker for WordPress
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
<?php | |
/* | |
* Provide fallback output incase no Menu is selected. | |
*/ | |
public static function fallback( $args = array() ) { | |
/* | |
* No content for left side Fallback | |
*/ | |
if ( 'left' == $args['menu_class'] ) { | |
echo "<ul class=\"left\"></ul>"; | |
return; | |
} | |
$home_url = site_url( '/' ); | |
$admin_menu_url = admin_url( '/nav-menus.php' ); | |
$output = "<ul class=\"right\">\n"; | |
$output .= "<li class=\"menu-item\">\n"; | |
$output .= "<a href=\"{$home_url}\">Home</a>\n"; | |
$output .= "</li>\n"; | |
if ( current_user_can( 'manage_options' ) ) { | |
$output .= "<li class=\"menu-item\">\n"; | |
$output .= "<a href=\"{$admin_menu_url}\">Customise Menu</a>\n"; | |
$output .= "</li>\n"; | |
} | |
$output .= "</ul>"; | |
echo $output; | |
} |
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
<?php | |
/* | |
* Fixed TopBar + WP Admin Bar Fix | |
*/ | |
public static function fixed_fix() { | |
if ( ! is_admin() && is_admin_bar_showing() ) { | |
remove_action( 'wp_head', '_admin_bar_bump_cb' ); | |
$height = WP_TopBar_Walker::$height; | |
$output = '<style type="text/css">' . "\n\t"; | |
$output .= 'body.admin-bar #wpadminbar { position: fixed; }' . "\n\t"; | |
$output .= 'body.admin-bar .fixed { margin-top: 46px; } body.admin-bar .fixed + div { margin-top: ' . $height . '; } body.admin-bar .fixed.expanded { margin-top: 0; }' . "\n\t"; | |
$output .= '@media ( min-width: 782px ) { body.admin-bar .fixed { margin-top: 32px; } body.admin-bar .fixed + div { margin-top: ' . $height . '; } body.admin-bar .fixed.expanded { margin-top: 0; } }' . "\n\t"; | |
$output .= '</style>' . "\n"; | |
echo $output; | |
} | |
} |
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
<?php | |
/* | |
* Sticky TopBar + WP Admin Bar Fix | |
*/ | |
public static function sticky_fix() { | |
if ( ! is_admin() && is_admin_bar_showing() ) { | |
remove_action( 'wp_head', '_admin_bar_bump_cb' ); | |
$output = '<style type="text/css">' . "\n\t"; | |
$output .= 'body.admin-bar #wpadminbar { position: fixed; }' . "\n\t"; | |
$output .= 'body.admin-bar { padding-top: 46px; }' . "\n\t"; | |
$output .= 'body.admin-bar .sticky.fixed { margin-top: 46px; }' . "\n\t"; | |
$output .= '@media ( min-width: 782px ) { body.admin-bar .sticky.fixed { margin-top: 32px; } }' . "\n\t"; | |
$output .= '@media ( min-width: 782px ) { body.admin-bar { padding-top: 32px; } }' . "\n\t"; | |
$output .= '</style>' . "\n"; | |
echo $output; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment