Repository navigation
Ship a default style for the outdated post notice - #3
Merged
Merged
Conversation
A service declares the scripts and styles it needs by implementing HasAssets; the plugin hooks the enqueue actions once, asks every registered service at each of them, and loads the declarations through the Assets boundary. Handles are checked for the plugin's prefix where they are declared, and a subsystem may name the infrastructure's value objects. Ported from mwpd/basic-scaffold@6302cb2 with the test and fixture fixes of 4431c78 (mwpd/basic-scaffold#37), renamed to this plugin, without the scaffold's sample assets. Refs #2
OutdatedPostNotice declares assets/css/notice.css at the front-end enqueue point when the queried post is outdated, so the style is in the head before the notice shows, and a fresh post, an archive or an admin screen loads nothing. The decision is made from the queried post and the policy, as the head comes before the loop. Themes adjust the look by overriding the mwpd-content-freshness-notice class, or replace it by dequeuing the handle. Refs #2
3 of 4 tasks
Follows mwpd/basic-scaffold@c72bf64 (mwpd/basic-scaffold#177): the plugin no longer delegates AssetLocation and DebugMode in the injector but asks the template methods get_asset_location() and get_debug_mode(), an enqueue action fired from inside get_assets() is only remembered, handles are AssetHandle values that reject what WordPress cannot print, equivalent script registrations compare equal, and the prefix rule sees dynamic receivers. The composition root overrides get_debug_mode() to return the DebugMode its services are bound to, so one rebinding covers the notice and the plugin's asset boundary alike. Refs #2
schlessera
force-pushed
the
feat/2-notice-default-style
branch
from
October 24, 2026 00:28
718f514 to
16421a7
Compare
This was referenced Oct 24, 2026
Merged
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.
Refs #2
Depends on mwpd/basic-scaffold#177 landing:
src/Infrastructure/, the architecture rules and their tests are that branch's asset capability atc72bf64, renamed to this plugin, so the infrastructure copy stays in sync with the scaffold. If the scaffold PR changes again before it merges, this PR follows.What changed
The outdated post notice ships a default style.
OutdatedPostNoticeimplementsHasAssetsand declaresassets/css/notice.cssat the front-end enqueue point when the queried post is outdated, so the stylesheet is in the head before the notice shows; a fresh post, an archive, a feed or an admin screen loads nothing. The look is the agreed one (soft amber box, dot marker,emsizing, forced-colors fallback), which the project website mirrors. Themes adjust it by overriding.mwpd-content-freshness-notice, or replace it by dequeuing themwpd-content-freshness-noticehandle. README, readme.txt, the docs and the changelog say so; the version is not bumped.The first commit ports the scaffold's asset capability (
HasAssets,Asset\*,InvalidAsset, theServiceBasedPluginorchestration, the PHPStan rule changes, the API snapshot and the infrastructure tests), without the scaffold's sample assets. The second adds the notice's style. The third resyncs the port with the reviewed scaffold branch (get_asset_location()andget_debug_mode()template methods instead of injector delegations, the re-entrancy guard,AssetHandle, normalized script registrations, the prefix rule's dynamic receivers) and overridesget_debug_mode()in the composition root so the asset boundary checks the sameDebugModethe services are bound to.Why this shape
The predicate runs in the head, so it asks
MainLoop::queried_post()and theFreshnessPolicyrather thanis_rendering_queried_post(), which needs the loop. The service does not catch its own failure inget_assets(): the plugin's enqueue listener is the boundary there, as the service's own filter callback is forthe_content, so the behaviour is the same (loud withWP_DEBUG, no style without it) and the service does not decide twice. The composition root returns the boundDebugModefromget_debug_mode(), so rebinding it once, through the bindings filter or in the root, covers the notice and the plugin's asset loading alike; the integration tests rely on that to exercise both modes.Proof
Run in a
php:8.3-clicontainer. The end-to-end tests ran in CI on the previous head and passed;tests/e2e/run.shnow also expects the stylesheet link on the old post, and the existing "no notice" checks cover its absence elsewhere, since the handle contains the class name.Checklist
composer testandcomposer lintpass locally;npm run e2eis left to CI.src/Infrastructure/changed: the API snapshot is regenerated, and the change is the scaffold's own (Add scripts and styles as a capability the plugin orchestrates basic-scaffold#177).Anything left open
AGENTS.mdnote is updated to the merged commit.