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

Moves to the template loader hooks and functions into lib/compat folder #37149

Merged
merged 2 commits into from
Dec 7, 2021

Conversation

youknowriad
Copy link
Contributor

See #37141 for the reasoning here.

@youknowriad youknowriad added [Type] Code Quality Issues or PRs that relate to code quality Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Dec 6, 2021
@youknowriad youknowriad requested a review from ockham December 6, 2021 13:09
@youknowriad youknowriad self-assigned this Dec 6, 2021
@youknowriad youknowriad force-pushed the update/sync-fse-code-1 branch from 28797dc to f5eba78 Compare December 6, 2021 13:09
/**
* Renders the markup for the current template.
*/
function gutenberg_render_the_template() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe that function is useless and I can't find it on Core either. So either we remove it or backport it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@scruffian Is this something that is needed for universal themes? Should this be backported as render_block_template or something in Core?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems to me like this has been obsolete since #28319 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed 👍 I was confusing this with block_template_part which is used in hybrid themes.

@youknowriad youknowriad force-pushed the move/template-loader-code branch from 27a4e55 to 708b641 Compare December 6, 2021 13:13
@@ -17,7 +17,7 @@ function gutenberg_add_template_loader_filters() {
if ( 'embed' === $template_type ) { // Skip 'embed' for now because it is not a regular template type.
continue;
}
add_filter( str_replace( '-', '', $template_type ) . '_template', 'gutenberg_override_query_template', 20, 3 );
add_filter( str_replace( '-', '', $template_type ) . '_template', 'gutenberg_locate_block_template', 20, 3 );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just aligning function names with Core equivalents

Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

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

Since we're moving template-canvas.php, I believe we also need to update this path:

diff --git a/lib/compat/wordpress-5.9/block-template.php b/lib/compat/wordpress-5.9/block-template.php
index 85b0a91b4e..4a57ece0d8 100644
--- a/lib/compat/wordpress-5.9/block-template.php
+++ b/lib/compat/wordpress-5.9/block-template.php
@@ -102,7 +102,7 @@ function gutenberg_locate_block_template( $template, $type, array $templates ) {
        add_action( 'wp_head', 'gutenberg_render_title_tag', 1 ); // ...and make it unconditional.
 
        // This file will be included instead of the theme's template file.
-       return gutenberg_dir_path() . 'lib/template-canvas.php';
+       return gutenberg_dir_path() . 'lib/compat/wordpress-5.9/template-canvas.php';
 }
 
 /**

Base automatically changed from update/sync-fse-code-1 to trunk December 7, 2021 09:00
@youknowriad youknowriad force-pushed the move/template-loader-code branch from 708b641 to c1ef717 Compare December 7, 2021 09:05
@youknowriad
Copy link
Contributor Author

@ockham good catch, I actually did that change but somehow it got lost before the commit.

Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

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

Thanks Riad, this LGTM now! 👍

(We might want to wait for confirmation for this question before merging.)

@youknowriad youknowriad merged commit f2e5e95 into trunk Dec 7, 2021
@youknowriad youknowriad deleted the move/template-loader-code branch December 7, 2021 12:03
@github-actions github-actions bot added this to the Gutenberg 12.2 milestone Dec 7, 2021
@noisysocks noisysocks removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Dec 13, 2021
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.

3 participants