WordPress / WordPress/plugin-check

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

Open
#750 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Team] Performance [Type] Bug Checks WP Admin
Dominant language
PHP
Stars
362
Forks
126
Avg merge
1d 23h
Merged PRs (30d)
22

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the Performance checks against contact-form-7 through both the AJAX-based and WP-CLI-based flows, focusing on Enqueued_Scripts_Scope_Check and Enqueued_Styles_Scope_Check. Compare the results and trace the runtime-check entry points to determine how frontend behavior is represented; done means the AJAX flow reliably detects the same frontend-only enqueue problems.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
testing-qa
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.