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

Spot non-existent method/function in remove_action() #197

Open
szepeviktor opened this issue Aug 7, 2023 · 3 comments
Open

Spot non-existent method/function in remove_action() #197

szepeviktor opened this issue Aug 7, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@szepeviktor
Copy link
Owner

szepeviktor commented Aug 7, 2023

remove_action('wp_enqueue_scripts', [$theme, 'wp_common_block_scripts_and_styles']);

This triggered no error on level 5.
How could that be?

ps. wp_common_block_scripts_and_styles is a global function from core

@szepeviktor szepeviktor changed the title Stop non-existent method/function in remove_action() Spot non-existent method/function in remove_action() Aug 7, 2023
@johnbillion
Copy link
Sponsor Contributor

This is expected behaviour. The $callback parameter doesn't have to be valid.

 * @param callable|string|array $callback  The name of the function which should be removed.
 *                                         This function can be called unconditionally to speculatively remove
 *                                         a callback that may or may not exist.

@szepeviktor
Copy link
Owner Author

szepeviktor commented Aug 7, 2023

Thank you, John.

(For extraterrestrial aliens 👽) could you add something like HookCallbackRule that checks for callback existence in hooking function? And has a parameter that activates it, so it is off by default (for earthlings).

@johnbillion
Copy link
Sponsor Contributor

I'd rather not 🤣

@szepeviktor szepeviktor added the help wanted Extra attention is needed label Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants