0

I would like to code a plugin that injects the custom content to any type of post (post, page, product, any others) but I would like to allow the users to let them select the place of content too. Such as; before/after the title, before/after the content, before/after the comment section, and all other possibilities (e.g. the_content_more_link filter etc).

As you know, there are many plugins, themes, custom post type plugins that they create their own custom filter hooks (e.g. Woocommerce creates many filter hooks like woocommerce_get_price_html etc.)

I would like to know that is there any way to get the list of filter hooks (can be used for content placement/injection) for any post type? So I can offer these places (filter hook places) to the users for adding the content.

0

1 Answer 1

3

Not automatically.

You don't know a filter exists until something tries to add it or runs it, and you have no guarantee what that filter is for without docs or a human being to describe it.

You can do this by hand for core itself as it's well documented what the filters are, but there isn't a generic way to do this for 3rd party plugins/themes that provide custom filters.

A particular plugin might use filter names that are consistent enough to guess things but you would need to identify and cater to that plugin on a case by case basis.

You also have no way of knowing which filters are for frontend HTML. For example, code that tries to do this automatically might pick up filters for saving content or sending API requests that then break things. A lot of filters also run on both the frontend and the admin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.