Hot answers tagged

2

The problem is the order of execution. The order things run matters. For your code to function, it would require either add_action to implement time travel several microseconds into the past so that it can add the hook before it ran, or it would require do_action to implement precognition so that it knows about add_action calls in the future that have not ...


2

The hook that you're currently using is publish_<post type> which means the <post type> part is dynamic and the value is a post type name/slug. So for other post types like page and (a custom post type named) my_cpt, you would just need to change the "post" (or the <post type> part) in the hook name to page, my_cpt or whatever is ...


1

This is not how this should work. You should not be stunning shell commands from a plugin. The proper way to do this is to install dependencies before bundling for distribution.


1

Used shorcodes can be retrived only if they are added in post content (or any content saved in db). They can not be retrived if hardcoded in template files (TBH, they can, but that's not the issue here). This code can help you to get the shortcodes used in a post content. function wpse387291_get_shortcodes() { global $post; $pattern = ...


1

I think I would go with a customizer setting, which a user could use to select a page (select) or pages (checkboxes) where the custom comment fields would be shown. The setting should save page ID(s). Then I'd add a callback function to template_redirect action, which would first get the customizer setting value with get_theme_mod() and then compare the ...


Only top voted, non community-wiki answers of a minimum length are eligible