[wp-trac] [WordPress Trac] #61696: Make overriding and back porting classes from gutenberg repo easier
WordPress Trac
noreply at wordpress.org
Thu Jul 18 17:02:45 UTC 2024
#61696: Make overriding and back porting classes from gutenberg repo easier
--------------------------+-----------------------------
Reporter: spacedmonkey | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: 5.0
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
The gutenberg repo overrides a number of core classes, including but not
limited to
- WP_Theme_JSON ->
[https://github.com/WordPress/gutenberg/blob/0ba206b88120ef93da94cd7df6e427cf918700e9/lib
/class-wp-theme-json-gutenberg.php WP_Theme_JSON_Gutenberg]
- WP_Theme_JSON_Data ->
[https://github.com/WordPress/gutenberg/blob/0ba206b88120ef93da94cd7df6e427cf918700e9/lib
/class-wp-theme-json-data-gutenberg.php WP_Theme_JSON_Data_Gutenberg]
- WP_Theme_JSON_Resolver ->
[https://github.com/WordPress/gutenberg/blob/0ba206b88120ef93da94cd7df6e427cf918700e9/lib
/class-wp-theme-json-resolver-gutenberg.php WP_Theme_JSON_Resolver]
- WP_Theme_JSON_Schema ->
[https://github.com/WordPress/gutenberg/blob/0ba206b88120ef93da94cd7df6e427cf918700e9/lib
/class-wp-theme-json-schema-gutenberg.php WP_Theme_JSON_Schema_Gutenberg]
- WP_Duotone ->
[https://github.com/WordPress/gutenberg/blob/0ba206b88120ef93da94cd7df6e427cf918700e9/lib
/class-wp-duotone-gutenberg.php WP_Duotone_Gutenberg]
Currently this has a number of issues, including
- Overrides are not perfect, so it is unperdictable what version of this
class will be used, core or gutenberg.
- It makes backporting changes to these classes a manaul process.
- It makes it hard to write unit test the code.
Recommendation
Add filters similar to `parse_blocks` function.
{{{#!php
function parse_blocks( $content ) {
/**
* Filter to allow plugins to replace the server-side block
parser.
*
* @since 5.0.0
*
* @param string $parser_class Name of block parser class.
*/
$parser_class = apply_filters( 'block_parser_class',
'WP_Block_Parser' );
$parser = new $parser_class();
return $parser->parse( $content );
}
}}}
Possible issues:
A number of these classes, have static methods and consts, that make
referencing class name by string a little harder.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61696>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list