From dd6b2fef1f98d6b8b4a06ab6bfaee7577ca1d45a Mon Sep 17 00:00:00 2001 From: emhr Date: Sat, 8 Jun 2013 09:34:24 -0400 Subject: [PATCH 1/2] Adding basic support for bbPress Parse shortcodes in topics and replies. Encode when creating and saving topic and replies. Decode when retrieving topics and replies. Output shortcode script for bbPress front-end editor instance --- syntaxhighlighter.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/syntaxhighlighter.php b/syntaxhighlighter.php index 07e3e67..f441c7c 100644 --- a/syntaxhighlighter.php +++ b/syntaxhighlighter.php @@ -46,6 +46,8 @@ function __construct() { add_filter( 'the_content', array( $this, 'parse_shortcodes' ), 7 ); // 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 + add_filter( 'bbp_get_topic_content', array( $this, 'parse_shortcodes' ), 7 ); // bbPress + add_filter( 'bbp_get_reply_content', array( $this, 'parse_shortcodes' ), 7 ); // bbPress // Exempt shortcodes from wptexturize() add_filter( 'no_texturize_shortcodes', array( $this, 'no_texturize_shortcodes' ) ); @@ -55,12 +57,18 @@ function __construct() { add_filter( 'pre_comment_content', array( $this, 'encode_shortcode_contents_slashed' ), 1 ); // Comments add_filter( 'group_forum_post_text_before_save', array( $this, 'encode_shortcode_contents_slashed' ), 1 ); // BuddyPress add_filter( 'group_forum_topic_text_before_save', array( $this, 'encode_shortcode_contents_slashed' ), 1 ); // BuddyPress + add_filter( 'bbp_new_topic_pre_content', array( $this, 'encode_shortcode_contents_slashed' ), 1 ); // bbPress + add_filter( 'bbp_new_reply_pre_content', array( $this, 'encode_shortcode_contents_slashed' ), 1 ); // bbPress + add_filter( 'bbp_edit_topic_pre_content', array( $this, 'encode_shortcode_contents_slashed' ), 1 ); // bbPress + add_filter( 'bbp_edit_reply_pre_content', array( $this, 'encode_shortcode_contents_slashed' ), 1 ); // bbPress // 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( 'bbp_get_topic_content', array( $this, 'decode_shortcode_contents' ), 1 ); // bbPress + add_filter( 'bbp_get_reply_content', array( $this, 'decode_shortcode_contents' ), 1 ); // bbPress // Outputting SyntaxHighlighter's JS and CSS add_action( 'wp_head', array( $this, 'output_header_placeholder' ), 15 ); @@ -68,6 +76,10 @@ function __construct() { add_action( 'wp_footer', array( $this, 'maybe_output_scripts' ), 15 ); add_action( 'admin_footer', array( $this, 'maybe_output_scripts' ), 15 ); // For comments + // Front end output of scortcodes script if "fancy editor" is enabled by bbPress + if ( function_exists( 'bbp_use_wp_editor' ) && bbp_use_wp_editor() ) + add_action( 'bbp_head', array( $this, 'output_shortcodes_for_tinymce' ) ); + // Admin hooks add_action( 'admin_init', array( $this, 'register_setting' ) ); add_action( 'admin_menu', array( $this, 'register_settings_page' ) ); From ad58aac2fdd4eaa6202505123581e0ada067fd98 Mon Sep 17 00:00:00 2001 From: emhr Date: Sat, 8 Jun 2013 09:52:56 -0400 Subject: [PATCH 2/2] Added support for bbPress quickedits The content of replies and topics is stored encoded in database. Do not (re)encode content when spitting topics, merging replies, trashing topics or replies, or toggling spam on topics or replies. --- syntaxhighlighter.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/syntaxhighlighter.php b/syntaxhighlighter.php index f441c7c..a0a687d 100644 --- a/syntaxhighlighter.php +++ b/syntaxhighlighter.php @@ -430,6 +430,18 @@ function encode_shortcode_contents_slashed_noquickedit( $content ) { if ( ! empty( $_POST ) && !empty( $_POST['action'] ) && 'inline-save' == $_POST['action'] ) return $content; + // bbPress (front-end) admin links for topic split or merge and reply move + if ( !empty( $_POST ) && !empty( $_POST['action'] ) && ( 'bbp-move-reply' == $_POST['action'] || 'bbp-split-topic' == $_POST['action'] || 'bbp-merge-topic' == $_POST['action'] ) ) + return $content; + + // bbPress (front-end) admin links for trash + if ( !empty( $_GET ) && !empty( $_GET['action'] ) && ( 'bbp_toggle_topic_trash' == $_GET['action'] || 'bbp_toggle_reply_trash' == $_GET['action'] ) ) + return $content; + + // bbPress admin links (front-end) and quick links (wp-admin) for spam + if ( !empty( $_GET ) && !empty( $_GET['action'] ) && ( 'bbp_toggle_topic_spam' == $_GET['action'] || 'bbp_toggle_reply_spam' == $_GET['action'] ) ) + return $content; + return $this->encode_shortcode_contents_slashed( $content ); }