WP-CLI 3.0: the activation redirect silently ends the next `wp plugin` / `wp theme` command
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in inc/admin.php at Admin::maybe_redirect(), the activation redirect named in the issue, and check how it reads and clears the redirect flag. Reproduce with the two WP-CLI commands in the issue, then add the early return described there and verify that the next command runs while the redirect still works on the first wp-admin page.
Written by the indexing model from the issue text.
Description
What happens
WP-CLI 3.0 (stable since 2026-12-01) changed its default context from cli to auto, which runs wp plugin … and wp theme … commands as a wp-admin page load for an administrator, so admin_init fires. Optimole's one-time redirect after activation, Admin::maybe_redirect() (https://github.com/Codeinwp/optimole-wp/blob/31e2a5c8d039998cfd2921544d3655d1878fb316/inc/admin.php#L1137), then calls wp_safe_redirect() and exit. WP-CLI suppresses the redirect header (wp-cli/wp-cli#6279) but not the exit, so the first such command after activating Optimole ends with exit code 0, no output, and having done nothing.
A deploy or provisioning script that activates Optimole and then runs another plugin or theme command silently skips that step: an install that never happens, a theme that is not activated, a deactivation that does not happen, or wp plugin is-installed answering success for a missing plugin. Only one command is affected, because the redirect clears its flag.
Reproduce
wp plugin activate optimole-wp
wp plugin install hello-dolly # WP-CLI 3.0.x: prints nothing, exit 0, nothing installed
Measured on a local WordPress site with the current release of Optimole: under WP-CLI 3.0.1 the wp plugin install above printed nothing, exited 0 and installed nothing; under WP-CLI 2.12.0 the same steps installed the plugin.
Suggested fix
Return before the flag is read or cleared when running under WP-CLI, so the redirect still happens on the administrator's first wp-admin page:
if ( defined( 'WP_CLI' ) && WP_CLI ) {
return;
}
This is how Easy MCP AI fixed the same bug in App_Page::maybe_redirect() (Codeinwp/wp-plugin-easy-mcp@c2ef3e341, with a unit test). Other Codeinwp products were checked the same way; the same issue is open in each affected one:
- Codeinwp/hyve-lite#325
- Codeinwp/optimole-wp#1259
- Codeinwp/otter-blocks#3238
- Codeinwp/redirection-for-contact-form-7#332
- Codeinwp/sparks-for-woocommerce#441
- Codeinwp/templates-patterns-collection#554
- Codeinwp/WP-Cloudflare-Super-Page-Cache#899
- Codeinwp/wp-full-stripe#853
- Codeinwp/wp-maintenance-mode#615
- Dominant language
- PHP
- Stars
- 75
- Forks
- 14
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 31
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Codeinwp/optimole-wp
-
bug-report bug-report-triage customer report
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
Codeinwp/optimole-wp#1255 ·
Maintainers usually reply within 1 day
-
Lazyload SVG placeholder runs uncached attachment lookups with JSON-escaped URLs on REST responsesOpencustomer report
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Codeinwp/optimole-wp#1253 ·
Maintainers usually reply within 1 day
-
customer report feature-request-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Codeinwp/optimole-wp#1239 ·
Maintainers usually reply within 1 day
-
Throttle and optimize `/wp-json/optml/v1/optimizations` REST API endpoint execution and validationOpencustomer report feature-request-triage
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Codeinwp/optimole-wp#1250 ·
Maintainers usually reply within 1 day
-
Cache `attachment_url_to_postid()` lookups in `Optml_Lazyload_Replacer` to reduce database overheadOpencustomer report feature-request-triage
Difficulty 3/5 1-2 days Newbie friendliness 65/100
Codeinwp/optimole-wp#1249 · 1 comment ·
Maintainers usually reply within 1 day
All issues in Codeinwp/optimole-wp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Sylius/SyliusResourceBundle#1179 ·
-
repo:ckeditor
Difficulty 1/5 Under an hour Newbie friendliness 78/100
craftcms/ckeditor#682 · 1 comment ·
Maintainers usually reply within 1 day
-
component/core domain/framework
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day