Hi
Ok this is a little complex. I am creating a plugin, and want to find the category ID from the Post page.
That's the easy part.
What makes it complex is I am doing it within an ob_start (started in a 'template_redirect' action) as I want to edit the full page before it is returned to the browser. Again that is easy enough from the ob_start function.
With the ID returned I want to evaluate some php stored in a sql field. I am trying to do this from within the ob_start function
$tui_cifp_insertvalue = tui_cifp_evaluate_html($tui_cifp_insertvalue);
This calls this
function tui_cifp_evaluate_html($string) {
return preg_replace_callback("/(<\?php|<\?|< \?php)(.*?)\?>/si",'EvalBuffer', $string);
}
Which in turn calls
function EvalBuffer($string) {
ob_start();
eval("$string[2];");
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
And the php I am trying to evaluate is.
<?php tui_findPostThumbIMG([categoryID],100,100,'categoryintro-thumbnail','','',''); ?>
This all works outside the ob_start routine, but here even simple php doesn't work. From within the ob_start routine the plugin breaks and a blank page returns.
So I thought I could evaluate the php before the start of the ob_start and pass the result through a global variable. That works, but at the point this starts using the following, the category ID is not available.
if ( strpos($_SERVER['REQUEST_URI'], 'wp-admin') === false ) {
global $holdvalue;
$tui_cifp_insertvalue = get_option('tui_cifp_insertvalue');
$categories = get_the_category();
$categoryID = $categories[0]->cat_ID;
$tui_cifp_insertvalue = str_replace("[categoryID]", $categoryID, $tui_cifp_insertvalue);
$holdvalue = tui_cifp_evaluate_html($tui_cifp_insertvalue);
add_action('template_redirect','tui_cifp_ob_start'); //
}
The ob_start function
function tui_cifp_ob_start()
{
ob_start('tui_cifp_templatefilter');
}
Ok I am stumped ... any ideas?
I either need to find a hook that executes at the right time so that I have access to the category ID, or I need to work out how to evaluate the php during the ob_start.
Oh ... I guess I should say. What I want to do is replace a tag on a wordpress page with some other information saved in a string, but need to be able to do this once the full page if drawn.
Thanks Stephen
PS I have asked this on the wordpress forums without a response. Sorry for the cross posting but I am a little desperate.