|
4 | 4 |
|
5 | 5 | Plugin Name: SyntaxHighlighter Evolved
|
6 | 6 | Plugin URI: http://www.viper007bond.com/wordpress-plugins/syntaxhighlighter/
|
7 |
| -Version: 3.4.0 |
| 7 | +Version: 3.4.1 |
8 | 8 | Description: 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.
|
9 | 9 | Author: Alex Mills (Viper007Bond)
|
10 | 10 | Author URI: http://www.viper007bond.com/
|
|
21 | 21 |
|
22 | 22 | class SyntaxHighlighter {
|
23 | 23 | // All of these variables are private. Filters are provided for things that can be modified.
|
24 |
| - var $pluginver = '3.4.0'; // Plugin version |
| 24 | + var $pluginver = '3.4.1'; // Plugin version |
25 | 25 | var $agshver = false; // Alex Gorbatchev's SyntaxHighlighter version (dynamically set below due to v2 vs v3)
|
26 | 26 | var $shfolder = false; // Controls what subfolder to load SyntaxHighlighter from (v2 or v3)
|
27 | 27 | var $settings = array(); // Contains the user's settings
|
@@ -73,7 +73,10 @@ function __construct() {
|
73 | 73 | add_filter( 'plugin_action_links', array( $this, 'settings_link' ), 10, 2 );
|
74 | 74 |
|
75 | 75 | // Editor Blocks
|
76 |
| - if ( function_exists( 'parse_blocks' ) ) { |
| 76 | + if ( |
| 77 | + function_exists( 'parse_blocks' ) // WordPress 5.0+ |
| 78 | + || function_exists( 'the_gutenberg_project' ) // Gutenberg plugin for older WordPress |
| 79 | + ) { |
77 | 80 | add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
|
78 | 81 | add_action( 'the_content', array( $this, 'enable_brushes_used_in_blocks' ), 0 );
|
79 | 82 | }
|
@@ -317,7 +320,10 @@ function enqueue_block_editor_assets() {
|
317 | 320 | : $this->pluginver
|
318 | 321 | );
|
319 | 322 |
|
320 |
| - wp_set_script_translations( 'syntaxhighlighter-blocks', 'syntaxhighlighter' ); |
| 323 | + // WordPress 5.0+ only, no Gutenberg plugin support |
| 324 | + if ( function_exists( 'wp_set_script_translations' ) ) { |
| 325 | + wp_set_script_translations( 'syntaxhighlighter-blocks', 'syntaxhighlighter' ); |
| 326 | + } |
321 | 327 |
|
322 | 328 | natsort( $this->brush_names );
|
323 | 329 |
|
@@ -353,7 +359,13 @@ function enable_brushes_used_in_blocks( $content ) {
|
353 | 359 | return $content;
|
354 | 360 | }
|
355 | 361 |
|
356 |
| - $blocks = parse_blocks( $content ); |
| 362 | + if ( function_exists( 'parse_blocks' ) ) { // WP 5.0+ |
| 363 | + $blocks = parse_blocks( $content ); |
| 364 | + } elseif ( Function_exists( 'gutenberg_parse_blocks' ) ) { // Gutenberg plugin |
| 365 | + $blocks = gutenberg_parse_blocks( $content ); |
| 366 | + } else { |
| 367 | + return $content; |
| 368 | + } |
357 | 369 |
|
358 | 370 | foreach ( $blocks as $block ) {
|
359 | 371 | if ( empty( $block['blockName'] ) || 'syntaxhighlighter/code' !== $block['blockName'] ) {
|
|
0 commit comments