Repository navigation
Plugins: Show the output of a plugin that fails to activate - #16084
huzaifaalmesbah wants to merge 2 commits into
Conversation
When a plugin triggers a fatal error or exits during activation, the error notice appends an `error_scrape` iframe that shows the plugin's output. Since r56573 that notice is printed with `wp_admin_notice()`, which passes the message through `wp_kses_post()`. `<iframe>` is not an allowed post tag, so the iframe was stripped and the reason for the failure was no longer shown. Allow the iframe through kses for this one notice only, by adding a `wp_kses_allowed_html` filter just around the `wp_admin_notice()` call. Other notices are still filtered as before. Follow-up to r56573. See #60373.
There was a problem hiding this comment.
🟡 Changes recommended
The temporary global allowlist change permits iframes in unrelated sanitization performed by notice callbacks, so it must be scoped to this notice while preserving its hooks.
1 open issue
What changed in this PR
Restores plugin activation failure output by allowing the error-scrape iframe through admin notice sanitization. This complements the separate fix for network activation context.
Changes:
- Adds an iframe allowlist filter when the activation error notice includes an iframe.
- Removes the filter after rendering the notice.
| File | Description |
|---|---|
src/wp-admin/plugins.php |
Temporarily allows iframe markup while rendering the plugin activation error notice. |
Review effort: Balanced
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Instead of temporarily filtering `wp_kses_allowed_html` while `wp_admin_notice()` runs, which also allowed iframes in any `wp_kses_post()` call made by a `wp_admin_notice` callback or notice filter, fire the `wp_admin_notice` action and sanitize this notice's markup with a local allowlist that adds the iframe. See #60373.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|

Description
When a plugin triggers a fatal error or exits during activation,
wp-admin/plugins.phpappends anerror_scrapeiframe to the "Plugin could not be activated because it triggered a fatal error." notice, so the plugin's output (the reason for the failure) is shown.Since r56573 (WordPress 6.4) that notice is printed with
wp_admin_notice(), which passes the message throughwp_kses_post().<iframe>is not an allowed post tag, so the iframe is stripped and only the generic message is shown.This PR allows the iframe for this one notice only. Instead of calling
wp_admin_notice(), which sanitizes withwp_kses_post(), it does the same two steps locally:wp_admin_noticeaction, aswp_admin_notice()does;wp_get_admin_notice()throughwp_kses()with the post allowlist plusiframe(src,style,width,height). Theiframeentry is only added when the iframe is actually appended.postkses rules are not changed, so other notices, and anywp_kses_post()call made by awp_admin_noticecallback or a notice filter, still strip iframes. This is the difference from 60373.patch, which allowed iframes in every notice printed throughwp_admin_notice().wp_admin_noticeaction and thewp_admin_notice_args/wp_admin_notice_markupfilters still run.esc_url(). The plugin's output loads inside the iframe as a separate document, not in the admin page.Related: #36406 / #16082 fixes the
$network_widevalue passed during the sameerror_scraperequest. That fix is only visible in the UI once this iframe is shown again. The two PRs touch nearby lines but are independent.Follow-up to r56573.
Testing Instructions
There is no PHPUnit test: the change is in the top-level code of
wp-admin/plugins.php, which the PHPUnit suite does not load.wp_admin_noticecallback:Before: only "Plugin could not be activated because it triggered a fatal error." is shown, and the page contains no
<iframe>.After: the notice contains the iframe, and it shows "Test 60373: this plugin always fails to activate."
Control (both before and after): the paragraphs show
HOOK:[]andCONTROL:[], sowp_kses_post()still strips iframes outside this notice.The other error notices on this screen (unexpected output, "cannot delete a plugin while it is active on the main site", and "could not be resumed") have no iframe and render as before.
Tested on a local multisite install, from a site admin and from the network admin. Together with #16082, a network activation also shows the plugin's output, and the hook receives
$network_wide = true.Trac ticket: https://core.trac.wordpress.org/ticket/60373
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Code archaeology, reproduction scripts, and preparing the diff and PR description; the change was reproduced before and after on a local multisite install and reviewed by me.