Skip to content

Commit 58cd4f3

Browse files
authored
Merge pull request #296 from pattonwebz/update/readme-change
Update/readme change
2 parents 69f0f05 + d53b3db commit 58cd4f3

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ A custom WordPress nav walker class to fully implement the Bootstrap 3.0+ naviga
1414

1515
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.
1616

17+
### Bootstrap 4
18+
19+
Bootstrap 4 beta is available and is now the default branch offered at the GitHub repo and on [GetBootstrap](https://getbootstrap.com). A working version of the walker for Bootstrap 4 can be found in the `v4` branch.
20+
21+
Acording to @mdo & team:
22+
23+
> Long story short, shipping a beta means we’re done breaking all your stuff until our next major version (v5).
24+
1725
## Installation
1826

1927
Place **wp-bootstrap-navwalker.php** in your WordPress theme folder `/wp-content/your-theme/`
@@ -22,7 +30,19 @@ Open your WordPress themes **functions.php** file `/wp-content/your-theme/funct
2230

2331
```php
2432
// Register Custom Navigation Walker
25-
require_once('wp-bootstrap-navwalker.php');
33+
require_once get_template_directory() . 'wp-bootstrap-navwalker.php';
34+
```
35+
36+
If you encounter errors with the above code use a check like this to return clean errors to help diagnose the problem.
37+
38+
```php
39+
if ( ! file_exists( get_template_directory() . 'wp-bootstrap-navwalker.php' ) ) {
40+
// file does not exist... return an error.
41+
return new WP_Error( 'wp-bootstrap-navwalker-missing', __( 'It appears the wp-bootstrap-navwalker.php file may be missing.', 'wp-bootstrap-navwalker' ) );
42+
} else {
43+
// file exists... require it.
44+
require_once get_template_directory . 'wp-bootstrap-navwalker.php';
45+
}
2646
```
2747

2848
## Usage
@@ -99,6 +119,20 @@ Review options in the Bootstrap docs for more information on [nav classes](https
99119

100120
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.
101121

122+
### Making this Walker the Default Walker for Nav Manus
123+
124+
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.
125+
126+
```php
127+
function prefix_modify_nav_menu_args( $args ) {
128+
return array_merge( $args, array(
129+
'walker' => WP_Bootstrap_Navwalker(),
130+
) );
131+
}
132+
add_filter( 'wp_nav_menu_args', 'prefix_modify_nav_menu_args' );
133+
```
134+
Simply updating the walker may not be enough to get menus working right, you may need to add wrappers or additional classes, you can do that via the above function as well.
135+
102136
### Extras
103137

104138
This script included the ability to add Bootstrap dividers, dropdown headers, glyphicons and disables links to your menus through the WordPress menu UI.

0 commit comments

Comments
 (0)