Ok this can be a little complex. I'm developing a wordpress plugin, and wish to discover the category ID in the Publish page.

This is the easy part.

What causes it to be complex is I'm doing the work inside an doctor_start (began inside a 'template_redirect' action) as I wish to edit the entire page prior to it being came back towards the browser. Again that's simple in the doctor_start function.

Using the ID came back I wish to evaluate some php saved inside a sql area. I'm trying to get this done from inside the doctor_start function

$tui_cifp_insertvalue = tui_cifp_evaluate_html($tui_cifp_insertvalue);

This refers to this as

function tui_cifp_evaluate_html($string) {
return preg_replace_callback("/(<\?php|<\?|< \?php)(.*?)\?>/si",'EvalBuffer', $string);
}

Which calls

function EvalBuffer($string) {
ob_start();
eval("$string[2];");
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}

And also the php I'm attempting to evaluate is.

<?php tui_findPostThumbIMG([categoryID],100,100,'categoryintro-thumbnail','','',''); ?>

All of this works outdoors the doctor_start routine, but here even simple php does not work. From inside the doctor_start routine the wordpress plugin breaks along with a blank page returns.

And So I thought I possibly could assess the php before the beginning of the doctor_start and pass the end result via a global variable. That actually works, but in the point this begins while using following, the course ID isn't 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 doctor_start function

function tui_cifp_ob_start()
{

ob_start('tui_cifp_templatefilter');

}

Ok I'm stumped ... any ideas?

I either must find a hook that executes in the proper time to ensure that I have the category ID, or I have to see how to judge the php throughout the doctor_start.

Oh ... I suppose I ought to say. What I wish to do is replace a tag on the wordpress page with a few additional information held in a string, but have to have the ability to do that when the full-page if attracted.

Thanks Stephen

PS I've requested this around the wordpress forums with no response. Sorry for that mix posting but I'm a little desperate.

Thanks OIS, I thank you for suggesting that solution. It's however doing exactly the same factor as I've been doing. I suppose structured in a different way.

It did however cause me to check out the issue from the different prospective.

Things I realized was that get_the_category() requires a parameter and wasn't obtaining a category since it was the Publish ID that wasn't available. I reduced the problem by doing the setup in advance like so.

function tui_cifp_ob_start()
{

    global $tui_cifp_message, $tui_cifp_div, $wp_query;

    if (is_single()) 
    {

        $tui_cifp_div = get_option('tui_cifp_div');

        if ($tui_cifp_div !== '') 
        {

        $thePostID = $wp_query->post->ID;
        $categories = get_the_category($thePostID); 
        $categoryID = $categories[0]->cat_ID;

        $tui_cifp_message = get_option('tui_cifp_message');

        $categoryTitle = $categories[0]->cat_name;
        $categoryDescription = $categories[0]->category_description;

        $tui_cifp_message = str_replace("[categoryID]", $categoryID, $tui_cifp_message);
        $tui_cifp_message = str_replace("[categoryTitle]", $categoryTitle, $tui_cifp_message);
        $tui_cifp_message = str_replace("[categoryDescription]", $categoryDescription, $tui_cifp_message);
        $tui_cifp_message = $tui_cifp_div.$tui_cifp_message;

        $tui_cifp_message = tui_cifp_evaluate_html($tui_cifp_message);

        }

        ob_start('tui_cifp_templatefilter');

    }

}

Many thanks.

I am not a fan of eval, but this appears to operate, without or with the output loading in the finish ...

function tui_findPostThumbIMG()
{
 echo "hey hey\n";
}

ob_start();
$categoryID = 10;
$tui_cifp_insertvalue = "<?php tui_findPostThumbIMG([categoryID],100,100,'categoryintro-thumbnail','','',''); ?>";
$tui_cifp_insertvalue = str_replace("[categoryID]", $categoryID, $tui_cifp_insertvalue);
$tui_cifp_insertvalue = tui_cifp_evaluate_html($tui_cifp_insertvalue);
echo $tui_cifp_insertvalue;
ob_end_flush();