Skip to content

Commit

Permalink
fix notice (#30928)
Browse files Browse the repository at this point in the history
  • Loading branch information
Addison-Stavlo authored Apr 20, 2021
1 parent 3419065 commit 20b9705
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/block-library/src/template-part/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ function render_block_core_template_part( $attributes ) {
$content = null;
$area = WP_TEMPLATE_PART_AREA_UNCATEGORIZED;

if ( ! empty( $attributes['postId'] ) && get_post_status( $attributes['postId'] ) ) {
$template_part_id = $attributes['postId'];
// If we have a post ID and the post exists, which means this template part
// is user-customized, render the corresponding post content.
$content = get_post( $attributes['postId'] )->post_content;
} elseif (
if (
isset( $attributes['slug'] ) &&
isset( $attributes['theme'] ) &&
wp_get_theme()->get_stylesheet() === $attributes['theme']
Expand Down Expand Up @@ -66,6 +61,10 @@ function render_block_core_template_part( $attributes ) {
}

if ( is_null( $content ) && is_user_logged_in() ) {
if ( ! isset( $attributes['slug'] ) ) {
// If there is no slug this is a placeholder and we dont want to return any message.
return;
}
return sprintf(
/* translators: %s: Template part slug. */
__( 'Template part has been deleted or is unavailable: %s' ),
Expand Down

0 comments on commit 20b9705

Please sign in to comment.