Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove GB prefixed functions from template part #36180

Merged

Conversation

ntsekouras
Copy link
Contributor

@ntsekouras ntsekouras commented Nov 3, 2021

This will be needed for back porting the FSE changes in core: WordPress/wordpress-develop#1796

) {
$block['attrs']['theme'] = wp_get_theme()->get_stylesheet();
$has_updated_content = true;
if ( ! function_exists( '_inject_theme_attribute_in_block_template_content' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that works until we do some changes in these functions for future releases. It might never be required so I think it's fine for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general is it okay to rename function without the GB prefix in the plugin? I guess for functionality that is added through filters or actions we don't rename and bail early like here, but in util functions?

We already have the problem of not being able to change some functions like here.

Are there any instructions for how these cases are handled? --cc @gziolo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no rules for updating the functionality that is in WP core. If the utility function doesn’t fit anymore you can always deprecate it and create a new one.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this solves the template part block code issue. I did rename a lot more functions on the core patch and there's a lot of functions that might need to have a function check before redefining here.

@ntsekouras ntsekouras marked this pull request as ready for review November 3, 2021 16:23
@ntsekouras
Copy link
Contributor Author

I did rename a lot more functions on the core patch and there's a lot of functions that might need to have a function check before redefining here.

Will look into these changes.

@ntsekouras ntsekouras merged commit b40b61f into trunk Nov 3, 2021
@ntsekouras ntsekouras deleted the try/remove-gb-prefixed-functions-from-template-part branch November 3, 2021 16:26
@github-actions github-actions bot added this to the Gutenberg 11.9 milestone Nov 3, 2021
@ntsekouras ntsekouras changed the title Try: Remove GB prefixed functions from template part Remove GB prefixed functions from template part Nov 3, 2021
@andrewserong andrewserong added the [Type] Code Quality Issues or PRs that relate to code quality label Nov 4, 2021
@andrewserong andrewserong changed the title Remove GB prefixed functions from template part Remove GB prefixed functions from template part Nov 4, 2021
@gziolo
Copy link
Member

gziolo commented Nov 4, 2021

It would be helpful to move the code that is about to be include in WordPress 5.9 to the lib/compat/wordpress-5.9/ as discussed in #33810. It will help to remove code from the plugin once it becomes obsolete. At the moment, there is no easy way to tell when those functions could be dropped from the plugin.

lib/full-site-editing/block-templates.php Show resolved Hide resolved
) {
$block['attrs']['theme'] = wp_get_theme()->get_stylesheet();
$has_updated_content = true;
if ( ! function_exists( '_inject_theme_attribute_in_block_template_content' ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no rules for updating the functionality that is in WP core. If the utility function doesn’t fit anymore you can always deprecate it and create a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants