Skip to content

Instantly share code, notes, and snippets.

@alexadark
Last active July 8, 2016 11:21
Show Gist options
  • Save alexadark/3407c11790de64db709139a3df5f6060 to your computer and use it in GitHub Desktop.
Save alexadark/3407c11790de64db709139a3df5f6060 to your computer and use it in GitHub Desktop.
add_action( 'beans_uikit_enqueue_scripts', 'example_enqueue_uikit_assets' );
function example_enqueue_uikit_assets() {
// Enqueue extra UIkit components.
beans_uikit_enqueue_components( array( 'modal' ) );
// Add style.less to the compiler.
beans_compiler_add_fragment( 'uikit', get_stylesheet_directory_uri() . '/style.less', 'less' );
}
// Modify primary menu type to stack as it would in a sidenav.
add_filter( 'beans_primary_menu_args', 'example_primary_menu_args' );
function example_primary_menu_args( $args ) {
return array_merge( $args, array(
'beans_type' => 'sidenav'
) );
}
// Add the modal menu button.
add_action( 'beans_site_branding_after_markup', 'example_modal_menu_button' );
function example_modal_menu_button() {
?>
<a class="uk-float-right" href="#example-modal-menu" data-uk-modal>
<i class="uk-icon-navicon"></i>
</a>
<?php
}
// Add the modal menu with an action to which the menu will be attached.
add_action( 'beans_site_after_markup', 'example_modal_menu' );
function example_modal_menu() {
?>
<div id="example-modal-menu" class="uk-modal">
<a class="uk-modal-close uk-close"></a>
<div class="uk-modal-dialog">
<?php do_action( 'example_modal_menu' ); ?>
</div>
</div>
<?php
}
// Change the primary menu hook to the new modal hook and remove floating class.
beans_modify_action_hook( 'beans_primary_menu', 'example_modal_menu' );
beans_remove_attribute( 'beans_primary_menu', 'class', 'uk-float-right' );
// Move the primary menu offcanvas button back to the header.
beans_modify_action_hook( 'beans_primary_menu_offcanvas_button', 'beans_site_branding_after_markup' );
#example-modal-menu {
background: #fff;
.uk-modal-close {
position: absolute;
top: 80px;
right: 70px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment