From ef4a278194aa5228be4362681046d708a7d166d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Thu, 22 Jun 2023 12:10:53 -0300 Subject: [PATCH] Fix fatal errors --- src/api.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/api.php b/src/api.php index 36c6bf8..b526404 100644 --- a/src/api.php +++ b/src/api.php @@ -45,6 +45,9 @@ function get_gutenberg_templates(string $post_type): array function get_gutenberg_template(string $template) { global $wp_gutenberg_templates; + if (empty($wp_gutenberg_templates)) { + return null; + } foreach ($wp_gutenberg_templates as $post_type => $templates) { if (isset($templates[$template])) { return $templates[$template]; @@ -59,6 +62,9 @@ function get_gutenberg_template(string $template) function get_gutenberg_template_by_file(string $template_file): ?array { global $wp_gutenberg_templates; + if (empty($wp_gutenberg_templates)) { + return null; + } foreach ($wp_gutenberg_templates as $post_type => $templates) { foreach ($templates as $template => $args) { if ($args['template_file'] === $template_file) {