All Projects → jaycbrf4 → Wp Bootstrap4 Megamenu Navwalker

jaycbrf4 / Wp Bootstrap4 Megamenu Navwalker

A Navwalker to impliment a widget based Mega Menu using Bootstrap 4.0 nav classes

Projects that are alternatives of or similar to Wp Bootstrap4 Megamenu Navwalker

B4st
A Bootstrap 4 Starter Theme, for WordPress
Stars: ✭ 318 (+1035.71%)
Mutual labels:  wordpress, bootstrap4
Bootstrap Blocks Wordpress Plugin
Bootstrap Gutenberg Blocks for WordPress
Stars: ✭ 143 (+410.71%)
Mutual labels:  wordpress, bootstrap4
Uix Kit
A free UI toolkit based on some common libraries for building beautiful responsive website, compatible with Bootstrap v4.
Stars: ✭ 318 (+1035.71%)
Mutual labels:  wordpress, bootstrap4
Sage
WordPress starter theme with a modern development workflow
Stars: ✭ 11,531 (+41082.14%)
Mutual labels:  wordpress, bootstrap4
Tony
An Elegant WordPress Theme Based on ✌️Vue.js | 基于 Vue.js 的简洁一般强大的 WordPress 单栏博客主题
Stars: ✭ 462 (+1550%)
Mutual labels:  wordpress, bootstrap4
Cloud Native Workloads On Linuxone
In this code we will show how to run open source Cloud-Native workloads on Linux One. LinuxONE is built for open source.
Stars: ✭ 13 (-53.57%)
Mutual labels:  wordpress
Wordpress Related
WordPress codes
Stars: ✭ 15 (-46.43%)
Mutual labels:  wordpress
Wp Downloadmanager
Adds a simple download manager to your WordPress blog.
Stars: ✭ 11 (-60.71%)
Mutual labels:  wordpress
Heroku Wp
WordPress on Heroku
Stars: ✭ 865 (+2989.29%)
Mutual labels:  wordpress
Blog Post Workflow
Show your latest blog posts from any sources or StackOverflow activity or Youtube Videos on your GitHub profile/project readme automatically using the RSS feed
Stars: ✭ 910 (+3150%)
Mutual labels:  wordpress
Pmpro Addon Packages
Charge for access to specific pages or other post types in WordPress. Requires the Paid Memberships Pro plugin.
Stars: ✭ 20 (-28.57%)
Mutual labels:  wordpress
Pods
The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
Stars: ✭ 883 (+3053.57%)
Mutual labels:  wordpress
Wp Hercules
Simple domain mapping for top domains
Stars: ✭ 13 (-53.57%)
Mutual labels:  wordpress
E Commerce 2 django
Guest register, user register, user login, user logout, account home page, product view history, change password, reset password, change name, send activation email when register, resend activation email, add shipping address, add billing address, add nickname to the addresses, edit shipping address, edit billing address, view list of your addresses, reuse shipping addresses when order products, reuse billing addresses when ordeer products, show sales analytics if staff or admin only using -chart.js-, get analytics data with Ajax, receive marketing email, change if user will receive marketing email or not by admin, send contact message with Ajax, products list, product detail, download product detail as a PDF file, download digital product files -if the user purchased that digital product only-, orders list, list of digital products files, order detail, download order detail as a PDF file, verify order ownership with Ajax -to secure order detail page-, show cart products, add or remove product from cart, checkout page, thanks page when order placed successfully, add or reuse payment method, add or reuse payment method with Ajax, search products by title, search products by description, search products by price, search products by tag title, write tags for products -by admin only-, auto fill contact email, full name if user logged in.
Stars: ✭ 20 (-28.57%)
Mutual labels:  bootstrap4
Wordpress Admin Style
Shows the WordPress admin styles on one page to help you to develop WordPress compliant
Stars: ✭ 871 (+3010.71%)
Mutual labels:  wordpress
Hodd
Homie Device Discovery
Stars: ✭ 21 (-25%)
Mutual labels:  bootstrap4
Momtaz Nmwdhj
A WordPress forms elements API plugin.
Stars: ✭ 11 (-60.71%)
Mutual labels:  wordpress
Wordpress Exploit Framework
A Ruby framework designed to aid in the penetration testing of WordPress systems.
Stars: ✭ 882 (+3050%)
Mutual labels:  wordpress
Cmb2 Extension
This Repository is a extensions of CMB2 WordPress Plugin.
Stars: ✭ 20 (-28.57%)
Mutual labels:  wordpress
Django Bootstrap4
Bootstrap 4 integration with Django.
Stars: ✭ 877 (+3032.14%)
Mutual labels:  bootstrap4

wp-bootstrap4-navwalker-Mega

A custom WordPress nav walker class to fully implement the Bootstrap 4.0+ navigation style with Mega Menu items in a custom theme using the WordPress built in menu manager.

http://prntscr.com/h7206f <- screenshot of menu

http://prntscr.com/h720sy < - screenshot of widgets screen

http://prntscr.com/h721hh <- screenshot of menu screen

This version adds the support for multi level dropdowns with Mega Menu type nav items

NOTE

This is a utility class that is intended to format your WordPress theme menu with the correct syntax and classes to utilize the Bootstrap dropdown navigation, and does not include the required Bootstrap JS files. You will have to include them manually.

Installation

