Skip to content

Conversation

@justlevine
Copy link
Collaborator

@justlevine justlevine commented Nov 27, 2025

What

This PR begins the process of code standardization/sharing. Specifically it:

  • Standardizes the following files from other One* plugins:
    • uninstall.php
    • onedesign.php
    • inc/Autoloader.php
    • inc/Main.php
    • inc/Contracts/Interfaces/Registrable.php
    • inc/Contracts/Traits/Singleton.php
    • inc/Modules/Rest/Abstract_Rest_Controller.php
    • inc/Modules/Rest/Rest.php
  • Moves classes into the PSR-4 namespace, (guestimated to prevent merge conflicts, but not final)
  • Replaces undesired usages of Singleton, with class instantiation and moves hook registration out of the constructor.

Why

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

  • Docs etc have not been updated, since there are future incoming changes.
  • The part the requires detailed review are the "standardized" files. These will be the source of truth going forward. Any changes beyond those are just a result of the new patterns, and those classes will likely be standardized/reviewed in follow-up PRs.

Checklist

  • I have read the Contribution Guidelines.
  • I have read the Development Guidelines.
  • My code is tested to the best of my abilities.
  • My code passes all lints (ESLint etc.).
  • My code has detailed inline documentation.
  • I have updated the project documentation as needed.

Copilot AI review requested due to automatic review settings November 27, 2025 21:53
Copy link
Contributor

Copilot AI left a 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 Registrable interface and refactored Singleton trait 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 as static (line 47), but is being called as an instance method using $this->. This should be self::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.

@justlevine justlevine requested a review from up1512001 November 27, 2025 22:02
Copy link
Member

@up1512001 up1512001 left a comment

Choose a reason for hiding this comment

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

Added few suggestions.

Copy link
Member

@up1512001 up1512001 left a comment

Choose a reason for hiding this comment

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

LGTM

@justlevine justlevine merged commit d78484a into develop Nov 28, 2025
6 of 9 checks passed
@justlevine justlevine deleted the dev/psr-4 branch November 28, 2025 11:07
@justlevine justlevine mentioned this pull request Dec 1, 2025
6 tasks
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.

3 participants