-
Notifications
You must be signed in to change notification settings - Fork 0
dev: implement PSR-4 and reduce Singleton usage #29
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
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.
Pull request overview
This PR implements PSR-4 autoloading and reduces singleton usage across the OneDesign plugin. It standardizes file structure and naming conventions to align with other One* plugins.
Key changes:
- Introduces a
Registrableinterface and refactoredSingletontrait for better separation of concerns - Replaces singleton pattern with explicit class instantiation in most modules
- Moves classes into PSR-4 compliant namespaces (e.g.,
OneDesign\Modules\Rest,OneDesign\Modules\Post_Types)
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| uninstall.php | Refactored to use namespaced functions and improved multisite handling |
| onedesign.php | Updated to use new Main::instance() instead of Plugin::get_instance() |
| inc/Main.php | New bootstrap class that instantiates and registers all plugin components |
| inc/Contracts/Traits/Singleton.php | New simplified singleton trait with improved error handling |
| inc/Contracts/Interfaces/Registrable.php | New interface for classes that register WordPress hooks |
| inc/Modules/Rest/Abstract_REST_Controller.php | New base class for REST controllers with shared namespace |
| inc/Modules/Rest/*.php | Refactored REST controllers to extend abstract base and implement Registrable |
| inc/Modules/Post_Types/*.php | Updated to use PSR-4 namespaces and Registrable interface |
| inc/Modules/Core/Assets.php | Removed Singleton, now instantiated directly |
| inc/Modules/Settings/Admin.php | Moved to proper namespace and implements Registrable |
| inc/Modules/Multisite/Multisite.php | Updated namespace and implements Registrable |
| custom-functions.php | New file with global helper functions moved from inc/helpers/ |
| Configuration files | Updated to include custom-functions.php and ignore generic type warnings |
Comments suppressed due to low confidence (1)
inc/Modules/Core/Assets.php:31
- The
build_localized_data()method is declared asstatic(line 47), but is being called as an instance method using$this->. This should beself::build_localized_data()or the method should not be static.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
up1512001
left a comment
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.
Added few suggestions.
ced23ad to
8287666
Compare
up1512001
left a comment
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.
LGTM
What
This PR begins the process of code standardization/sharing. Specifically it:
uninstall.phponedesign.phpinc/Autoloader.phpinc/Main.phpinc/Contracts/Interfaces/Registrable.phpinc/Contracts/Traits/Singleton.phpinc/Modules/Rest/Abstract_Rest_Controller.phpinc/Modules/Rest/Rest.phpWhy
This should prevent the bulk of potential merge conflicts, making it easier for future PRs to be independent and reviewable in isolation.
Related Issue(s):
Additional Info
Checklist