Skip to content

Commit

Permalink
Fix Empty Block Templates output string (#30145)
Browse files Browse the repository at this point in the history
* Fix Empty Block Templates output string
  • Loading branch information
carolinan authored Mar 31, 2021
1 parent 3f0f8f9 commit 6484a26
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/full-site-editing/template-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) && 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 );
}
Expand Down Expand Up @@ -174,7 +182,10 @@ function gutenberg_get_the_template_html() {
global $wp_embed;

if ( ! $_wp_current_template_content ) {
return '<h1>' . esc_html__( 'No matching template found', 'gutenberg' ) . '</h1>';
if ( is_user_logged_in() ) {
return '<h1>' . esc_html__( 'No matching template found', 'gutenberg' ) . '</h1>';
}
return;
}

$content = $wp_embed->run_shortcode( $_wp_current_template_content );
Expand Down

0 comments on commit 6484a26

Please sign in to comment.