| @@ -48,18 +48,23 @@ | ||
| 48 | 48 | ob_start(); |
| 49 | 49 | // Evaluate PHP code and save the result! |
| 50 | 50 | $beforeEvalError = error_get_last(); |
| 51 | 51 | $unusedResult = eval("?>{$code}"); |
| 52 | + $afterEvalError = error_get_last(); | |
| 52 | 53 | $evalOBuffer = ob_get_clean(); |
| 54 | + $showError = ini_get('display_errors') && WP_DEBUG; | |
| 55 | + $isError = $afterEvalError && ($beforeEvalError != $afterEvalError); | |
| 53 | 56 | // Handling errors! |
| 54 | - if ($beforeEvalError != error_get_last()) { | |
| 55 | - if (ini_get('display_errors')) { | |
| 56 | - $this->output = 'CJT PHP Code Error detected for the following block: <br><br>'; | |
| 57 | - $this->output .= "Name: {$block->name}<br>"; | |
| 58 | - $this->output .= "ID: #{$block->id}<br><br>"; | |
| 59 | - $this->output .= "PHP Error Details are listed below:<br>"; | |
| 57 | + if ($isError && $showError) { | |
| 58 | + $this->output = 'CJT PHP Code Error detected for the following block: <br><br>'; | |
| 59 | + $this->output .= "Name: {$block->name}<br>"; | |
| 60 | + $this->output .= "ID: #{$block->id}<br><br>"; | |
| 61 | + if ($evalOBuffer) { | |
| 62 | + $this->output .= "PHP Error message:<br>"; | |
| 60 | 63 | $this->output .= $evalOBuffer; |
| 61 | 64 | } |
| 65 | + $this->output .= "PHP Error tech Details:<br>"; | |
| 66 | + $this->output .= print_r($afterEvalError, true); | |
| 62 | 67 | } |
| 63 | 68 | else { // Get evaludated code result! |
| 64 | 69 | $this->output .= $evalOBuffer; |
| 65 | 70 | } |
| @@ -89,5 +94,5 @@ | ||
| 89 | 94 | */ |
| 90 | 95 | public function getOutput() { |
| 91 | 96 | return $this->output; |
| 92 | 97 | } |
| 93 | -} // End class. | |
| 98 | +} // End class. | |