Skip to content

Commit 7708fd5

Browse files
authored
fix: guard ability category registration against double-fire _doing_it_wrong notice (#1006)
1 parent 6d7f40c commit 7708fd5

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

packages/wordpress-plugin/src/class-wp-codebox-abilities.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ private function register_category(): void {
9797
}
9898

9999
$register_category = static function (): void {
100+
// Core's `wp_abilities_api_categories_init` action can fire more than
101+
// once per request (e.g. on multisite), so guard against re-registering
102+
// an already-registered category to avoid a `_doing_it_wrong` notice.
103+
if ( function_exists( 'wp_has_ability_category' ) && wp_has_ability_category( 'wp-codebox' ) ) {
104+
return;
105+
}
106+
100107
wp_register_ability_category(
101108
'wp-codebox',
102109
array(

0 commit comments

Comments
 (0)