Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 137819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:09:59+00:00 2026-05-11T07:09:59+00:00

Ok this is a little complex. I am creating a plugin, and want to

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:10:00+00:00Added an answer on May 11, 2026 at 7:10 am

    Thanks OIS, I appreciate your proposing that solution. It is however doing the same thing as I have been doing. I guess structured differently.

    It did however cause me to look at the problem from a different prospective.

    What I realised was that get_the_category() needs a parameter and wasn’t getting a category because it was the Post ID that wasn’t available. I solved the problem by doing the setup up front 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');      }  } 

    Thanks again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a little confusing to explain, so bear with me here... I want
From ValueType.cs **Action: Our algorithm for returning the hashcode is a little bit complex.
I want to use a temp directory that will be unique to this build.
I'm creating an XML hierarchy that looks something like this: element A 0+ element
I have this little function function makewindows(){ child1 = window.open (about:blank); child1.document.write(<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']),
I have this little script to toggle a contact form when a button is
I'm trying to be responsible with my DOM references in this little Flash 8/AS2
ffdshow has this awesome little API for controlling playback of video files. It allows
I've searched for this a little but I have not gotten a particularly straight
This is a little out there but I have a customer object coming back

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.