block = $block; } /** * put your comment there... * * @param mixed $stack */ public function exec($stack = array()) { $block =& $this->block; $code =& $block->code; // Make all stack variables available to the local scope. extract($stack); // Evaluate PHP codes! ob_start(); // Evaluate PHP code and save the result! $beforeEvalError = error_get_last(); $unusedResult = eval("?>{$code}"); $afterEvalError = error_get_last(); $evalOBuffer = ob_get_clean(); $showError = ini_get('display_errors') && WP_DEBUG; $isError = $afterEvalError && ($beforeEvalError != $afterEvalError); // Handling errors! if ($isError && $showError) { $this->output = 'CJT PHP Code Error detected for the following block:

'; $this->output .= "Name: {$block->name}
"; $this->output .= "ID: #{$block->id}

"; if ($evalOBuffer) { $this->output .= "PHP Error message:
"; $this->output .= $evalOBuffer; } $this->output .= "PHP Error tech Details:
"; $this->output .= print_r($afterEvalError, true); } else { // Get evaludated code result! $this->output .= $evalOBuffer; } return $this; } /** * put your comment there... * */ public function getBlock() { return $this->block; } /** * put your comment there... * * @param mixed $code */ public static function getInstance($code) { return new CJTPHPCodeEvaluator($code); } /** * put your comment there... * */ public function getOutput() { return $this->output; } } // End class.