WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/21/2021 05:10:56 AM (8 months ago)
Author:
gziolo
Message:

Editor: Abstract block editor configuration

There are several WordPress hooks defined on the server that depend on $post object that isn’t present on the new screens like edit site, edit widgets, or edit navigation. This patch deprecates existing filters and introduces replacements that are context-aware.

Props azaozz, andraganescu, jeremyfelt, nosolosw, youknowriad.
See #52920.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r50618 r50776  
    21822182
    21832183/**
    2184  * Returns all the block categories that will be shown in the block editor.
    2185  *
    2186  * @since 5.0.0
    2187  *
    2188  * @param WP_Post $post Post object.
    2189  * @return array[] Array of block categories.
    2190  */
    2191 function get_block_categories( $post ) {
    2192     $default_categories = array(
    2193         array(
    2194             'slug'  => 'text',
    2195             'title' => _x( 'Text', 'block category' ),
    2196             'icon'  => null,
    2197         ),
    2198         array(
    2199             'slug'  => 'media',
    2200             'title' => _x( 'Media', 'block category' ),
    2201             'icon'  => null,
    2202         ),
    2203         array(
    2204             'slug'  => 'design',
    2205             'title' => _x( 'Design', 'block category' ),
    2206             'icon'  => null,
    2207         ),
    2208         array(
    2209             'slug'  => 'widgets',
    2210             'title' => _x( 'Widgets', 'block category' ),
    2211             'icon'  => null,
    2212         ),
    2213         array(
    2214             'slug'  => 'theme',
    2215             'title' => _x( 'Theme', 'block category' ),
    2216             'icon'  => null,
    2217         ),
    2218         array(
    2219             'slug'  => 'embed',
    2220             'title' => _x( 'Embeds', 'block category' ),
    2221             'icon'  => null,
    2222         ),
    2223         array(
    2224             'slug'  => 'reusable',
    2225             'title' => _x( 'Reusable Blocks', 'block category' ),
    2226             'icon'  => null,
    2227         ),
    2228     );
    2229 
    2230     /**
    2231      * Filters the default array of block categories.
    2232      *
    2233      * @since 5.0.0
    2234      *
    2235      * @param array[] $default_categories Array of block categories.
    2236      * @param WP_Post $post               Post being loaded.
    2237      */
    2238     return apply_filters( 'block_categories', $default_categories, $post );
    2239 }
    2240 
    2241 /**
    22422184 * Prepares server-registered blocks for the block editor.
    22432185 *
Note: See TracChangeset for help on using the changeset viewer.