Skip to content

Commit 2908e93

Browse files
authored
Merge pull request #325 from pattonwebz/master
Slight readme tweaks
2 parents 572472d + cfb49cb commit 2908e93

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

README.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A custom WordPress nav walker class to fully implement the Bootstrap 3.0+ naviga
1212

1313
## NOTES
1414

15-
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.
15+
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. It does not include the required Bootstrap JS and CSS files. You will have to include those dependancies seporately.
1616

1717
### Bootstrap 4
1818

@@ -29,13 +29,15 @@ Place **wp-bootstrap-navwalker.php** in your WordPress theme folder `/wp-content
2929
Open your WordPress themes **functions.php** file `/wp-content/your-theme/functions.php` and add the following code:
3030

3131
```php
32+
<?php
3233
// Register Custom Navigation Walker
3334
require_once get_template_directory() . '/wp-bootstrap-navwalker.php';
3435
```
3536

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

3839
```php
40+
<?php
3941
if ( ! file_exists( get_template_directory() . '/wp-bootstrap-navwalker.php' ) ) {
4042
// file does not exist... return an error.
4143
return new WP_Error( 'wp-bootstrap-navwalker-missing', __( 'It appears the wp-bootstrap-navwalker.php file may be missing.', 'wp-bootstrap-navwalker' ) );
@@ -50,61 +52,58 @@ if ( ! file_exists( get_template_directory() . '/wp-bootstrap-navwalker.php' ) )
5052
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.
5153

5254
```php
53-
<?php
54-
wp_nav_menu( array(
55-
'menu' => 'primary',
56-
'theme_location' => 'primary',
57-
'depth' => 2,
58-
'container' => 'div',
59-
'container_class' => 'collapse navbar-collapse',
60-
'container_id' => 'bs-example-navbar-collapse-1',
61-
'menu_class' => 'nav navbar-nav',
62-
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
63-
'walker' => new WP_Bootstrap_Navwalker())
64-
);
65-
?>
55+
<?php
56+
wp_nav_menu( array(
57+
'theme_location' => 'primary',
58+
'depth' => 2,
59+
'container' => 'div',
60+
'container_class' => 'collapse navbar-collapse',
61+
'container_id' => 'bs-example-navbar-collapse-1',
62+
'menu_class' => 'nav navbar-nav',
63+
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
64+
'walker' => new WP_Bootstrap_Navwalker())
65+
);
6666
```
6767

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

70-
You will also want to declare your new menu in your `functions.php` file.
70+
You will also want to declare your new menu in your `functions.php` file if one is not already defined.
7171

7272
```php
73+
<?php
7374
register_nav_menus( array(
74-
'primary' => __( 'Primary Menu', 'THEMENAME' ),
75+
'primary' => __( 'Primary Menu', 'THEMENAME' ),
7576
) );
7677
```
7778

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

8081
```php
8182
<nav class="navbar navbar-default" role="navigation">
82-
<div class="container-fluid">
83-
<!-- Brand and toggle get grouped for better mobile display -->
84-
<div class="navbar-header">
85-
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
86-
<span class="sr-only">Toggle navigation</span>
87-
<span class="icon-bar"></span>
88-
<span class="icon-bar"></span>
89-
<span class="icon-bar"></span>
90-
</button>
91-
<a class="navbar-brand" href="<?php echo home_url(); ?>">
92-
<?php bloginfo('name'); ?>
93-
</a>
94-
</div>
95-
83+
<div class="container-fluid">
84+
<!-- Brand and toggle get grouped for better mobile display -->
85+
<div class="navbar-header">
86+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
87+
<span class="sr-only">Toggle navigation</span>
88+
<span class="icon-bar"></span>
89+
<span class="icon-bar"></span>
90+
<span class="icon-bar"></span>
91+
</button>
92+
<a class="navbar-brand" href="<?php echo home_url(); ?>">
93+
<?php bloginfo('name'); ?>
94+
</a>
95+
</div>
9696
<?php
97-
wp_nav_menu( array(
98-
'menu' => 'primary',
99-
'theme_location' => 'primary',
100-
'depth' => 2,
101-
'container' => 'div',
102-
'container_class' => 'collapse navbar-collapse',
103-
'container_id' => 'bs-example-navbar-collapse-1',
104-
'menu_class' => 'nav navbar-nav',
105-
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
106-
'walker' => new WP_Bootstrap_Navwalker())
107-
);
97+
wp_nav_menu( array(
98+
'theme_location' => 'primary',
99+
'depth' => 2,
100+
'container' => 'div',
101+
'container_class' => 'collapse navbar-collapse',
102+
'container_id' => 'bs-example-navbar-collapse-1',
103+
'menu_class' => 'nav navbar-nav',
104+
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
105+
'walker' => new WP_Bootstrap_Navwalker())
106+
);
108107
?>
109108
</div>
110109
</nav>
@@ -117,13 +116,14 @@ Review options in the Bootstrap docs for more information on [nav classes](https
117116

118117
### Displaying the Menu
119118

120-
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.
119+
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 while editing a menu in the WordPress menu manager.
121120

122121
### Making this Walker the Default Walker for Nav Manus
123122

124123
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.
125124

126125
```php
126+
<?php
127127
function prefix_modify_nav_menu_args( $args ) {
128128
return array_merge( $args, array(
129129
'walker' => WP_Bootstrap_Navwalker(),
@@ -135,24 +135,24 @@ Simply updating the walker may not be enough to get menus working right, you may
135135

136136
### Extras
137137

138-
This script included the ability to add Bootstrap dividers, dropdown headers, glyphicons and disables links to your menus through the WordPress menu UI.
138+
This script included the ability to add Bootstrap dividers, dropdown headers, glyphicons and disabled links to your menus through the WordPress menu UI.
139139

140-
### Dividers
140+
#### Dividers
141141

142142
Simply add a Link menu item with a **URL** of `#` and a **Link Text** or **Title Attribute** of `divider` (case-insensitive so ‘divider’ or ‘Divider’ will both work ) and the class will do the rest.
143143

144-
### Glyphicons
144+
#### Glyphicons
145145

146146
To add an Icon to your link simple place the Glyphicon class name in the links **Title Attribute** field and the class will do the rest. IE `glyphicon-bullhorn`
147147

148-
### Dropdown Headers
148+
#### Dropdown Headers
149149

150150
Adding a dropdown header is very similar, add a new link with a **URL** of `#` and a **Title Attribute** of `dropdown-header` (it matches the Bootstrap CSS class so it's easy to remember). set the **Navigation Label** to your header text and the class will do the rest.
151151

152-
### Disabled Links
152+
#### Disabled Links
153153

154154
To set a disabled link simply set the **Title Attribute** to `disabled` and the class will do the rest.
155155

156-
### Changelog
156+
## Changelog
157157

158158
Please see the [Changelog](https://github.com/wp-bootstrap/wp-bootstrap-navwalker/blob/master/CHANGELOG.md).

0 commit comments

Comments
 (0)