From 4f123582ad1c741a6cd0a5a6276e0662616d55ae Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Tue, 23 Mar 2021 15:14:59 +0100 Subject: [PATCH 1/2] Fix Empty Block Templates output string --- lib/full-site-editing/template-loader.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/full-site-editing/template-loader.php b/lib/full-site-editing/template-loader.php index f90f07c02fff55..30413437235c42 100644 --- a/lib/full-site-editing/template-loader.php +++ b/lib/full-site-editing/template-loader.php @@ -79,8 +79,16 @@ function gutenberg_override_query_template( $template, $type, array $templates = } if ( $current_template ) { - $_wp_current_template_content = empty( $current_template->content ) ? __( 'Empty template.', 'gutenberg' ) : $current_template->content; - + if ( empty( $current_template->content ) && isset( $current_template->title ) && is_user_logged_in() ) { + $_wp_current_template_content = + sprintf( + /* translators: %s: Template title */ + __( 'Empty template: %s', 'gutenberg' ), + $current_template->title + ); + } elseif ( ! empty( $current_template->content ) ) { + $_wp_current_template_content = $current_template->content; + } if ( isset( $_GET['_wp-find-template'] ) ) { wp_send_json_success( $current_template ); } @@ -174,7 +182,10 @@ function gutenberg_get_the_template_html() { global $wp_embed; if ( ! $_wp_current_template_content ) { - return '

' . esc_html__( 'No matching template found', 'gutenberg' ) . '

'; + if ( is_user_logged_in() ) { + return '

' . esc_html__( 'No matching template found', 'gutenberg' ) . '

'; + } + return; } $content = $wp_embed->run_shortcode( $_wp_current_template_content ); From 9c3d12681029f1a776bdef0aacc52df42eea4e9c Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Tue, 30 Mar 2021 14:37:08 +0200 Subject: [PATCH 2/2] Update template-loader.php --- lib/full-site-editing/template-loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/full-site-editing/template-loader.php b/lib/full-site-editing/template-loader.php index 30413437235c42..c828a27c99a7bd 100644 --- a/lib/full-site-editing/template-loader.php +++ b/lib/full-site-editing/template-loader.php @@ -79,7 +79,7 @@ function gutenberg_override_query_template( $template, $type, array $templates = } if ( $current_template ) { - if ( empty( $current_template->content ) && isset( $current_template->title ) && is_user_logged_in() ) { + if ( empty( $current_template->content ) && is_user_logged_in() ) { $_wp_current_template_content = sprintf( /* translators: %s: Template title */