Skip to content

Commit 6b4880b

Browse files
authored
Merge pull request #374 from pattonwebz/master
Readme tweaks
2 parents e662885 + 190e257 commit 6b4880b

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

README.md

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Between version 3 and version 4 of the walker there have been significant change
2525
Here is a list of the most notable changes:
2626

2727
- The filename has been changed and prefixed with `class-` to better fit PHP coding standards naming conventions.
28-
- New Name: `class-wp-bootstrap-navwalker.php`
28+
- New Name: `class-wp-bootstrap-navwalker.php`
2929
- Old Name: `wp-bootstrap-navwalker.php`
3030
- Icon and link modifier handling is now done through the `CSS Classes` menu item input instead of the `Title` input.
3131
- Icon only items are possible using icon classes in combination with the `sr-only` classname.
@@ -37,21 +37,19 @@ Place **class-wp-bootstrap-navwalker.php** in your WordPress theme folder `/wp-c
3737
Open your WordPress themes **functions.php** file - `/wp-content/your-theme/functions.php` - and add the following code:
3838

3939
```php
40-
<?php
4140
// Register Custom Navigation Walker
4241
require_once get_template_directory() . '/class-wp-bootstrap-navwalker.php';
4342
```
4443

4544
If you encounter errors with the above code use a check like this to return clean errors to help diagnose the problem.
4645

4746
```php
48-
<?php
4947
if ( ! file_exists( get_template_directory() . '/class-wp-bootstrap-navwalker.php' ) ) {
5048
// file does not exist... return an error.
5149
return new WP_Error( 'class-wp-bootstrap-navwalker-missing', __( 'It appears the class-wp-bootstrap-navwalker.php file may be missing.', 'wp-bootstrap-navwalker' ) );
5250
} else {
5351
// file exists... require it.
54-
require_once get_template_directory() . '/class-wp-bootstrap-navwalker.php';
52+
require_once get_template_directory() . '/class-wp-bootstrap-navwalker.php';
5553
}
5654
```
5755
You will also need to declare a new menu in your `functions.php` file if one doesn't already exist.
@@ -66,18 +64,16 @@ register_nav_menus( array(
6664
Add or update any `wp_nav_menu()` functions in your theme (often found in `header.php`) to use the new walker by adding a `'walker'` item to the wp_nav_menu args array.
6765

6866
```php
69-
<?php
7067
wp_nav_menu( array(
71-
'theme_location' => 'primary',
72-
'depth' => 1, // 1 = with dropdowns, 0 = no dropdowns.
73-
'container' => 'div',
74-
'container_class' => 'collapse navbar-collapse',
75-
'container_id' => 'bs-example-navbar-collapse-1',
76-
'menu_class' => 'navbar-nav mr-auto',
77-
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
78-
'walker' => new WP_Bootstrap_Navwalker()
68+
'theme_location' => 'primary',
69+
'depth' => 2, // 1 = no dropdowns, 2 = with dropdowns.
70+
'container' => 'div',
71+
'container_class' => 'collapse navbar-collapse',
72+
'container_id' => 'bs-example-navbar-collapse-1',
73+
'menu_class' => 'navbar-nav mr-auto',
74+
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
75+
'walker' => new WP_Bootstrap_Navwalker(),
7976
) );
80-
?>
8177
```
8278

8379
Your menu will now be formatted with the correct syntax and classes to implement Bootstrap dropdown navigation.
@@ -87,24 +83,24 @@ Typically the menu is wrapped with additional markup, here is an example of a `
8783
```php
8884
<nav class="navbar navbar-expand-md navbar-light bg-light" role="navigation">
8985
<div class="container">
90-
<!-- Brand and toggle get grouped for better mobile display -->
86+
<!-- Brand and toggle get grouped for better mobile display -->
9187
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-controls="bs-example-navbar-collapse-1" aria-expanded="false" aria-label="Toggle navigation">
9288
<span class="navbar-toggler-icon"></span>
9389
</button>
9490
<a class="navbar-brand" href="#">Navbar</a>
95-
<?php
96-
wp_nav_menu( array(
97-
'theme_location' => 'primary',
98-
'depth' => 2,
99-
'container' => 'div',
100-
'container_class' => 'collapse navbar-collapse',
101-
'container_id' => 'bs-example-navbar-collapse-1',
102-
'menu_class' => 'nav navbar-nav',
103-
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
104-
'walker' => new WP_Bootstrap_Navwalker()
91+
<?php
92+
wp_nav_menu( array(
93+
'theme_location' => 'primary',
94+
'depth' => 2,
95+
'container' => 'div',
96+
'container_class' => 'collapse navbar-collapse',
97+
'container_id' => 'bs-example-navbar-collapse-1',
98+
'menu_class' => 'nav navbar-nav',
99+
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
100+
'walker' => new WP_Bootstrap_Navwalker(),
105101
) );
106-
?>
107-
</div>
102+
?>
103+
</div>
108104
</nav>
109105
```
110106

@@ -122,11 +118,10 @@ To display the menu you must associate your menu with your theme location. You c
122118
There has been some interest in making this walker the default walker for all menus. That could result in some unexpected situations but it can be achieved by adding this function to your functions.php file.
123119

124120
```php
125-
<?php
126121
function prefix_modify_nav_menu_args( $args ) {
127-
return array_merge( $args, array(
128-
'walker' => WP_Bootstrap_Navwalker(),
129-
) );
122+
return array_merge( $args, array(
123+
'walker' => WP_Bootstrap_Navwalker(),
124+
) );
130125
}
131126
add_filter( 'wp_nav_menu_args', 'prefix_modify_nav_menu_args' );
132127
```
@@ -162,9 +157,9 @@ To make an item appear with the icon only apply the bootstrap screen reader clas
162157

163158
To set a disabled link simply add `disabled` to the **CSS Classes** field in the Menu UI and the walker class will do the rest. _Note: In addition to adding the .disabled class this will change the link `href` to `#` as well so that it is not a followable link._
164159

165-
#### Dropdown Headers & Dropdown Dividers
160+
#### Dropdown Headers, Dropdown Dividers & Dropdown Item Text.
166161

167-
Headers and dividers can be added within dropdowns by adding a Custom Link and adding either `dropdown-header` or `dropdown-divider` into the **CSS Classes** input. _Note: This will remove the `href` on the item and change it to either a `<span>` for headers or a `<div>` for dividers._
162+
Headers, dividers and text only items can be added within dropdowns by adding a Custom Link and adding either `dropdown-header`, `dropdown-divider` or `dropdown-item-text` into the **CSS Classes** input. _Note: This will remove the `href` on the item and change it to either a `<span>` for headers or a `<div>` for dividers._
168163

169164
## Changelog
170165

0 commit comments

Comments
 (0)