WordPress / WordPress/WordPress-Coding-Standards
Check hook callback is not boolean
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.8k
- Forks
- 521
- Avg merge
- 5d 20h
- Merged PRs (30d)
- 1
Description
Is your feature request related to a problem?
A client wanting to return false to a filter, did:
add_filter( 'liveblog_entry_enable_embeds', false );
...instead of:
add_filter( 'liveblog_entry_enable_embeds', '__return_false' );
Describe the solution you'd like
When a boolean false or true is given as the second arg of add_filter() or add_action(), make it an Error with a suggestion of what to use instead.
This could be extended to look for other __return_() functions, like null, 0, array(), etc.
Perhaps an error with a more vague message if it's anything non-callable?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Search the repository for the checks and tests covering the add_filter() and add_action() entry points, then trace how invalid callback arguments are reported. Define done as producing an Error for boolean callbacks with a suggestion to use the corresponding _return* function; the broader non-callable cases are optional in the request.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100