Making WordPress.org


Ignore:
Timestamp:
04/18/2024 05:30:51 AM (5 months ago)
Author:
dd32
Message:

Support Forums: Blocks: Disable the image block in the reviews forums.

Fixes #6712.

File:
1 edited

Legend:

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

    r13561 r13562  
    6565    }
    6666
     67    /**
     68     * Whether the current pageload appears to be related to the reviews forum.
     69     */
     70    protected function is_review_related() {
     71        if ( bbp_is_single_forum() ) {
     72            return ( bbp_get_forum_id() == Plugin::REVIEWS_FORUM_ID );
     73        }
     74
     75        if ( bbp_is_single_topic() || bbp_is_topic_edit() ) {
     76            return ( bbp_get_topic_forum_id() == Plugin::REVIEWS_FORUM_ID );
     77        }
     78
     79        if ( bbp_is_single_view() ) {
     80            return ( bbp_get_view_id() == 'reviews' );
     81        }
     82
     83        return false;
     84    }
     85
    6786    public function allowed_blocks( $blocks ) {
    68         // See ::editor_settings();
    69         $blocks[] = 'core/image';
    70         $blocks[] = 'core/embed';
     87        if ( ! $this->is_review_related() ) {
     88            // See ::editor_settings();
     89            $blocks[] = 'core/image';
     90            $blocks[] = 'core/embed';
     91        }
    7192
    7293        return array_unique( $blocks );
     
    7495
    7596    public function editor_settings( $settings ) {
    76         // This adds the image block, but only with 'add from url' as an option.
    77         $settings['iso']['blocks']['allowBlocks'][] = 'core/image';
    78 
    79         // Allows embeds and might fix pasting links sometimes not working.
    80         $settings['iso']['blocks']['allowBlocks'][] = 'core/embed';
     97        if ( ! $this->is_review_related() ) {
     98            // This adds the image block, but only with 'add from url' as an option.
     99            $settings['iso']['blocks']['allowBlocks'][] = 'core/image';
     100
     101            // Allows embeds and might fix pasting links sometimes not working.
     102            $settings['iso']['blocks']['allowBlocks'][] = 'core/embed';
     103        }
    81104
    82105        // Adds a navigation button in the toolbar.
Note: See TracChangeset for help on using the changeset viewer.