[wp-trac] [WordPress Trac] #52920: Editor: Abstract block editor configuration
WordPress Trac
noreply at wordpress.org
Thu Apr 22 07:19:29 UTC 2021
#52920: Editor: Abstract block editor configuration
-------------------------------------------------+-------------------------
Reporter: gziolo | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: 5.8
Component: Editor | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests dev- | Focuses:
feedback needs-dev-note |
-------------------------------------------------+-------------------------
Comment (by gziolo):
@jeremyfelt, that would be ideal to go with the approach you outlined. We
are discussing the same issue in
https://github.com/WordPress/gutenberg/pull/31027. Let me share the part
that worries me the most if we go this route:
`block_categories` and other filters involved here, they have the `$post`
object as a param which is not set outside of the edit post page. More
importantly, we provide examples for this filter that depend on unguarded
`$post` usage at https://github.com/WordPress/gutenberg/blob/trunk/docs
/reference-guides/filters/block-filters.md#managing-block-categories:
{{{#!php
<?php
// my-plugin.php
function my_plugin_block_categories( $categories, $post ) {
if ( $post->post_type !== 'post' ) {
return $categories;
}
return array_merge(
$categories,
array(
array(
'slug' => 'my-category',
'title' => __( 'My category', 'my-plugin'
),
'icon' => 'wordpress',
),
)
);
}
add_filter( 'block_categories', 'my_plugin_block_categories', 10, 2 );
}}}
If you have some ideas on how to address it safely then we should do it.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52920#comment:25>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list