| @@ -14,21 +14,18 @@ | ||
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Content render |
| 17 | 17 | * |
| 18 | - * @param array $attr Shortcode attributes. | |
| 19 | - * @param string $content Enclosed shortcode content. | |
| 20 | - * @param string $tag Shortcode tag. | |
| 21 | - * @return mixed Rendered snippet output, if any. | |
| 18 | + * @param array $attr | |
| 19 | + * @param string $content | |
| 20 | + * @param string $tag | |
| 22 | 21 | */ |
| 23 | 22 | public function html( $attr, $content, $tag ) { |
| 24 | 23 | $id = $this->get_snippet_id( $attr, WINP_SNIPPET_TYPE_PHP ); |
| 25 | 24 | |
| 26 | 25 | if ( ! $id ) { |
| 27 | - if ( current_user_can( 'manage_options' ) || ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ) { | |
| 28 | - /* translators: %s: Shortcode tag name */ | |
| 29 | - echo '<span style="color:red">' . sprintf( esc_html__( '[%s]: PHP snippets error (not passed the snippet ID)', 'insert-php' ), esc_html( $tag ) ) . '</span>'; | |
| 30 | - } | |
| 26 | + /* translators: %s: Shortcode tag name */ | |
| 27 | + echo '<span style="color:red">' . sprintf( esc_html__( '[%s]: PHP snippets error (not passed the snippet ID)', 'insert-php' ), esc_html( $tag ) ) . '</span>'; | |
| 31 | 28 | |
| 32 | 29 | return; |
| 33 | 30 | } |
| 34 | 31 | |
| @@ -63,35 +60,7 @@ | ||
| 63 | 60 | |
| 64 | 61 | // Track shortcode execution. |
| 65 | 62 | WINP_Plugin::app()->get_execute_object()->track_shortcode_snippet( $id ); |
| 66 | 63 | |
| 67 | - // Initialize error handler. | |
| 68 | - WINP_Error_Handler::init(); | |
| 69 | - | |
| 70 | - // Set current snippet context for error handler. | |
| 71 | - WINP_Error_Handler::set_current_snippet( $id, $snippet->post_title, $snippet_content ); | |
| 72 | - | |
| 73 | - $buffer_level = ob_get_level(); | |
| 74 | - ob_start(); | |
| 75 | - | |
| 76 | - try { | |
| 77 | - eval( $snippet_content ); | |
| 78 | - | |
| 79 | - // Preserve output from buffers opened by the snippet itself. | |
| 80 | - while ( ob_get_level() > $buffer_level + 1 ) { | |
| 81 | - ob_end_flush(); | |
| 82 | - } | |
| 83 | - | |
| 84 | - $snippet_output = ob_get_clean(); | |
| 85 | - return false !== $snippet_output ? $snippet_output : ''; | |
| 86 | - } catch ( Throwable $exception ) { | |
| 87 | - while ( ob_get_level() > $buffer_level ) { | |
| 88 | - ob_end_clean(); | |
| 89 | - } | |
| 90 | - | |
| 91 | - return WINP_Error_Handler::handle_exception( $exception ); | |
| 92 | - } finally { | |
| 93 | - // Clear snippet context after execution. | |
| 94 | - WINP_Error_Handler::clear_current_snippet(); | |
| 95 | - } | |
| 64 | + eval( $snippet_content ); | |
| 96 | 65 | } |
| 97 | 66 | } |