• Hi, I have a suggestion for render callback function that will output shortcode for non admin pages the same way it’s done in main wordpress shortcode block (I had trouble with some complicated shortcodes otherwise).

    function swp_rnk_shortcode_preview_callback($atts)
    {
    	if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
    	ob_start();
    ?>
    	<div class="swp-rnk-preview">
    		<?php
    		echo ! empty( $atts['shortcodeText'] ) ? do_shortcode( $atts['shortcodeText'] ) : '';
    		?>
    	</div>
    <?php
    	$html = ob_get_clean();
    	return $html;
    	} else return wpautop($atts['shortcodeText'] );
    }
  • The topic ‘suggestion for render code’ is closed to new replies.