Changeset 12340
- Timestamp:
- 12/16/2022 02:50:12 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
r12334 r12340 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, 'bbp_new_reply_pre_content' ] ); 54 57 } 55 58 … … 281 284 282 285 /** 286 * Don't allow empty block replies. 287 */ 288 public function bbp_new_reply_pre_content( $content ) { 289 // Remove HTML tags. 290 $no_html_content = wp_strip_all_tags( $content, true ); 291 // Remove HTML comments (including encoded). 292 $no_html_content = preg_replace( '@(<|<)!--.*?--(>|>)@i', '', $no_html_content ); 293 // Remove whitespace. 294 $no_html_content = trim( $no_html_content ); 295 296 if ( empty( $no_html_content ) ) { 297 // Trigger bbPress's internal "This looks empty!" checks. See bbp_new_reply_handler(). 298 $content = ''; 299 } 300 301 return $content; 302 } 303 304 /** 283 305 * Register pre-defs for the forums. 284 306 */
Note: See TracChangeset
for help on using the changeset viewer.