Skip to content

Commit

Permalink
Adds shortcode_ui_preview filter
Browse files Browse the repository at this point in the history
Added `shortcode_ui_preview` filter to give the option to modify the preview in the WYSIWYG.
  • Loading branch information
joseadrian committed Aug 29, 2017
1 parent e49302b commit 594c08d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions inc/class-shortcode-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 594c08d

Please sign in to comment.