Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,18 @@ add_action( 'after_setup_theme', 'register_navwalker' );
If you encounter errors with the above code use a check like this to return clean errors to help diagnose the problem.

```php
if ( ! file_exists( get_template_directory() . '/class-wp-bootstrap-navwalker.php' ) ) {
// File does not exist... return an error.
return new WP_Error( 'class-wp-bootstrap-navwalker-missing', __( 'It appears the class-wp-bootstrap-navwalker.php file may be missing.', 'wp-bootstrap-navwalker' ) );
if ( !file_exists( get_template_directory() . '/class-wp-bootstrap-navwalker.php' ) ) {
// file does not exist, return an error.
function our_error() {
return new WP_Error( 'broke', __( 'class-wp-bootstrap-navwalker.php file may be missing', 'wp-bootstrap-navwalker' ) );
}
$return = our_error();
if( is_wp_error( $return ) ) {
echo $return->get_error_message();
}
} else {
// File exists... require it.
require_once get_template_directory() . '/class-wp-bootstrap-navwalker.php';
// file exists, require it.
require_once get_template_directory() . '/class-wp-bootstrap-navwalker.php';
}
```

Expand Down