Runtime checks that simulate frontend request not reliable in AJAX based workflow #750
Labels
Checks
Audit/test of the particular part of the plugin
[Team] Performance
Issues owned by Performance Team
[Type] Bug
An existing feature is broken
WP Admin
Issues for the WP Admin screen
When running runtime checks like
Enqueued_Scripts_Scope_Check
orEnqueued_Styles_Scope_Check
using the AJAX based flow, they may not detect problems correctly. A crucial issue is that AJAX requests are considered "WP Admin", so functions likeis_admin()
will return true. It's common for plugins to have a check like! is_admin()
around initialization logic that is specifically for the frontend, which means any such behaviors will not be spotted.You can verify this by running the "Performance" checks against
contact-form-7
for example, which enqueues scripts and stylesheets across the entire site.The AJAX based flow won't detect that - only the WP-CLI based flow will. The latter is because WP-CLI does not run in "WP Admin context".
I'm not sure there's a way to override what
is_admin()
returns... But worth thinking through this.The text was updated successfully, but these errors were encountered: