Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime checks that simulate frontend request not reliable in AJAX based workflow #750

Open
felixarntz opened this issue Oct 25, 2024 · 0 comments
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

Comments

@felixarntz
Copy link
Member

When running runtime checks like Enqueued_Scripts_Scope_Check or Enqueued_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 like is_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.

@felixarntz felixarntz added [Type] Bug An existing feature is broken Checks Audit/test of the particular part of the plugin WP Admin Issues for the WP Admin screen [Team] Performance Issues owned by Performance Team labels Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

1 participant