Skip to content

Close four verified gaps in the PKIW integration#13

Merged
courtneyr-dev merged 1 commit into
mainfrom
fix/pkiw-integration-gaps
Jul 3, 2026
Merged

Close four verified gaps in the PKIW integration#13
courtneyr-dev merged 1 commit into
mainfrom
fix/pkiw-integration-gaps

Conversation

@courtneyr-dev

Copy link
Copy Markdown
Owner

Closes the four gaps from the 2026-07-03 PKIW-integration audit, plus one latent bug found while fixing them.

1. Timing bug

PFBT_Post_Kinds_Integration ran its active check at after_setup_theme:99, before PKIW registers the kind taxonomy at init:5, so on PKIW-only installs is_post_kinds_active() returned false and no hooks registered. Hook registration now defers to init:12 (after PKIW's taxonomy registration and term seeding), and the check recognizes PKIW's real class (PostKindsForIndieWeb\Taxonomy), not just the legacy Kind_Taxonomy.

2. Automations were off (and one hook never fired)

pfbt_auto_suggest_kind / pfbt_auto_suggest_format defaulted to false with nothing enabling them. They now default to enabled when the kind taxonomy exists; the filters still allow opting out. IndieBlocks meta-only installs stay off, matching prior behavior.

While wiring this up: core has no set_post_format actionset_post_format() is a wp_set_post_terms() wrapper — so the format→kind hook could never fire even with the timing fixed. Format changes now route through set_object_terms on the post_format taxonomy. The kind→format handler had the mirror bug: it called get_term( $terms[0] ) assuming IDs, but $terms echoes what callers pass (usually slugs); it now resolves from $tt_ids, which are always integer term-taxonomy IDs.

3. Reconciled kind↔format maps

kind_format_map now covers all 24 of PKIW's default kinds (was missing eat, drink, mood, play, read, event, review, favorite, jam, wish, acquisition, recipe) and drops quotation and tag, which PKIW never registers. Quote format maps to the note kind. set_post_kind() refuses slugs with no registered term, so a bad mapping can no longer silently create junk terms in the non-hierarchical kind taxonomy.

4. Detector now sees kind cards

  • get_first_meaningful_block() no longer skips contentless blocks when they're registered dynamic blocks — the self-closing comments the Micropub builder writes for kind cards now reach format mapping.
  • get_format_by_block() maps PKIW kind-card blocks to formats (listen-card→audio, watch-card→video, mood/eat/drink/checkin/etc.→status, like/repost/reply/favorite/rsvp→aside, bookmark-card→link) via a new pfbt_kind_card_format_map filter. Includes cards the open PKIW sessions are shipping (repost/reply/bookmark) so the maps stay aligned.

Not touched

The format modal's kind-card-first patterns and its reactions-indieweb-set-kind dispatch — both verified working on staging.

Tests

20 new tests in tests/integration/test-post-kinds-integration.php covering the deferred active check, default-on automations in both directions (including slug-based term assignment), exact map coverage against PKIW's 24 default kinds, the junk-term guard, and contentless kind-card detection (registered → mapped format + kind; unregistered → standard). composer test green locally: phpcs clean, phpstan 0 errors, 274 tests / 727 assertions.

🤖 Generated with Claude Code

1. Timing: the active check ran at after_setup_theme:99, before PKIW
   registers the kind taxonomy at init:5, so hooks never registered on
   PKIW-only installs. Hook registration now defers to init:12 and the
   check recognizes PostKindsForIndieWeb\Taxonomy.

2. Automations: pfbt_auto_suggest_kind / pfbt_auto_suggest_format now
   default to enabled when the kind taxonomy exists (was hardcoded
   false with no way to enable). Also fixes a latent dead hook: core
   has no set_post_format action, so the format-to-kind direction now
   routes through set_object_terms on the post_format taxonomy, and
   the kind-to-format handler resolves terms from term-taxonomy IDs
   instead of assuming $terms holds IDs (callers pass slugs).

3. Maps: kind_format_map now covers all 24 PKIW default kinds and
   drops quotation/tag, which PKIW never registers; quote format maps
   to the note kind. set_post_kind() refuses unregistered slugs so a
   bad mapping can no longer create junk terms in the non-hierarchical
   kind taxonomy.

4. Detection: contentless registered dynamic blocks (what the Micropub
   builder writes for kind cards) now count as meaningful first
   blocks, and get_format_by_block() maps PKIW kind-card blocks to
   formats via the filterable pfbt_kind_card_format_map.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@courtneyr-dev courtneyr-dev enabled auto-merge (squash) July 3, 2026 23:48
@courtneyr-dev courtneyr-dev merged commit 94c74e4 into main Jul 3, 2026
13 checks passed
@courtneyr-dev courtneyr-dev deleted the fix/pkiw-integration-gaps branch July 3, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant