#48039 closed defect (bug) (fixed)
Backport block styles server functions from Gutenberg to core
Reported by: | jorgefilipecosta | Owned by: | jorgefilipecosta |
---|---|---|---|
Milestone: | 5.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | |
Focuses: | Cc: |
Description
This patch backports the block styles functionality added to the block editor in https://github.com/WordPress/gutenberg/pull/16356 to the core of WordPress.
Thew block editor was recently updated include this functionality only if it not available in core, so it is compatible with the last version of WordPress and trunk.
How to test
I added the following code to the functions.php file of the enabled theme and verified styles were registered as expected:
add_action(
'enqueue_block_assets',
function() {
wp_register_style( 'myguten-style', get_template_directory_uri() . '/custom-style.css' );
}
);
register_block_style(
'core/quote',
array(
'name' => 'fancy-quote',
'label' => 'Fancy Quote',
'style_handle' => 'myguten-style',
)
);
register_block_style(
'core/quote',
array(
'name' => 'not-fancy-quote',
'label' => 'Not Fancy Quote',
'inline_style' => '.wp-block-quote.is-style-not-fancy-quote { color: blue; }',
)
);
register_block_style(
'core/quote',
array(
'name' => 'unregistered-fancy-quote',
'label' => 'Unregistered Fancy Quote',
'inline_style' => '.wp-block-quote.is-style-unregistered-fancy-quote { color: orange; }',
)
);
unregister_block_style( 'core/quote', 'unregistered-fancy-quote' );
Attachments (1)
Change History (8)
#4
@
5 years ago
- Owner set to jorgefilipecosta
- Resolution set to fixed
- Status changed from new to closed
In 46111:
#6
@
5 years ago
This is causing a fatal error in current trunk with the most recent version of the plugin (6.4.0):
Fatal error: Cannot declare class WP_Block_Styles_Registry, because the name is already in use in wp-content/plugins/gutenberg/lib/class-wp-block-styles-registry.php on line 14
Looks like this was already mentioned in comment:23:ticket:47843 and addressed in https://github.com/WordPress/gutenberg/pull/17429. Is there a timeline for 6.5.0?
LGTM 👍