From 462faefd7e47508523036d17dcd08ad183ff3c36 Mon Sep 17 00:00:00 2001 From: emhr Date: Sat, 25 May 2013 23:45:43 -0400 Subject: [PATCH] Bug Fixes for display and restoring of revisions Decode revisions when displayed and do not re-encode them upon restore. --- syntaxhighlighter.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/syntaxhighlighter.php b/syntaxhighlighter.php index 07e3e67..903d6ae 100644 --- a/syntaxhighlighter.php +++ b/syntaxhighlighter.php @@ -57,11 +57,14 @@ function __construct() { add_filter( 'group_forum_topic_text_before_save', array( $this, 'encode_shortcode_contents_slashed' ), 1 ); // BuddyPress // Out of the database for editing - add_filter( 'the_editor_content', array( $this, 'the_editor_content' ), 1 ); // Posts - add_filter( 'comment_edit_pre', array( $this, 'decode_shortcode_contents' ), 1 ); // Comments - add_filter( 'bp_get_the_topic_text', array( $this, 'decode_shortcode_contents' ), 1 ); // BuddyPress - add_filter( 'bp_get_the_topic_post_edit_text', array( $this, 'decode_shortcode_contents' ), 1 ); // BuddyPress - + add_filter( 'the_editor_content', array( $this, 'the_editor_content' ), 1 ); // Posts + add_filter( 'comment_edit_pre', array( $this, 'decode_shortcode_contents' ), 1 ); // Comments + add_filter( 'bp_get_the_topic_text', array( $this, 'decode_shortcode_contents' ), 1 ); // BuddyPress + add_filter( 'bp_get_the_topic_post_edit_text', array( $this, 'decode_shortcode_contents' ), 1 ); // BuddyPress + + // Out of the database for displaying revisions + add_filter( '_wp_post_revision_field_post_content', array( $this, 'decode_shortcode_contents' ) ); // Revisions + // Outputting SyntaxHighlighter's JS and CSS add_action( 'wp_head', array( $this, 'output_header_placeholder' ), 15 ); add_action( 'admin_head', array( $this, 'output_header_placeholder' ), 15 ); // For comments @@ -418,6 +421,11 @@ function encode_shortcode_contents_slashed_noquickedit( $content ) { if ( ! empty( $_POST ) && !empty( $_POST['action'] ) && 'inline-save' == $_POST['action'] ) return $content; + // Revision content is already encoded when restored, so we don't need to encode it (again) + if ( isset( $_GET['revision'] ) ) { + return $content; + } + return $this->encode_shortcode_contents_slashed( $content ); }