From d57c709174fd8e16c671532a3119adba7e4262b3 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Wed, 3 Jun 2026 18:15:42 -0400 Subject: [PATCH 1/2] fix: bootstrap after late plugin activation --- data-machine-code.php | 3 +++ tests/smoke-github-issue-publish-handler.php | 1 + 2 files changed, 4 insertions(+) diff --git a/data-machine-code.php b/data-machine-code.php index 36c0a69..8ae0bb2 100644 --- a/data-machine-code.php +++ b/data-machine-code.php @@ -119,6 +119,9 @@ function datamachine_code_bootstrap() { add_action('wp_abilities_api_categories_init', 'datamachine_code_register_ability_categories'); } add_action('plugins_loaded', '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..321fd4c 100644 --- a/tests/smoke-github-issue-publish-handler.php +++ b/tests/smoke-github-issue-publish-handler.php @@ -33,6 +33,7 @@ $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'); echo "\n"; if (empty($failures) ) { From 7d558b619c0bd02e94ab082127f317d922ad24fc Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Wed, 3 Jun 2026 18:19:59 -0400 Subject: [PATCH 2/2] fix: retry bootstrap after plugin activation --- data-machine-code.php | 7 +++++++ tests/smoke-github-issue-publish-handler.php | 1 + 2 files changed, 8 insertions(+) diff --git a/data-machine-code.php b/data-machine-code.php index 8ae0bb2..e437322 100644 --- a/data-machine-code.php +++ b/data-machine-code.php @@ -119,6 +119,13 @@ 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(); } diff --git a/tests/smoke-github-issue-publish-handler.php b/tests/smoke-github-issue-publish-handler.php index 321fd4c..a040680 100644 --- a/tests/smoke-github-issue-publish-handler.php +++ b/tests/smoke-github-issue-publish-handler.php @@ -34,6 +34,7 @@ $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) ) {