Changeset 12344
- Timestamp:
- 12/19/2022 12:30:31 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-blocks.php
r12341 r12344 52 52 add_action( 'admin_init', [ $this, 'admin_init' ] ); 53 53 add_action( 'save_post', [ $this, 'metabox_forum_optin_save_handler' ] ); 54 55 // Implement Blocks-no-empty-replies.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 54 59 55 // Reverse twemoji replacements. Before bbPress sanitization gets to it. … … 289 285 290 286 /** 291 * Don't allow empty block replies.292 */293 public function no_empty_block_replies( $content ) {294 // Remove HTML tags.295 $no_html_content = wp_strip_all_tags( $content, true );296 // Remove HTML comments (including encoded).297 $no_html_content = preg_replace( '@(<|<)!--.*?--(>|>)@i', '', $no_html_content );298 // Remove whitespace.299 $no_html_content = trim( $no_html_content );300 301 if ( empty( $no_html_content ) ) {302 // Trigger bbPress's internal "This looks empty!" checks. See bbp_new_reply_handler().303 $content = '';304 }305 306 return $content;307 }308 309 /**310 287 * Reverse twemoji upon save. 311 288 * … … 314 291 public function reverse_twemoji_upon_save( $content ) { 315 292 // <img ... class="emoji" alt="emojihere" ... /> 316 if ( false ===str_contains( $content, 'emoji' ) ) {293 if ( ! str_contains( $content, 'emoji' ) ) { 317 294 return $content; 318 295 }
Note: See TracChangeset
for help on using the changeset viewer.