WordPress / WordPress/plugin-check

False positives flagged about hook names not starting with the theme/plugin prefix

Open
#1,099 17 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Needs Discussion
Dominant language
PHP
Stars
362
Forks
126
Avg merge
1d 23h
Merged PRs (30d)
22

Description

I'm getting these errors now for my AI Services plugin, all of which are false positives:

Error: Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "pre_option_{$option}".
Error: Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "pre_option".
Error: Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "ais_load_services_capabilities".
Error: Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "pre_http_request".
Error: Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "http_request_timeout".
Error: Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "http_request_redirection_count".
Error: Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "http_headers_useragent".
Error: Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "http_request_reject_unsafe_urls".
Error: Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "https_ssl_verify".

There are two underlying problems:

  • ais_load_services_capabilities starts with "ais", which is a plugin-specific prefix. So that shouldn't be flagged?
  • All other filters are from WordPress Core, and they have to be reused here to have the plugin behave as expected in combination with the WordPress Core logic.
    • Concretely, the plugin implements a batch HTTP request API, and for that to work correctly, it needs to manually trigger certain Core filters again.

So I think it's a false positive to flag these. Ideally, we can find a way to improve this check, or alternatively this could be downgraded to a warning, since there can be inaccuracies like the above?

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

No files or tests are identified in the issue. Start by locating the hook-name prefix check that emits these errors and reproduce it with the listed plugin and WordPress Core hooks. Done means the checker no longer falsely flags valid prefixed or reused Core hooks, or applies an agreed warning behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.