Skip to:
Content

bbPress.org

Changeset 7389


Ignore:
Timestamp:
12/29/2025 05:07:24 PM (4 months ago)
Author:
johnjamesjacoby
Message:

API - Blocks: Do not use the block editor for bbPress post types.

This commit ensures that the legacy (non-block, meta-box based) new/edit post GUI is still used, even though show_in_rest is set to true for the forum/topic/reply post types, by introducing a new function on top of the core use_block_editor_for_post_type filter.

This prevents admin-area edits from saving block-based content when it is not yet properly handled or supported for the 2.7.0 release, even though blocks are (via the shortcodes & theme compatibility APIs).

See #3403.

In trunk, for 2.7.

Location:
trunk/src/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/functions.php

    r7385 r7389  
    1515
    1616/**
    17  * Return array of bbPress registered post types.
     17 * Return array of bbPress registered post type names.
    1818 *
    1919 * @since 2.6.0 bbPress (r6813)
     
    139139
    140140/** Misc **********************************************************************/
     141
     142/**
     143 * Filters whether or not to use the block editor for bbPress post types.
     144 *
     145 * As of 2.7.0 this is explicitly false, because the `show_in_rest` property
     146 * of each post type is now set to true, and because support for blocks in
     147 * user-facing forum content is not properly handled yet.
     148 *
     149 * The default return value of this function is highly likely to change once
     150 * the block editor is integrated into the Forum/Topic/Reply experience.
     151 *
     152 * If you're feeling adventurous or working on this feature, override this
     153 * filter with
     154 *
     155 * @since 2.7.0 bbPress (r7388)
     156 *
     157 * @param bool   $use       Optional. Default false. If using.
     158 * @param string $post_type Optional. Default empty string. The post type to check.
     159 *
     160 * @return bool
     161 */
     162function bbp_filter_use_block_editor_for_post_type( $use = false, $post_type = '' ) {
     163
     164    // Get bbPress post types
     165    $bbp_post_types = bbp_get_post_types();
     166
     167    // Compare post types
     168    $is_post_type = in_array( $post_type, $bbp_post_types, true );
     169    $retval       = ! $is_post_type;
     170
     171    // Filter & return
     172    return (bool) apply_filters( 'bbp_filter_use_block_editor_for_post_type', $retval, $is_post_type, $use, $post_type );
     173}
    141174
    142175/**
  • trunk/src/includes/core/filters.php

    r7380 r7389  
    7575// User Creation
    7676add_filter( 'signup_user_meta', 'bbp_user_add_role_to_signup_meta', 10 );
     77
     78// No block editor for bbPress post types
     79add_filter( 'use_block_editor_for_post_type', 'bbp_filter_use_block_editor_for_post_type', 10, 2 );
    7780
    7881/**
Note: See TracChangeset for help on using the changeset viewer.