Repository navigation
v2.1.8 — Phase 9.12 shortcode + campaign redirect extraction
Phase 9.12 — shortcode + campaign redirect extraction
The two remaining public entry points leave the god-class for dedicated single-responsibility classes under src/Frontend/Shortcode/ and src/Frontend/Redirect/.
Three new classes
ToplistShortcode— validates attrs, looks up toplist viaToplistsRepository(slug-or-id), runs the H7BrandMetaPrefetcheronce before iterating items, dispatches each item toCardRenderer::render(CasinoCardVM)or toTableRenderer::render(ToplistTableVM).ShortcodeRegistrar— owns theadd_shortcode('dataflair_toplist', …)registration. Wired through a genericcallableso heavy-weight orchestrator construction is deferred to first invocation — every other plugin has had a chance to register itsdataflair_card_renderer/dataflair_table_rendererfilters before the renderer resolves through the lazyContainer.CampaignRedirectHandler— ownstemplate_redirect, validates the campaign param, increments the per-campaign hit-counter transient, callswp_safe_redirect()to the brand affiliate URL.
Main file trim
dataflair-toplists.php drops by ~177 LOC. Two god-class methods become one-line delegators wired through lazy Container getters. add_shortcode + add_action('template_redirect', …) registrations move to Plugin::registerHooks().
Invariants preserved
- Render-time read-only:
ToplistShortcode::render()still passes the H7 prefetched brand-meta map into everyCasinoCardVM.RenderIsReadOnlyTest+RenderBatchQueryCountTestcontinue to enforce this — both H* invariants now point to the new class file at the source-scan layer. - Public contract: shortcode HTML is byte-identical, campaign redirect URL pattern (
/go/?campaign=…) and per-campaign hit-counter transient unchanged. AJAX endpoints, REST endpoints, sync semantics, telemetry hooks: identical.
Tests
21 new unit tests pin attribute validation, repository lookup, prefetch ordering, dispatch into table vs cards, the registrar's function_exists guard, the campaign happy path, the invalid-campaign 404, the already-redirected guard, and the per-campaign hit-counter transient. Full suite: 574 tests, 1,270 assertions, all green.
Strangler-fig
The two extracted god-class methods remain as one-line delegators through v2.1.x. They are deleted in v3.0.0 (Phase 9.13 — god-class symbol removal).