Skip to content

fix: guard ability category registration against double-fire _doing_it_wrong notice#130

Merged
chubes4 merged 1 commit into
mainfrom
fix-category-double-register
Jun 15, 2026
Merged

fix: guard ability category registration against double-fire _doing_it_wrong notice#130
chubes4 merged 1 commit into
mainfrom
fix-category-double-register

Conversation

@chubes4

@chubes4 chubes4 commented Jun 15, 2026

Copy link
Copy Markdown
Owner

The notice

PHP Notice: Function WP_Ability_Categories_Registry::register was called incorrectly.
Ability category "block-format-bridge" is already registered.
in /var/www/extrachill.com/wp-includes/functions.php on line 6170

Root cause

On the Extra Chill multisite, WordPress core's wp_abilities_api_categories_init action fires more than once per request. Core's WP_Ability_Categories_Registry::register() warns via _doing_it_wrong whenever an already-registered category gets registered again.

bfb_register_ability_category() called wp_register_ability_category() unconditionally inside its wp_abilities_api_categories_init callback, with no idempotency guard — so on the second hook fire it re-registered the block-format-bridge category and tripped the notice.

The fix

Guard the registration with core's idempotency check wp_has_ability_category() (itself guarded with function_exists since it ships with the same core API). A repeat fire is now a clean no-op. The existing function_exists( 'wp_register_ability_category' ) guard is preserved. No change to the slug, label, description, or hook.

This plugin registers a single category (block-format-bridge); that one call is now guarded.

@chubes4 chubes4 merged commit 2408b0a into main Jun 15, 2026
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