I have a plugin that I want to ensure runs ONLY on singular posts, pages, etc. I’m using the is_singular() function and it works great – except that all it does is return execution to the rest of the plugin if I do this:
function singular_check(){
if(is_singular())
return;
}
I’m executing it in a hook like so:
add_action('wp', 'singular_check');
I need to actually make my entire plugin bail out at that point, and return to executing whatever else was downstream of my plugin. Anyone know how to do so?
A possible solution would be to hook in way late (template redirect, for example), do your conditional check. If it passes, include (or require) a file that contains the stuff needed.
This is not going to work if
your-file.php
contains functions hooked into things that happened earlier (eg.init
orwp
). But ifyour-file.php
contains things that, say, modified content (hooking inthe_title
orthe_content
, for instance) then it would be fine.