Skip to content

v2.1.4 — Phase 9.8: frontend assets + Alpine.js extraction

Choose a tag to compare

@mexiter mexiter released this 25 Apr 13:13
· 70 commits to epic/refactor-april since this release

Phase 9.8 — Frontend Assets + Alpine.js Extraction

Five frontend asset methods leave the god-class for dedicated single-responsibility classes under src/Frontend/Assets/. Each class registers its own WordPress hook via register(); Plugin::registerHooks() wires them.

Added

  • StylesEnqueuer — wp_enqueue_scripts (frontend stylesheet w/ filemtime cache buster)
  • AlpineJsEnqueuer — wp_footer priority 5 (conditional Alpine 3 CDN load)
  • PromoCopyScript — wp_footer priority 20 (copy-to-clipboard inline JS)
  • AlpineDeferAttribute — script_loader_tag filter (defer attribute)
  • WidgetShortcodeDetector — widget_text filter (shortcode-in-widget detection)

Removed from god-class

  • enqueue_frontend_assets(), maybe_enqueue_alpine(), enqueue_promo_copy_script(), add_alpine_defer_attribute(), check_widget_for_shortcode()
  • Four corresponding add_action/add_filter registrations from init_hooks()

Compatibility

No public contract change. Alpine 3.13.5 still loaded from the same jsDelivr URL, still filterable via dataflair_alpinejs_url. Stylesheet handle and footer-script ordering (priority 5/20) byte-identical.

Stats

  • Tests: 18 new tests; full suite 452 tests, 1,062 assertions, all green
  • LOC: dataflair-toplists.php 2,347 → 2,165 (-182)