Refactor theme structure and update to use rtcamp/framework#689
Open
pratik-londhe4 wants to merge 14 commits into
Open
Refactor theme structure and update to use rtcamp/framework#689pratik-londhe4 wants to merge 14 commits into
pratik-londhe4 wants to merge 14 commits into
Conversation
…ettings registration
There was a problem hiding this comment.
Pull request overview
Migrates theme-elementary from a vendored in-repo framework (inc/Framework/) to the upstream rtcamp/wp-framework Composer dependency, and updates theme bootstrapping/services/docs to align with the framework’s Singleton/Loader/Registrable patterns.
Changes:
- Replace the local framework layer with
rtcamp/wp-frameworkvia Composer and update theme bootstrap/autoloading to use upstream traits/contracts. - Refactor theme services to be loaded through the framework
Loader(assets, block extension, and a new example settings page). - Update documentation and housekeeping (PSR-4 helpers class, README/DEVELOPMENT.md rewrites, workflow adjustments).
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates structural docs to reflect vendor/rtcamp/wp-framework + inc/ layout. |
| phpstan-baseline.neon | Adds a new suppression for a PHPStan always-true boolean warning. |
| inc/Modules/Settings/ThemeOptions.php | Introduces a declarative settings page built on the framework’s AbstractSettingsPage. |
| inc/Modules/BlockExtensions/MediaTextInteractive.php | Converts to Registrable and renames hook wiring to register_hooks(). |
| inc/Main.php | Switches to framework Singleton + Loader and loads services via $this->load([...]). |
| inc/Helpers/Util.php | Replaces empty global helpers file with a PSR-4 static utility class placeholder. |
| inc/helpers/custom-functions.php | Removes the old non-namespaced (empty) helpers file. |
| inc/Framework/Traits/Singleton.php | Removes local framework singleton trait (now provided by dependency). |
| inc/Framework/Traits/AutoloaderTrait.php | Removes local autoloader trait (now provided by dependency). |
| inc/Framework/Traits/AssetLoaderTrait.php | Removes local asset loader trait (now provided by dependency). |
| inc/Framework/README.md | Removes framework-layer documentation (now replaced by DEVELOPMENT.md guidance). |
| inc/Core/Assets.php | Converts assets service to Registrable and swaps to framework AssetLoaderTrait. |
| inc/Autoloader.php | Switches to framework AutoloaderTrait and points at dependency location. |
| DEVELOPMENT.md | Rewrites dev docs to match the new vendor/framework boundary and module patterns. |
| composer.lock | Locks rtcamp/wp-framework and updates dependency graph accordingly. |
| composer.json | Adds VCS repo + requires rtcamp/wp-framework, removes autoload.files. |
| .github/workflows/test-measure.yml | Adjusts PHP lint job for VCS installs; removes the PHP unit test job. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+14
to
17
| if ( ! trait_exists( 'rtCamp\WPFramework\AutoloaderTrait' ) ) { | ||
| require_once ELEMENTARY_THEME_TEMP_DIR . '/vendor/rtcamp/wp-framework/inc/AutoloaderTrait.php'; | ||
| } | ||
|
|
| $this->setup_hooks(); | ||
| public function __construct() { | ||
| $this->plugin_dir = ELEMENTARY_THEME_TEMP_DIR . '/'; | ||
| $this->plugin_url = trailingslashit( get_template_directory_uri() ) . '/'; |
Comment on lines
+2
to
+4
| ignoreErrors: | ||
| - identifier: booleanNot.alwaysTrue | ||
| path: inc/Core/Assets.php |
Comment on lines
85
to
92
| - name: Summarize skipped jobs | ||
| run: | | ||
| SKIPPED=() | ||
|
|
||
| [[ "${{ steps.determine-file-counts.outputs.css-count }}" -le 0 ]] && SKIPPED+=("lint-css") | ||
| [[ "${{ steps.determine-file-counts.outputs.js-count }}" -le 0 ]] && SKIPPED+=("lint-js" "unit-tests-js" "build-prod") | ||
| [[ "${{ steps.determine-file-counts.outputs.php-count }}" -le 0 ]] && SKIPPED+=("lint-php" "unit-test-php") | ||
| [[ "${{ steps.determine-file-counts.outputs.php-count }}" -le 0 ]] && SKIPPED+=("lint-php") | ||
|
|
| Assets::class, | ||
| MediaTextInteractive::class, | ||
| ThemeOptions::class, | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Migrates
theme-elementaryoff its copy of the framework and onto the upstreamrtcamp/wp-frameworkComposer package.Also folds in a few stale-doc / stale-code follow-ons that were left over from the migration: converts the now-empty
inc/helpers/custom-functions.phpto a PSR-4Helpers\Utilstatic class, drops the Composerfilesautoload entry, and rewritesDEVELOPMENT.md(which still describedinc/Framework/as a real subdirectory).Technical Details
type: vcsrepository entry pointing atgithub.com/rtCamp/wp-framework.gitandrequire rtcamp/wp-framework: dev-frameworktocomposer.json. Dropped the legacyfilesautoload block — the whole theme is now PSR-4 with no special cases.inc/Framework/deleted in its entirety. The local copy only hadAutoloaderTrait,AssetLoaderTrait, andSingleton; the missing pieces (Loader,Container,Registrable,Shareable) now come from the package along with the abstracts.inc/Autoloader.phpusesrtCamp\WPFramework\AutoloaderTrait(the package's graceful-failure wrapper aroundvendor/autoload.php).inc/Main.phpuses the packageSingleton+Loadertraits and loads the theme's services via$this->load( [ Assets::class, MediaTextInteractive::class, ThemeOptions::class ] ). Noget_instance()anywhere except onMainitself.Core\AssetsimplementsRegistrableand uses the frameworkAssetLoaderTrait.Modules\BlockExtensions\MediaTextInteractiveimplementsRegistrable(previously aget_instance()singleton — now plain).Modules\Settings\ThemeOptionsextendsAbstractSettingsPage. Uses a declarativeget_fields()pattern with auto-generated Settings API sections + a genericrender_field()so adding another option is a one-entry change.use/ namespace reference re-pointed fromrtCamp\Theme\Elementary\Framework\…tortCamp\WPFramework\….inc/helpers/custom-functions.php→inc/Helpers/Util.php. The old file was empty (placeholder comment only). Replaced with afinalstatic class (private __construct()) mirroring the plugin'sHelpers\Utilpattern — ready to host theme-wide helpers without growing the global function table or relying on thefilesautoload directive.DEVELOPMENT.mdrewritten. The previous version still described aninc/Framework/subdirectory and a "two-layer model" rooted in it. New content reframes the layers aroundvendor/rtcamp/wp-framework/vsinc/, lists the actual on-disk PSR-4 reference table, documents theHelpers/convention, and adds a "Picking a base" table mapping feature types to the package's abstracts/interfaces.Checklist
Acceptance criteria from the issue:
theme-elementaryboots without fatal (fixes the broken hand-edit state)get_instance()calls remain except the bootstrap class (Main::get_instance()infunctions.php)inc/Framework/directory deletedgrep -rn "inc/Framework\|\\Framework\\" inc/returns nothing)requireincludesrtcamp/wp-framework+type: vcsrepository entry pointing at the framework repoinc/Autoloader.phpuses the package'sAutoloaderTraitMainkeepsuse Singleton; use Loader;— every other former singleton became a plainRegistrableThemeOptions→AbstractSettingsPage)Out-of-ticket cleanup landed alongside the migration:
inc/helpers/custom-functions.php(empty) converted to PSR-4Helpers\Utilstatic class;filesautoload entry removedDEVELOPMENT.mdrewritten to drop staleinc/Framework/references and document the current architectureFixes/Covers issue
Fixes #
https://github.com/rtCamp/wp-framework/issues/26