Changeset 12341
- Timestamp:
- 12/16/2022 04:55:38 AM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-blocks.php
r12340 r12341 54 54 55 55 // Implement Blocks-no-empty-replies. 56 add_filter( 'bbp_new_reply_pre_content', [ $this, 'bbp_new_reply_pre_content' ] ); 56 add_filter( 'bbp_new_reply_pre_content', [ $this, 'no_empty_block_replies' ] ); 57 add_filter( 'bbp_new_topic_pre_content', [ $this, 'no_empty_block_replies' ] ); 58 59 // Reverse twemoji replacements. Before bbPress sanitization gets to it. 60 add_filter( 'bbp_new_reply_pre_content', [ $this, 'reverse_twemoji_upon_save' ], 5 ); 61 add_filter( 'bbp_new_topic_pre_content', [ $this, 'reverse_twemoji_upon_save' ], 5 ); 57 62 } 58 63 … … 286 291 * Don't allow empty block replies. 287 292 */ 288 public function bbp_new_reply_pre_content( $content ) {293 public function no_empty_block_replies( $content ) { 289 294 // Remove HTML tags. 290 295 $no_html_content = wp_strip_all_tags( $content, true ); … … 303 308 304 309 /** 310 * Reverse twemoji upon save. 311 * 312 * @see https://core.trac.wordpress.org/ticket/52219 313 */ 314 public function reverse_twemoji_upon_save( $content ) { 315 // <img ... class="emoji" alt="emojihere" ... /> 316 if ( false === str_contains( $content, 'emoji' ) ) { 317 return $content; 318 } 319 320 $content = wp_unslash( $content ); 321 322 // Replace all img.emoji with the alt text. 323 $content = preg_replace( 324 '~<img[^>]+class="emoji"[^>]+alt="(.*?)"+[^>]+>~i', 325 '$1', 326 $content 327 ); 328 329 return wp_slash( $content ); // Expect slashed. 330 } 331 332 /** 305 333 * Register pre-defs for the forums. 306 334 */
Note: See TracChangeset
for help on using the changeset viewer.