Plugin Directory

Changeset 1353216 for syntaxhighlighter


Ignore:
Timestamp:
02/18/2016 08:32:17 AM (10 years ago)
Author:
Viper007Bond
Message:

v3.2.1

https://github.com/Viper007Bond/syntaxhighlighter/releases/tag/v3.2.1

Location:
syntaxhighlighter/trunk
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • syntaxhighlighter/trunk

    • Property svn:ignore
      •  

        old new  
        11.git
         2.gitignore
        23.idea
        3 .gitignore
         4readme.md
  • syntaxhighlighter/trunk/readme.txt

    r1351361 r1353216  
    5555
    5656== ChangeLog ==
     57
     58= Version 3.2.1 =
     59
     60* Fix shortcode issues that would occur during post editing if the code contained what looked like opening HTML tags such as `<?php`. See [this forum thread](https://wordpress.org/support/topic/php-opening-closing-tags-break-code-blocks) for details.
    5761
    5862= Version 3.2.0 =
  • syntaxhighlighter/trunk/syntaxhighlighter.php

    r1351361 r1353216  
    55Plugin Name:  SyntaxHighlighter Evolved
    66Plugin URI:   http://www.viper007bond.com/wordpress-plugins/syntaxhighlighter/
    7 Version:      3.2.0
     7Version:      3.2.1
    88Description:  Easily post syntax-highlighted code to your site without having to modify the code at all. Uses Alex Gorbatchev's <a href="http://alexgorbatchev.com/wiki/SyntaxHighlighter">SyntaxHighlighter</a>. <strong>TIP:</strong> Don't use the Visual editor if you don't want your code mangled. TinyMCE will "clean up" your HTML.
    99Author:       Alex Mills (Viper007Bond)
     
    2222class SyntaxHighlighter {
    2323    // All of these variables are private. Filters are provided for things that can be modified.
    24     var $pluginver            = '3.2.0';  // Plugin version
     24    var $pluginver            = '3.2.1';  // Plugin version
    2525    var $agshver              = false;    // Alex Gorbatchev's SyntaxHighlighter version (dynamically set below due to v2 vs v3)
    2626    var $shfolder             = false;    // Controls what subfolder to load SyntaxHighlighter from (v2 or v3)
     
    349349     * Phew!
    350350     *
    351      * @param string $content  The post content.
    352      * @param string $callback The callback function that should be used for add_shortcode()
     351     * @param string $content     The post content.
     352     * @param string $callback    The callback function that should be used for add_shortcode()
     353     * @param bool   $ignore_html When true, shortcodes inside HTML elements will be skipped.
    353354     *
    354355     * @return string The filtered content, with this plugin's shortcodes parsed.
    355356     */
    356     function shortcode_hack( $content, $callback ) {
     357    function shortcode_hack( $content, $callback, $ignore_html = true ) {
    357358        global $shortcode_tags;
    358359
     
    371372        }
    372373
    373         // Extra escape escaped shortcodes because do_shortcode() is going to strip a pair of square brackets when it runs
    374         $content = preg_replace_callback(
    375             '/' . get_shortcode_regex( $this->shortcodes ) . '/',
    376             array( $this, 'shortcode_hack_extra_escape_escaped_shortcodes' ),
    377             $content
    378         );
    379 
    380         // Do the shortcodes (only this plugins's are registered)
    381         $content = do_shortcode( $content, true );
     374        $regex = '/' . get_shortcode_regex( $this->shortcodes ) . '/';
     375
     376        // Parse the shortcodes (only this plugins's are registered)
     377        if ( $ignore_html ) {
     378            // Extra escape escaped shortcodes because do_shortcode_tag() called by do_shortcode() is going to strip a pair of square brackets when it runs
     379            $content = preg_replace_callback(
     380                $regex,
     381                array( $this, 'shortcode_hack_extra_escape_escaped_shortcodes' ),
     382                $content
     383            );
     384
     385            // Normal, safe parsing
     386            $content = do_shortcode( $content, true );
     387        } else {
     388            // Extra escape escaped shortcodes because do_shortcode_tag() called by do_shortcode() is going to strip a pair of square brackets when it runs.
     389            // Then call do_shortcode_tag(). This is basically do_shortcode() without calling do_shortcodes_in_html_tags() which breaks things.
     390            // For context, see https://wordpress.org/support/topic/php-opening-closing-tags-break-code-blocks
     391            $content = preg_replace_callback(
     392                $regex,
     393                array( $this, 'shortcode_hack_extra_escape_escaped_shortcodes_and_parse' ),
     394                $content
     395            );
     396        }
    382397
    383398        // Put the original shortcodes back
     
    424439    }
    425440
     441    /**
     442     * This is a combination of this class's shortcode_hack_extra_escape_escaped_shortcodes()
     443     * and do_shortcode_tag() for performance reasons so that we don't have to run some regex twice.
     444     *
     445     * @param array $match Regular expression match array.
     446     *
     447     * @return string|false False on failure, otherwise a parse shortcode tag.
     448     */
     449    function shortcode_hack_extra_escape_escaped_shortcodes_and_parse( $match ) {
     450        $match[0] = $this->shortcode_hack_extra_escape_escaped_shortcodes( $match );
     451
     452        return do_shortcode_tag( $match );
     453    }
     454
    426455
    427456    // The main filter for the post contents. The regular shortcode filter can't be used as it's post-wpautop().
     
    433462    // HTML entity encode the contents of shortcodes
    434463    function encode_shortcode_contents( $content ) {
    435         return $this->shortcode_hack( $content, array( $this, 'encode_shortcode_contents_callback' ) );
     464        return $this->shortcode_hack( $content, array( $this, 'encode_shortcode_contents_callback' ), false );
    436465    }
    437466
     
    466495    // HTML entity decode the contents of shortcodes
    467496    function decode_shortcode_contents( $content ) {
    468         return $this->shortcode_hack( $content, array( $this, 'decode_shortcode_contents_callback' ) );
     497        return $this->shortcode_hack( $content, array( $this, 'decode_shortcode_contents_callback' ), false );
    469498    }
    470499
Note: See TracChangeset for help on using the changeset viewer.