-
Notifications
You must be signed in to change notification settings - Fork 4
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce PHP namespace #90
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't investigate why but in this PR /events/
doesn't load for me anymore.
Mmm, weird, I tested locally and |
Is there a reason for renaming the main plugin file to |
The name change caused the plugin to be deactivated and would need to be re-activated. I guess that's why the routes don't load for @akirk . |
Ah yes, indeed, I forgot to mention that the plugin needs to be reactivated 🤦♂️ The reason I renamed the main plugin file is because the directory/repo already "carries" the name of the plugin. I did it for the purpose of shortening the name of the file. I'm happy to revert this change though, if you want. |
Ah makes sense! Thanks @trymebytes ! |
In WordPress it's the common practice to have the main plugin file with the same name as the directory+.php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You missed a rename in https://github.com/WordPress/wporg-gp-translation-events/pull/90/files#diff-4ad28b7297b89b696671daf3dbbda0f7e559703113a18bc042b3361ebbb04caaR189 includes/route.php:189
and in wporg-gp-translation-events.php:234
. If I rename those locally, it works!
Good catch, fixed. Also merged trunk to resolve conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately i just got another crash: Fatal error: Uncaught Error: Class "Wporg\TranslationEvents\DateTime" not found in wp-content/plugins/wporg-gp-translation-events/templates/events-user-created.php:31
Oops, sorry, should've tested. I added the missing import, and tested and everything seems to work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now!
Fixes #14
I think namespaces make code considerably easier to understand because it allows shortening the names of classes, functions, variables and files. And of course it prevents clashes of names with other plugins.