Hooking into the HTML header container

Unless a theme provides such a hook there is no way to do this with actions and filters. If a hook is provided then it will be theme specific, no generic WP solution exists. For a full list of the hooks that a theme should implement, see here: https://developer.wordpress.org/themes/advanced-topics/plugin-api-hooks/ At the moment this includes: wp_head() … Read more

Better use two dedicated methods hooked with add_action() to different actions, or can it be twice the same method?

So there’s 4 factors: Performance (Speed, resource usage) Convenience Code maintainability Learning the API you’re using If you don’t know the performance of your function then it’s impossible to answer your question, but I would guess that if it doesn’t do or cause any database queries, and it’s not doing operations on lots of data, … Read more

Send email to user when I publish a new post

Updated code for statuses as per @Fredrik’s answer as his is more accurate. To trigger this when publishing, you could change your first if to if ( $new_status === ‘inherit’ && $old_status === ‘new’ ) That way, your code should trigger only when you publish a post. EDIT: Some notes on your code. if ( … Read more

If has action not working as expected

That’s not what has_action does. has_action is true, if functions are added to fire on that hook. It is not a way to detect do_action calls. However in that code: Nothing was added to the acf_add_class action If something had been added, it still wouldn’t work because the body_class filter has already ran. It would … Read more