Making WordPress.org


Ignore:
Timestamp:
12/19/2022 12:30:31 AM (4 years ago)
Author:
dd32
Message:

Support Forum: Blocks: Remove custom empty-blocks-content filter added in [12340].

See https://github.com/Automattic/blocks-everywhere/pull/113.
See #6608.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-blocks.php

    r12341 r12344  
    5252                add_action( 'admin_init', [ $this, 'admin_init' ] );
    5353                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' ] );
    5854
    5955                // Reverse twemoji replacements. Before bbPress sanitization gets to it.
     
    289285
    290286        /**
    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( '@(<|&lt;)!--.*?--(>|&gt;)@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         /**
    310287         * Reverse twemoji upon save.
    311288         *
     
    314291        public function reverse_twemoji_upon_save( $content ) {
    315292                // <img ... class="emoji" alt="emojihere" ... />
    316                 if ( false === str_contains( $content, 'emoji' ) ) {
     293                if ( ! str_contains( $content, 'emoji' ) ) {
    317294                        return $content;
    318295                }
Note: See TracChangeset for help on using the changeset viewer.