feat(encryption): add a shared Encryption service over the framework Encryptor#713
Merged
Merged
Conversation
…Encryptor Extend the framework Encryptor with a key() override that sources the key from a project constant — no salt fallback; without the constant the framework refuses to encrypt. Shared through the container like the other loaders, with Util::encrypt()/decrypt() wrappers.
There was a problem hiding this comment.
Pull request overview
This PR introduces a shared theme-level encryption service built on the framework Encryptor, registers it in the theme bootstrap, and exposes encryption/decryption via Helpers\Util for consistent consumption across the theme.
Changes:
- Added
inc/Core/Encryption.phpas a shared (container-managed) encryptor service sourcing its key fromELEMENTARY_ENCRYPTION_KEY. - Registered the new
Encryptionservice inMain::CLASSESso it’s loaded by the theme bootstrap. - Added
Util::encrypt()/Util::decrypt()wrappers that resolve and delegate to the sharedEncryptioninstance.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| inc/Main.php | Registers the new Core\Encryption service in the theme’s load list. |
| inc/Helpers/Util.php | Adds encrypt()/decrypt() wrappers backed by the shared encryptor instance. |
| inc/Core/Encryption.php | Implements the shared encryptor service and overrides key resolution via ELEMENTARY_ENCRYPTION_KEY. |
…or/encryptor-instance # Conflicts: # inc/Helpers/Util.php # inc/Main.php
Refresh composer.lock: rtcamp/wp-framework dev-main → 2e8fa2d, the main tip carrying the injectable Encryptor that Core\Encryption extends.
pratik-londhe4
approved these changes
Jun 11, 2026
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.
What this does
Wires the theme into the framework's instance-based
Encryptor, following thesame consumer pattern as
Assets/Components/Templates: a context-ownedCoreservice shared through the container, withUtilwrappers as the callsurface.
Changes
inc/Core/Encryption.php—final class Encryption extends Encryptor implements Shareable; overrides thekey()seam to source the key from theELEMENTARY_ENCRYPTION_KEYconstant. No salt fallback — without the constantthe framework's
parent::key()throws on first use.inc/Main.php— registerEncryptioninCLASSES.inc/Helpers/Util.php—Util::encrypt()/Util::decrypt()backed by ashared
encryptor()resolved viaget_shared( Encryption::class ).Configuration
Define a dedicated key in
wp-config.phpbefore first use:There is deliberately no
LOGGED_IN_KEYfallback: an auth salt should notdouble as an encryption key, and rotating WordPress salts (standard incident
response) must never invalidate encrypted data. The throw is lazy — boot and
container registration never error; only an actual
Util::encrypt()/Util::decrypt()call without the constant does.How I verified
php -lclean on changed files.Encryption extends Encryptor, isShareable; without the constant the first encrypt throws the framework'sRuntimeException; with the constant a full encrypt → decrypt roundtripsucceeds.
Reviewer notes
composer.lockonce it lands onmain.