Skip to content

notice: ship a default style through the asset capability #2

Closed

Description

@schlessera

Context

OutdatedPostNotice prepends <p class="mwpd-content-freshness-notice" role="note">…</p> to an outdated post, and the plugin ships no CSS for it. In a default theme the notice looks like the first paragraph of the post. The design critique of the project page (2026-10-24) flagged this as its one blocking issue: the hero shows a styled amber callout that the plugin does not actually produce.

The fix is to ship a small default style, loaded through the asset capability that mwpd/basic-scaffold#37 adds to the scaffold (HasAssets, Style, Script, AssetContext, AssetLocation, Assets/WordPressAssets, InvalidAsset). The use case and the maintainer ruling are on that issue; this plugin is the worked example it was written for.

Scope

  • Port the asset capability into src/Infrastructure/ and the architecture rules (PrefixedNamesRule declarations and forwarders, CapabilitiesOnServicesRule with HasAssets, DependencyDirectionRule value objects), with the infrastructure tests, fixtures and the API snapshot, renamed to this plugin.
  • OutdatedPostNotice implements HasAssets and declares Style::file( 'mwpd-content-freshness-notice', 'assets/css/notice.css' ) at the front-end enqueue point, only when the queried post is outdated. The decision is made in the head, from the queried post and the FreshnessPolicy, not from the loop.
  • assets/css/notice.css: the agreed look (soft amber box, dot marker, em sizing, forced-colors fallback), which the project website mirrors.
  • README, readme.txt, CHANGELOG (Unreleased) and the docs: the notice has a default style; themes override the class or dequeue the handle.

Out of scope

Acceptance criteria

  • On the front end of a single post that FreshnessPolicy judges outdated, the mwpd-content-freshness-notice style is enqueued at wp_enqueue_scripts, from the plugin's URL, with the main file's Version (integration test through the composition root).
  • On a fresh post, no style is enqueued (test).
  • At the admin, block editor and login enqueue points, the notice declares nothing (test).
  • On an archive, the service is not needed, so nothing is enqueued and the queried post is not looked at (integration test through the composition root).
  • The declared file ships in the plugin (test).
  • A failure of the policy while declaring the style surfaces with debug mode on and loads no style with it off (tests).
  • The ported infrastructure tests pass; architecture.prefixedNames checks the handle in Style::file().
  • README and readme.txt describe the default style and how to restyle or remove it; the architecture walkthrough lists HasAssets; CHANGELOG has an Unreleased entry.
  • The end-to-end tests see the stylesheet link on the old post.

Verification

composer test
composer lint
composer check:autoloader
npm run e2e

Depends on mwpd/basic-scaffold#37; the infrastructure copy here follows that branch until it merges.

Activity

  1. schlessera commented on Oct 24, 2026

    @schlessera
    MemberAuthor

    Done in #3 (a4ee1cb). Each acceptance criterion is covered by its tests and the end-to-end checks on WordPress 6.0 and latest, all green on the merged head. The infrastructure it relies on landed upstream in mwpd/basic-scaffold#177.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions