diff --git a/data-machine-code.php b/data-machine-code.php index 36c0a69..e437322 100644 --- a/data-machine-code.php +++ b/data-machine-code.php @@ -119,6 +119,16 @@ function datamachine_code_bootstrap() { add_action('wp_abilities_api_categories_init', 'datamachine_code_register_ability_categories'); } add_action('plugins_loaded', 'datamachine_code_bootstrap', 20); +add_action( + 'activated_plugin', + static function (): void { + datamachine_code_bootstrap(); + }, + 20 +); +if ( function_exists('did_action') && did_action('plugins_loaded') ) { + datamachine_code_bootstrap(); +} /** * Register DMC-owned webhook verifier modes with Data Machine core. diff --git a/tests/smoke-github-issue-publish-handler.php b/tests/smoke-github-issue-publish-handler.php index 591f582..a040680 100644 --- a/tests/smoke-github-issue-publish-handler.php +++ b/tests/smoke-github-issue-publish-handler.php @@ -33,6 +33,8 @@ $assert(false !== strpos($handler, 'GitHubAbilities::createIssue'), 'handler delegates issue creation to GitHubAbilities'); $assert(false !== strpos($settings, "'labels'") && false !== strpos($settings, "'assignees'"), 'settings expose labels and assignees defaults'); $assert(false !== strpos($plugin, 'new \\DataMachineCode\\Handlers\\GitHub\\GitHubIssuePublish();'), 'plugin bootstraps GitHub issue publish handler'); +$assert(false !== strpos($plugin, "did_action('plugins_loaded')") && false !== strpos($plugin, 'datamachine_code_bootstrap();'), 'plugin bootstraps immediately when loaded after plugins_loaded'); +$assert(false !== strpos($plugin, "'activated_plugin'") && false !== strpos($plugin, 'datamachine_code_bootstrap();'), 'plugin retries bootstrap after late activation completes'); echo "\n"; if (empty($failures) ) {