diff --git a/inc/class-shortcode-ui.php b/inc/class-shortcode-ui.php index 6e08d476..2b4df74a 100644 --- a/inc/class-shortcode-ui.php +++ b/inc/class-shortcode-ui.php @@ -440,6 +440,25 @@ private function render_shortcode_for_preview( $shortcode, $post_id = null ) { // @codingStandardsIgnoreEnd } + // Get the Shortcode tag and set the response if any + preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $shortcode, $matches ); + $shortcode_tag = isset( $matches[1][0] ) ? $matches[1][0] : ''; + + /** + * Filter the shortcode preview + * + * Used to render a custom preview for the shortcodes on the editor + * + * @param string $pre_option The default value to return if the custom preview hasn't been set. + * @param string $shortcode_tag Shortcode tag name. + * @param string $shortcode Shortcode used. + * @param array $options Shortcode UI options for the shortcode tag + */ + $response = apply_filters( 'shortcode_ui_preview', false, $shortcode_tag, $shortcode, $this->get_shortcode( $shortcode_tag ) ); + if( false !== $response ) { + return $response; + } + ob_start(); /** * Fires before shortcode is rendered in preview.