If we changed all of the template_*() calls to call this function instead, it will allow every plugin and theme author to add before/after every call.
define('TEMPLATE_EVENT_CALL_BREAK', true);
/**
* Call a template
* Should always be used to allow events
*
* @param string $name
*/
function template_call($name)
{
$args = func_get_args();
$name = array_shift($args);
if (empty($name))
{
throw new \InvalidArgumentException('$name cannot be empty');
}
$return = null;
$hook = 'template_' . $name;
call_integration_hook($hook . '__pre', $args);
$do_execute = call_integration_hook($hook . '__execute', $args);
if (empty($do_execute))
{
$return = call_user_func_array($name, $args);
}
call_integration_hook($hook . '__post', $args);
return $return;
}
If you're watching my View branch, it is AbstractTemplate::call()
Something to do for 1.1 without breaking everything. If you don't change the call to template_call() it doesn't break anything, you just don't get the hooks.