Place wp_bootstrap4-mega-navwalker.php in your WordPress theme folder /wp-content/your-theme/

Open your WordPress themes functions.php file /wp-content/your-theme/functions.php and add the following code:

	// Register Custom Navigation Walker
	require_once('wp_bootstrap4-mega-navwalker.php');

Usage

Update your wp_nav_menu() function in header.php to use the new walker by adding a "walker" item to the wp_nav_menu array.

 <?php
       $args = array(
		  'theme_location' => 'mega_menu',
		  'depth' => 0,
		  'menu_class'  => 'navbar-nav mr-auto',
		  'walker'  => new BootstrapNavMenuWalker()
          );
    wp_nav_menu($args);
        ?>

Your menu will now be formatted with the correct syntax and classes to implement Bootstrap dropdown navigation.

You will also want to declare your new menu in your functions.php file.

register_nav_menus( array(
'mega_menu'   => __( 'Mega Menu', 'your-theme' ),
) );

Now you will need to add the Widget that will contain the mega-menu item's HTML. In your functions file add this code to the register sidebars function:

//register MegaMenu widget if the Mega Menu is set as the menu location
$location = 'mega_menu';
$css_class = 'mega-menu-parent';
$locations = get_nav_menu_locations();
if ( isset( $locations[ $location ] ) ) {
  $menu = get_term( $locations[ $location ], 'nav_menu' );
  if ( $items = wp_get_nav_menu_items( $menu->name ) ) {
    foreach ( $items as $item ) {
      if ( in_array( $css_class, $item->classes ) ) {
        register_sidebar( array(
          'id'   => 'mega-menu-item-' . $item->ID,
          'description' => 'Mega Menu items',
          'name' => $item->title . ' - Mega Menu',
          'before_widget' => '<li id="%1$s" class="mega-menu-item">',
          'after_widget' => '</li>', 

        ));
      }
    }
  }
}

Typically the menu is wrapped with additional markup, here is an example of a navbar-fixed-top menu that collapse for responsive navigation.

<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
  <div class="container">
    <!-- custom calls to options stored in Admin section "Theme Options" to display the logo or not -->
     <a class="navbar-brand" id="logo" href="<?php echo site_url(); ?>"><img src="<?php header_image(); ?>" alt="Our Logo" class="img-responsive logo"/></a>
    <!-- custom calls to options stored in Admin section "Theme Options" to display the logo or not -->
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#bootstrap-nav-collapse" aria-controls="jd-bootstrap-nav-collapse" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <!-- Collect the nav links from WordPress -->
    <div class="collapse navbar-collapse" id="bootstrap-nav-collapse">         
		  <?php 

      $args = array(
        'theme_location' => 'mega_menu', // primary_menu or mega-menu
        'depth' => 0,
        'container' => '',
        'menu_class'  => 'navbar-nav mr-auto',
        'walker'  => new BootstrapNavMenuWalker()
        );
      wp_nav_menu($args);
      ?>
    </div><!-- ./collapse -->
  </div><!-- /.container -->
</nav>

Displaying the Menu

To display the menu you must associate your menu with your theme location. You can do this by selecting your theme location in the Theme Locations list wile editing a menu in the WordPress menu manager and selecting mega-menu.

Displaying the Mega Menu

To display the mega menu items add the class "mega-menu-parent" to the menu item in the WordPress menu manager. This will create a new widget in the widgets section with the same name as the nav parent. Add a Custom HTML widget and code your mega menu items using default bootstrap containers, rows and cols. Add a search widget or any other widget, style the CSS by the item's ID.

Additional CSS to get the menu to display correctly:

/**Mega Menu **/
.navbar .container {
    position: relative;
}
.navbar-nav, .navbar .collapse, .navbar-nav li {
  position: static;
}
.menu-item-has-children, .menu-item-has-children .dropdown-menu {
  left: auto;
}
.menu-item-has-children .dropdown-menu {
  width: auto !important;
}

And optional css for a hover/fade inUp effect

/* Make dropdown visible on hover */
@media (min-width: 767px) {
  .dropdown > .dropdown-menu {
    position: absolute;
    top: 100%;
    left: auto;
    z-index: 1000;
    float: none;
    min-width: 10rem;
    padding: 1rem;
    list-style: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    opacity: 0;
    margin-top: 10px !important;
    display: block;
    visibility:hidden;
    min-width: 150px;
    transition: all  0.2s ease-in-out;
  }
  .dropdown:hover > .dropdown-menu {
    visibility:visible;
    display: block;
    opacity: 1;
    margin-top: 5px !important; 
    border-bottom-right-radius: 8px;
    border-bottom-left-radius: 8px;
    transition: all  0.2s ease-in-out;
  }
    .mega-menu-parent.dropdown .dropdown-menu {
    position: absolute;
    left:  0;
  }
}

jQuery for hover:

$('body').on('mouseenter mouseleave', '.dropdown', function (e) {
    var dropdown = $(e.target).closest('.dropdown');
    var menu = $('.dropdown-menu', dropdown);
    dropdown.addClass('show');
    menu.addClass('show');
    setTimeout(function () {
        dropdown[dropdown.is(':hover') ? 'addClass' : 'removeClass']('show');
        menu[dropdown.is(':hover') ? 'addClass' : 'removeClass']('show');
    }, 300);
});
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].