From f2e312c863a7a19d3787758ae62fc5cf788ed8a5 Mon Sep 17 00:00:00 2001 From: Joseadrian Ochoa Date: Sat, 26 Aug 2017 04:18:42 -0500 Subject: [PATCH] Adds `shortcode_ui_preview` filter Added `shortcode_ui_preview` filter to give the option to modify the preview in the WYSIWYG. --- inc/class-shortcode-ui.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/inc/class-shortcode-ui.php b/inc/class-shortcode-ui.php index 6e08d476..99d46d4c 100644 --- a/inc/class-shortcode-ui.php +++ b/inc/class-shortcode-ui.php @@ -439,6 +439,12 @@ private function render_shortcode_for_preview( $shortcode, $post_id = null ) { setup_postdata( $post ); // @codingStandardsIgnoreEnd } + + // Get the Shortcode tag and set the response if any + preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $shortcode, $matches ); + if( isset($matches[1][0]) && $response = apply_filters( 'shortcode_ui_preview', false, $matches[1][0], $shortcode, $this->get_shortcode( $matches[1][0] ) ) ) { + return $response; + } ob_start(); /**