Make WordPress Core

Opened 3 months ago

Closed 3 months ago

Last modified 3 months ago

#62251 closed feature request (duplicate)

Allow wp_register_block_metadata_collection() in themes

Reported by: wongjn's profile wongjn Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.7
Component: Themes Keywords:
Focuses: Cc:

Description

I am aware that block registration is discouraged in themes, but we have a use case where we only use one theme for a site. In this theme, we have several blocks registered, so it would be good for performance to be able to use wp_register_block_metadata_collection() in a theme.

Currently, the underlying function WP_Block_Metadata_Registry::register_collection() checks valid paths for wp-includes and plugins and rejects all others.

Change History (7)

#1 @gziolo
3 months ago

  • Version set to trunk

#3 @louwie17
3 months ago

This is not only a blocker for themes, but also a blocker for plugins that are symlinked. In WooCommerce we make use of the ABSPATH for registering blocks, which will refer to the official plugin directory instead of the symlinked version.
While it doesn't entirely prevents us from still using it in WooCommerce, it does make testing it more difficult as many of us use symlinks for testing WooCommerce in our local environments.

Here ( https://github.com/woocommerce/woocommerce/pull/51184 ) is the initial implementation of using wp_register_block_metadata_collection() in WooCommerce.

This ticket was mentioned in Slack in #core-editor by louwie17. View the logs.


3 months ago

#5 @swissspidy
3 months ago

  • Milestone Awaiting Review deleted
  • Status changed from new to closed

Looks like we're already tracking this in #62251, so closing as a duplicate.

#6 @wongjn
3 months ago

Thank you for pointing that out @swissspidy. Could you provide a link to the ticket this is a duplicate of please?

#7 @swissspidy
3 months ago

  • Resolution set to duplicate

Argh, I wrote the wrong ticket number above. It was #62140

Note: See TracTickets for help on using tickets.