Skip to:
Content

bbPress.org

Changeset 7383


Ignore:
Timestamp:
12/26/2025 08:41:12 PM (6 months ago)
Author:
johnjamesjacoby
Message:

API - Blocks: Introduce support for Gutenberg blocks.

This commit includes:

  • bbp_register_blocks sub-action
  • common/blocks.php to register all of the blocks via PHP
  • common/blocks directory that includes a subdirectory for each block.json file
  • admin/assets/js/blocks.js to add block previews & preliminary support for some controls
  • admin/assets/css/blocks.css to help block previews look modern & clean

Fixes #3403.

In trunk, for 2.7.

Props georgestephanis, adamsilverstein, SirLouen, johnjamesjacoby.

Location:
trunk/src
Files:
38 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bbpress.php

    r7380 r7383  
    350350        // Common
    351351        require $this->includes_dir . 'common/ajax.php';
     352        require $this->includes_dir . 'common/blocks.php';
    352353        require $this->includes_dir . 'common/classes.php';
    353354        require $this->includes_dir . 'common/engagements.php';
     
    430431            'register_taxonomies',      // Register taxonomies (topic-tag)
    431432            'register_shortcodes',      // Register shortcodes (bbp-login)
     433            'register_blocks',          // Register blocks (bbp-login)
    432434            'register_views',           // Register the views (no-replies)
    433435            'register_theme_packages',  // Register bundled theme packages (bbp-theme-compat/bbp-themes)
     
    544546                    'public'              => true,
    545547                    'show_ui'             => current_user_can( 'bbp_forums_admin' ),
     548                    'show_in_rest'        => true,
    546549                    'can_export'          => true,
    547550                    'hierarchical'        => true,
     
    573576                    'public'              => true,
    574577                    'show_ui'             => current_user_can( 'bbp_topics_admin' ),
     578                    'show_in_rest'        => true,
    575579                    'can_export'          => true,
    576580                    'hierarchical'        => false,
     
    602606                    'public'              => true,
    603607                    'show_ui'             => current_user_can( 'bbp_replies_admin' ),
     608                    'show_in_rest'        => true,
    604609                    'can_export'          => true,
    605610                    'hierarchical'        => false,
     
    798803
    799804    /**
    800      * Register bbPress meta-data.
     805     * Register the bbPress blocks.
     806     *
     807     * @since 2.7.0 bbPress (r7382)
     808     */
     809    public function register_blocks() {
     810        $this->blocks = new BBP_Blocks();
     811    }
     812
     813    /**
     814     * Register bbPress meta-data
    801815     *
    802816     * Counts added in 2.6.0 to avoid negative values.
  • trunk/src/includes/admin/assets/css/admin.css

    r7268 r7383  
    161161th .bbp_replies_column::before {
    162162    font: 400 20px/0.5 dashicons;
    163     speak: none;
    164163    display: inline-block;
    165164    padding: 0;
  • trunk/src/includes/admin/classes/class-bbp-admin.php

    r7380 r7383  
    890890        $version = bbp_get_asset_version();
    891891
    892         // Register admin CSS with dashicons dependency
    893         wp_register_style( 'bbp-admin-css', $this->css_url . 'admin' . $suffix . '.css', array( 'dashicons' ), $version );
     892        // Register admin CSS
     893        wp_register_style( 'bbp-admin-css',    $this->css_url . 'admin'  . $suffix . '.css', array( 'dashicons' ), $version );
     894        wp_register_style( 'bbp-admin-blocks', $this->css_url . 'blocks' . $suffix . '.css', array(),              $version );
    894895
    895896        // Color schemes are not available when running out of src
     
    926927
    927928    /**
    928      * Registers the bbPress admin color schemes.
    929      *
    930      * Because wp-content can exist outside of the WordPress root there is no
    931      * way to be certain what the relative path of the admin images is.
    932      * We are including the two most common configurations here, just in case.
     929     * Registers the bbPress admin scripts.
    933930     *
    934931     * @since 2.6.0 bbPress (r2521)
     
    943940
    944941        // Header JS
    945         // phpcs:disable WordPress.WP.EnqueuedResourceParameters.NotInFooter
    946         wp_register_script( 'bbp-admin-common-js',  $this->js_url . 'common'    . $suffix . '.js', array( 'jquery', 'suggest'              ), $version );
    947         wp_register_script( 'bbp-admin-topics-js',  $this->js_url . 'topics'    . $suffix . '.js', array( 'jquery'                         ), $version );
    948         wp_register_script( 'bbp-admin-replies-js', $this->js_url . 'replies'   . $suffix . '.js', array( 'jquery', 'suggest'              ), $version );
    949         wp_register_script( 'bbp-converter',        $this->js_url . 'converter' . $suffix . '.js', array( 'jquery', 'postbox', 'dashboard' ), $version );
     942        // phpcs:disable
     943        wp_register_script( 'bbp-admin-blocks',     $this->js_url . 'blocks'    . $suffix . '.js', array( 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-element', 'wp-server-side-render' ), $version );
     944        wp_register_script( 'bbp-admin-common-js',  $this->js_url . 'common'    . $suffix . '.js', array( 'jquery', 'suggest'                     ), $version );
     945        wp_register_script( 'bbp-admin-topics-js',  $this->js_url . 'topics'    . $suffix . '.js', array( 'jquery'                                ), $version );
     946        wp_register_script( 'bbp-admin-replies-js', $this->js_url . 'replies'   . $suffix . '.js', array( 'jquery', 'suggest'                     ), $version );
     947        wp_register_script( 'bbp-converter',        $this->js_url . 'converter' . $suffix . '.js', array( 'jquery', 'postbox', 'dashboard'        ), $version );
    950948        // phpcs:enable
    951949
  • trunk/src/includes/core/actions.php

    r7380 r7383  
    124124add_action( 'bbp_register', 'bbp_register_views',          8  );
    125125add_action( 'bbp_register', 'bbp_register_shortcodes',     10 );
     126add_action( 'bbp_register', 'bbp_register_blocks',         10 );
    126127add_action( 'bbp_register', 'bbp_register_meta',           12 );
    127128
  • trunk/src/includes/core/sub-actions.php

    r7380 r7383  
    213213
    214214/**
     215 * Register the default bbPress blocks.
     216 *
     217 * @since 2.7.0 bbPress (r7382)
     218 */
     219function bbp_register_blocks() {
     220    do_action( 'bbp_register_blocks' );
     221}
     222
     223/**
    215224 * Register the default bbPress meta-data.
    216225 *
     
    258267
    259268/**
    260  * Add the bbPress-specific login forum action
     269 * Add the bbPress-specific login forum action.
    261270 *
    262271 * @since 2.0.0 bbPress (r2753)
  • trunk/src/templates/default/css/bbpress.css

    r7231 r7383  
    2626    overflow: hidden;
    2727    clip: rect(1px, 1px, 1px, 1px);
    28     -webkit-clip-path: inset(50%);
    2928    clip-path: inset(50%);
    3029    border: 0;
Note: See TracChangeset for help on using the changeset viewer.