Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update README.md#495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
maheraldous wants to merge1 commit intowp-bootstrap:master
base:master
Choose a base branch
Loading
frommaheraldous:patch-1

Conversation

maheraldous
Copy link

Your code didn't work for me but it worked somehow when I added the code in a funcation and then used the if statement to process the error.

Your code didn't work for me but it worked somehow when I added the code in a funcation and then used the if statement to process the error.
@mikaykun
Copy link

This sounds wrong. What changes have you done to your functions.php?

@maheraldous
Copy link
Author

@mikaykun I pasted the code which is in the README.md but I got errors so I did some search and found that code I wrote to you and it worked for me. There is no need to update the README.md but put it in case someone like me needed.

@mikaykun
Copy link

Can you provide a example code so that we can fixed this issue or create a better solution for others and add it to the Readme. That would be nice.

@IanDelMar
Copy link
Collaborator

I think@maheraldous is right. With

if ( !file_exists(get_template_directory() .'/class-wp-bootstrap-navwalker.php' ) ) {// File does not exist... return an error.returnnewWP_Error('class-wp-bootstrap-navwalker-missing',__('It appears the class-wp-bootstrap-navwalker.php file may be missing.','wp-bootstrap-navwalker' ) );}else {// File exists... require it.require_onceget_template_directory() .'/class-wp-bootstrap-navwalker.php';}

you simply return an instance of the WP_Error class holding the error codeclass-wp-bootstrap-navwalker-missing and the error messageIt appears the class-wp-bootstrap-navwalker.php file may be missing.. But the object is not processed in anyway, ie won't show up anywhere.

@maheraldous solution is a complicated way to echo the error message onevery page (admin and non-admin pages for logged in and logged out users).

My proposal is

$file =get_template_directory() .'/class-wp-bootstap-navwalker.php';if ( !file_exists($file ) ) {// Files does not exist, add admin notice.add_action('admin_notices',function() {$message =sprintf(/* translators: path to file */__('The file class-wp-bootstap-navwalker.php cannot be found at %s.','wp-bootstrap-navwalker' ),get_template_directory());printf('<div><p>%s</p></div>',esc_html($message ) );} );}else {// File exists, require it.require_once$file;}

which adds an admin notice on admin pages if the file does not exist.

image

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@maheraldous@mikaykun@IanDelMar

[8]ページ先頭

©2009-2025 Movatter.jp