WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/21/2021 09:30:40 AM (9 months ago)
Author:
gziolo
Message:

Editor: Shape block editor filters to work better with the Gutenberg plugin

This should allow to use new filters in the Gutenberg plugin and therefore it prevents deprecation warnings when in the debug mode.

See #52920.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-editor.php

    r50776 r50777  
    6767function get_block_categories( $editor_name_or_post ) {
    6868    // Assume the post editor when the WP_Post object passed.
    69     $editor_name        = is_object( $editor_name_or_post ) ? 'post-editor' : $editor_name_or_post;
    70     $default_categories = get_default_block_categories();
     69    $editor_name      = is_object( $editor_name_or_post ) ? 'post-editor' : $editor_name_or_post;
     70    $block_categories = get_default_block_categories();
    7171
    7272    /**
     
    7575     * @since 5.8.0
    7676     *
    77      * @param array[] $default_categories Array of categories for block types.
    78      */
    79     $block_categories = apply_filters( "block_categories_{$editor_name}", $default_categories );
     77     * @param array[] $block_categories Array of categories for block types.
     78     * @param string  $editor_name      The name of the editor, e.g. 'post-editor'.
     79     */
     80    $block_categories = apply_filters( 'block_categories_all', $block_categories, $editor_name );
    8081    if ( 'post-editor' === $editor_name ) {
    8182        $post = is_object( $editor_name_or_post ) ? $editor_name_or_post : get_post();
     
    9091         * @param WP_Post $post             Post being loaded.
    9192         */
    92         $block_categories = apply_filters_deprecated( 'block_categories', array( $block_categories, $post ), '5.8.0', "block_categories_{$editor_name}" );
     93        $block_categories = apply_filters_deprecated( 'block_categories', array( $block_categories, $post ), '5.8.0', 'block_categories_all' );
    9394    }
    9495
     
    109110
    110111    /**
    111      * Filters the allowed block types for the given editor, defaulting to true (all
    112      * registered block types supported).
     112     * Filters the allowed block types for all editor types, defaulting to `true`
     113     * (all registered block types supported).
     114     *
    113115     *
    114116     * @since 5.8.0
     
    116118     * @param bool|array $allowed_block_types Array of block type slugs, or
    117119     *                                        boolean to enable/disable all.
    118      */
    119     $allowed_block_types = apply_filters( "allowed_block_types_{$editor_name}", $allowed_block_types );
     120     * @param string     $editor_name         The name of the editor, e.g. 'post-editor'.
     121     */
     122    $allowed_block_types = apply_filters( 'allowed_block_types_all', $allowed_block_types, $editor_name );
     123
     124    /**
     125     * Filters the allowed block types for the given editor, defaulting to `true`
     126     * (all registered block types supported).
     127     *
     128     * The dynamic portion of the hook name, `$editor_name`, refers to the name
     129     * of the editor type, e.g. 'post-editor', 'site-editor', etc.
     130     *
     131     * @since 5.8.0
     132     *
     133     * @param bool|array $allowed_block_types Array of block type slugs, or
     134     *                                        boolean to enable/disable all.
     135     * @param string     $editor_name         The name of the editor, e.g. 'post-editor'.
     136     */
     137    $allowed_block_types = apply_filters( "allowed_block_types_{$editor_name}", $allowed_block_types, $editor_name );
    120138    if ( 'post-editor' === $editor_name ) {
    121139        $post = get_post();
     
    132150         * @param WP_Post    $post                The post resource data.
    133151         */
    134         $allowed_block_types = apply_filters_deprecated( 'allowed_block_types', array( $allowed_block_types, $post ), '5.8.0', "allowed_block_types_{$editor_name}" );
     152        $allowed_block_types = apply_filters_deprecated( 'allowed_block_types', array( $allowed_block_types, $post ), '5.8.0', 'allowed_block_types_all' );
    135153    }
    136154
     
    242260
    243261    /**
     262     * Filters the settings to pass to the block editor for all editor type.
     263     *
     264     * @since 5.8.0
     265     *
     266     * @param array  $editor_settings Default editor settings.
     267     * @param string $editor_name     The name of the editor, e.g. 'post-editor'.
     268     */
     269    $editor_settings = apply_filters( 'block_editor_settings_all', $editor_settings, $editor_name );
     270
     271    /**
    244272     * Filters the settings to pass to the block editor for a given editor type.
    245273     *
    246      * @since 5.8.0
    247      *
    248      * @param array $editor_settings Default editor settings.
    249      */
    250     $editor_settings = apply_filters( "block_editor_settings_{$editor_name}", $editor_settings );
     274     * The dynamic portion of the hook name, `$editor_name`, refers to the name
     275     * of the editor type, e.g. 'post-editor', 'site-editor', etc.
     276     *
     277     * @since 5.8.0
     278     *
     279     * @param array  $editor_settings Default editor settings.
     280     * @param string $editor_name     The name of the editor, e.g. 'post-editor'.
     281     */
     282    $editor_settings = apply_filters( "block_editor_settings_{$editor_name}", $editor_settings, $editor_name );
    251283    if ( 'post-editor' === $editor_name ) {
    252284        $post = get_post();
     
    261293         * @param WP_Post $post            Post being edited.
    262294         */
    263         $editor_settings = apply_filters_deprecated( 'block_editor_settings', array( $editor_settings, $post ), '5.8.0', "block_editor_settings_{$editor_name}" );
     295        $editor_settings = apply_filters_deprecated( 'block_editor_settings', array( $editor_settings, $post ), '5.8.0', 'block_editor_settings_all' );
    264296    }
    265297
Note: See TracChangeset for help on using the changeset viewer.