Close four verified gaps in the PKIW integration#13
Merged
Conversation
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>
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.
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_Integrationran its active check atafter_setup_theme:99, before PKIW registers thekindtaxonomy atinit:5, so on PKIW-only installsis_post_kinds_active()returned false and no hooks registered. Hook registration now defers toinit:12(after PKIW's taxonomy registration and term seeding), and the check recognizes PKIW's real class (PostKindsForIndieWeb\Taxonomy), not just the legacyKind_Taxonomy.2. Automations were off (and one hook never fired)
pfbt_auto_suggest_kind/pfbt_auto_suggest_formatdefaulted tofalsewith nothing enabling them. They now default to enabled when thekindtaxonomy 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_formataction —set_post_format()is awp_set_post_terms()wrapper — so the format→kind hook could never fire even with the timing fixed. Format changes now route throughset_object_termson thepost_formattaxonomy. The kind→format handler had the mirror bug: it calledget_term( $terms[0] )assuming IDs, but$termsechoes 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_mapnow covers all 24 of PKIW's default kinds (was missing eat, drink, mood, play, read, event, review, favorite, jam, wish, acquisition, recipe) and dropsquotationandtag, which PKIW never registers. Quote format maps to thenotekind.set_post_kind()refuses slugs with no registered term, so a bad mapping can no longer silently create junk terms in the non-hierarchicalkindtaxonomy.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 newpfbt_kind_card_format_mapfilter. 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-kinddispatch — both verified working on staging.Tests
20 new tests in
tests/integration/test-post-kinds-integration.phpcovering 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 testgreen locally: phpcs clean, phpstan 0 errors, 274 tests / 727 assertions.🤖 Generated with Claude Code