Changeset 9612
- Timestamp:
- 03/20/2020 04:01:26 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php
r9604 r9612 110 110 add_filter( 'request', array( $this, 'ignore_empty_query_vars' ) ); 111 111 112 // Support ```...``` and {{{...}}} for code blocks. 113 add_filter( 'bbp_new_reply_pre_content', array( $this, 'support_slack_trac_code_trick' ), 19 ); 114 add_filter( 'bbp_new_topic_pre_content', array( $this, 'support_slack_trac_code_trick' ), 19 ); 115 add_filter( 'bbp_new_forum_pre_content', array( $this, 'support_slack_trac_code_trick' ), 19 ); 116 add_filter( 'bbp_edit_reply_pre_content', array( $this, 'support_slack_trac_code_trick' ), 19 ); 117 add_filter( 'bbp_edit_topic_pre_content', array( $this, 'support_slack_trac_code_trick' ), 19 ); 118 add_filter( 'bbp_edit_forum_pre_content', array( $this, 'support_slack_trac_code_trick' ), 19 ); 112 119 } 113 120 … … 1103 1110 } 1104 1111 1112 /** 1113 * Add support for Slack and Trac style code formatting. 1114 * 1115 * Upon edit, the blocks will be unwrapped to bbPress style blocks. 1116 * 1117 * See `bbp_code_trick()` for the regex below. 1118 */ 1119 function support_slack_trac_code_trick( $content ) { 1120 $content = str_replace( array( "\r\n", "\r" ), "\n", $content ); 1121 1122 // Slack style ```...``` Inline and Multiline. 1123 $content = preg_replace_callback( '|(`)``(.*?)```|', 'bbp_encode_callback', $content ); 1124 $content = preg_replace_callback( "!(^|\n)```(.*?)```!s", 'bbp_encode_callback', $content ); 1125 1126 // Trac style {{{...}}} Inline and Multiline. 1127 $content = preg_replace_callback( '|({){{(.*?)}}}|', function( $matches ) { 1128 // bbPress expects `...` for inline code blocks. 1129 $matches[1] = '`'; 1130 return bbp_encode_callback( $matches ); 1131 }, $content ); 1132 $content = preg_replace_callback( "!(^|\n){{{(.*?)}}}!s", 'bbp_encode_callback', $content ); 1133 1134 return $content; 1135 } 1105 1136 }
Note: See TracChangeset
for help on using the changeset viewer.