Reputation: 1
I'm building a Wordpress plugin and as per the plugin functionality requirement I need to find out if a Wordpress theme has a particular hook or not and in case if it doesn't have then I need to perform some action. Say for eg. show an alert message.
Upvotes: 0
Views: 267
Reputation: 1805
The WordPress function has_action is used for this purpose.
Here's a really basic example showing how you can echo a message if the theme doesn't have the hook you need:
if(has_action('example_hook')) {
do_action('example_hook');
} else {
echo 'an example alert message';
}
There's some more about has_action in the Codex.
Upvotes: 1