Skip to content
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

Merged
merged 18 commits into from
Feb 19, 2024
Merged

Introduce PHP namespace #90

merged 18 commits into from
Feb 19, 2024

Conversation

psrpinto
Copy link
Member

@psrpinto psrpinto commented Feb 16, 2024

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.

@psrpinto psrpinto marked this pull request as ready for review February 16, 2024 15:49
akirk
akirk previously requested changes Feb 16, 2024
Copy link
Member

@akirk akirk left a 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.

@psrpinto
Copy link
Member Author

Mmm, weird, I tested locally and /events/ and other routes seem to work for me. Could you check if there's something in the logs?

@trymebytes
Copy link
Collaborator

Is there a reason for renaming the main plugin file to plugin.php? Otherwise, we could just leave it unchanged for the sake of consistency.

@trymebytes
Copy link
Collaborator

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 .

@psrpinto
Copy link
Member Author

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.

@akirk
Copy link
Member

akirk commented Feb 16, 2024

Ah makes sense! Thanks @trymebytes !

@akirk
Copy link
Member

akirk commented Feb 16, 2024

In WordPress it's the common practice to have the main plugin file with the same name as the directory+.php

@psrpinto psrpinto dismissed akirk’s stale review February 16, 2024 17:22

Issue has been addressed

Copy link
Member

@akirk akirk left a 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:189and in wporg-gp-translation-events.php:234. If I rename those locally, it works!

@psrpinto
Copy link
Member Author

Good catch, fixed. Also merged trunk to resolve conflicts.

@psrpinto psrpinto requested a review from akirk February 19, 2024 16:20
Copy link
Member

@akirk akirk left a 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

@psrpinto
Copy link
Member Author

psrpinto commented Feb 19, 2024

Oops, sorry, should've tested. I added the missing import, and tested and everything seems to work.

Copy link
Member

@akirk akirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now!

@psrpinto psrpinto merged commit 7c90a06 into trunk Feb 19, 2024
2 checks passed
@psrpinto psrpinto deleted the namespaces branch February 19, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some code is not namespaced to the plugin
3 participants