TinyMCE Advanced
syntax highlighting (3 posts)

  1. mxmanuel
    Posted 2 years ago #

    I have set up some shortcodes in my functions.php to be used in the editor and would love to highlight them in the editor.
    Is that possible and if so: how?

    Here is what I set up in my functions.php:

    /* Open Div */
    add_shortcode('div', 'be_div_shortcode');
    function be_div_shortcode($atts) {
    	extract(shortcode_atts(array('class' => '', 'id' => '' ), $atts));
    	$return = '<div';
    	if (!empty($class)) $return .= ' class="'.$class.'"';
    	if (!empty($id)) $return .= ' id="'.$id.'"';
    	$return .= '>';
    	return $return;
    /* Close Div */
    add_shortcode('end-div', 'be_end_div_shortcode');
    function be_end_div_shortcode($atts) {
    	return '</div>';
     function shortcode_empty_paragraph_fix( $content ) {
            $array = array (
                '<p>[' => '[',
                ']</p>' => ']',
                ']<br />' => ']'
            $content = strtr( $content, $array );
            return $content;
        add_filter( 'the_content', 'shortcode_empty_paragraph_fix' );

    Thanx for any answer


  2. Andrew Ozz
    WordPress Dev
    Plugin Author

    Posted 2 years ago #

    Shortcodes in the editor are just plain text strings. There's no direct way to highlight them.

    Depending on how you want the users to interact with your shortcode in the editor, you can replace it with a "placeholder image" similarly to how the more and nextpage tags work.

  3. mxmanuel
    Posted 2 years ago #

    Thanks a lot for your response.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • TinyMCE Advanced
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.