From fadb68b65d7baab4f800ee80985b07f86527d2fa Mon Sep 17 00:00:00 2001 From: Copons Date: Mon, 23 Nov 2020 19:40:42 +0000 Subject: [PATCH 1/3] Avoid throwing warnings if there are no terms for a template or part --- lib/full-site-editing/templates-utils.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/full-site-editing/templates-utils.php b/lib/full-site-editing/templates-utils.php index 62fb7f6da83bbc..b7afd49248b814 100644 --- a/lib/full-site-editing/templates-utils.php +++ b/lib/full-site-editing/templates-utils.php @@ -53,7 +53,10 @@ function gutenberg_render_templates_lists_custom_column( $column_name, $post_id } if ( 'theme' === $column_name ) { - $terms = get_the_terms( $post_id, 'wp_theme' ); + $terms = get_the_terms( $post_id, 'wp_theme' ); + if ( ! is_array( $terms ) ) { + return; + } $themes = array(); $is_file_based = false; foreach ( $terms as $term ) { From d650e5e81f5439250a07af5b5d93e8082914486b Mon Sep 17 00:00:00 2001 From: Copons Date: Mon, 23 Nov 2020 19:51:58 +0000 Subject: [PATCH 2/3] Improve the validity check --- lib/full-site-editing/templates-utils.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/full-site-editing/templates-utils.php b/lib/full-site-editing/templates-utils.php index b7afd49248b814..95f1866db32fa6 100644 --- a/lib/full-site-editing/templates-utils.php +++ b/lib/full-site-editing/templates-utils.php @@ -54,7 +54,7 @@ function gutenberg_render_templates_lists_custom_column( $column_name, $post_id if ( 'theme' === $column_name ) { $terms = get_the_terms( $post_id, 'wp_theme' ); - if ( ! is_array( $terms ) ) { + if ( empty( $terms ) ) { return; } $themes = array(); @@ -80,7 +80,7 @@ function gutenberg_render_templates_lists_custom_column( $column_name, $post_id * @param array $views The edit views to filter. */ function gutenberg_filter_templates_edit_views( $views ) { - $post_type = get_current_screen()->post_type; + $post_type = get_current_screen()->post_type; $url = add_query_arg( array( 'post_type' => $post_type, From 7c82a6569df86efaa0a7223ecd46726afb5c7881 Mon Sep 17 00:00:00 2001 From: Copons Date: Tue, 24 Nov 2020 10:48:00 +0000 Subject: [PATCH 3/3] Also handle WP_Error case --- lib/full-site-editing/templates-utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/full-site-editing/templates-utils.php b/lib/full-site-editing/templates-utils.php index 95f1866db32fa6..5430470cfa640a 100644 --- a/lib/full-site-editing/templates-utils.php +++ b/lib/full-site-editing/templates-utils.php @@ -54,7 +54,7 @@ function gutenberg_render_templates_lists_custom_column( $column_name, $post_id if ( 'theme' === $column_name ) { $terms = get_the_terms( $post_id, 'wp_theme' ); - if ( empty( $terms ) ) { + if ( empty( $terms ) || is_wp_error( $terms ) ) { return; } $themes = array();