Taking this further, imagine these two pieces of documentation for the hooks
DOCUMENTATION 1 (Current Proposal)
PRE_TEMPLATE HOOK
This hook action is called just before the output html is put together and is a prerequisite if you wish to use the POST_TEMPLATE Hook to modify output later.
To run it, initialise it in your plugin as follows "plugin_add_hook('PRE_TEMPLATE', 'plugin_x_capture_output');"
Then, define the function with your code as follows...
function plugin_x_capture_output($t) {
//YOUR CODE GOES HERE IF REQUIRED
ob_start();
return $t;
}
If you simply want to run some code before the output html is put together but do not wish to use the POST_TEMPLATE Hook to modify output later, define the function as follows ....
function plugin_x_capture_output($t) {
//YOUR CODE GOES HERE
return $t;
}
P.S: Try not to change the value of "$t", as we need it intact to use later on in the process.
POST_TEMPLATE HOOK
This hook action is called just before the output html is sent to the browser and requires the PRE_TEMPLATE Hook.
To run it, initialise it in your plugin as follows "plugin_add_hook('POST_TEMPLATE', 'plugin_x_process_output');"
Then, define the function with your code as follows...
function plugin_x_process_output() {
$template_output = ob_get_contents();
ob_end_clean();
$template_output = YOUR CODE TO MODIFY OUTPUT
echo $template_output;
}
Compare that to
DOCUMENTATION 2 (Revised Proposal)
PRE_TEMPLATE HOOK
This hook action is called just before the output html is put together and is a prerequisite if you wish to use the POST_TEMPLATE Hook to modify output later.
To run it, initialise it in your plugin as follows "plugin_add_hook('PRE_TEMPLATE', 'plugin_x_capture_output');"
Then, define the function with your code as follows...
function plugin_x_capture_output() {
//YOUR CODE GOES HERE IF REQUIRED
return null;
}
POST_TEMPLATE HOOK
This hook action is called just before the output html is sent to the browser and requires the PRE_TEMPLATE Hook.
To run it, initialise it in your plugin as follows "plugin_add_hook('POST_TEMPLATE', 'plugin_x_process_output');"
Then, define the function with your code as follows...
function plugin_x_process_output($input_html) {
$output_html = YOUR CODE TO MODIFY $input_html
return $output_html;
}
Look to me like one of them is a bit more simple and straightforward although I suppose it is not the end of the world. I just prefer high usability levels particularly if the cost is low.
[Updated on: Mon, 18 April 2011 00:49]
Report message to a moderator