Making WordPress.org

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#3907 closed defect (bug) (fixed)

Gutenberg runs wpautop before Syntaxhighlighter runs its shortcodes

Reported by: pento's profile pento Owned by:
Milestone: Priority: normal
Component: General Keywords: needs-patch
Cc:

Description

The Syntaxhighlighter plugin runs its shortcodes on the_content at priority 7, which is usually before wpautop runs, at priority 10.

The Gutenberg plugin moves wpautop to priority 6, which causes all sorts of weirdness. You can see it easily fixed by applying this change:

Index: syntaxhighlighter.php
===================================================================
--- syntaxhighlighter.php	(revision 1969451)
+++ syntaxhighlighter.php	(working copy)
@@ -43,7 +43,7 @@
 		load_plugin_textdomain( 'syntaxhighlighter', false, '/syntaxhighlighter/localization' );
 
 		// Display hooks
-		add_filter( 'the_content',                        array( $this, 'parse_shortcodes' ),                              7 ); // Posts
+		add_filter( 'the_content',                        array( $this, 'parse_shortcodes' ),                              5 ); // Posts
 		add_filter( 'comment_text',                       array( $this, 'parse_shortcodes_comment' ),                      7 ); // Comments
 		add_filter( 'bp_get_the_topic_post_content',      array( $this, 'parse_shortcodes' ),                              7 ); // BuddyPress

This bug should be fixed by switching from the Gutenberg plugin to WordPress 5.0, but a workaround would be a mu-plugin that changes the priority of parse_shortcodes.

Change History (3)

#1 @Otto42
6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Since this is an external, instead of patching the plugin, I added a mu-plugin to override the priority of that filter. If the plugin itself is changed, then we can simply remove the mu-plugin file.

Fixed in [dotorg:14535].

#2 @azaozz
6 years ago

Ah, great job @pento and @Otto42! Lets ping @viper007bond to update the plugin.

Last edited 6 years ago by azaozz (previous) (diff)

#3 @pento
6 years ago

The Syntaxhighlighter plugin doesn't need updating for this, really: this is just a quirk in the Gutenberg plugin that's fix in 5.0, and will be removed from Gutenberg shortly after 5.0.

Note: See TracTickets for help on using tickets.