Created
August 16, 2017 09:31
-
-
Save ollietreend/759d72b82c42c9178047500dff7b535a to your computer and use it in GitHub Desktop.
WordPress admin bar bump for Bootstrap fixed navbar
This file contains hidden or 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 | |
namespace MyTheme; | |
function setup() { | |
add_theme_support('admin-bar', ['callback' => __NAMESPACE__ . '\\admin_bar_bump']); | |
} | |
add_action('after_setup_theme', __NAMESPACE__ . '\\setup'); | |
/** | |
* Admin Bar Bump | |
* WordPress adds margin to the html element when the admin bar is showing. | |
* We also need that margin on the navbar element, so we're tweaking | |
* the default styling to add it. | |
*/ | |
function admin_bar_bump() { | |
ob_start(); | |
_admin_bar_bump_cb(); | |
$bump = ob_get_clean(); | |
echo str_replace('html {', 'html, .navbar.fixed-top {', $bump); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment