From 0fe333ef866226e783f3cbc056dc10cce3e5a690 Mon Sep 17 00:00:00 2001 From: MWDelaney Date: Thu, 29 Apr 2021 09:48:21 -0400 Subject: [PATCH] :bug: Fix error preventing debugging messages from appearing Addresses #60, closes #54. Is #51 still needed? --- sage-acf-gutenberg-blocks.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sage-acf-gutenberg-blocks.php b/sage-acf-gutenberg-blocks.php index 5c4e825..ba2e100 100644 --- a/sage-acf-gutenberg-blocks.php +++ b/sage-acf-gutenberg-blocks.php @@ -43,7 +43,6 @@ foreach ($template_directory as $template) { if (!$template->isDot() && !$template->isDir()) { - // Strip the file extension to get the slug $slug = removeBladeExtension($template->getFilename()); // If there is no slug (most likely because the filename does @@ -131,17 +130,17 @@ // If the SupportsInnerBlocks header is set in the template, restrict this block mode feature if (!empty($file_headers['supports_jsx'])) { - $data['supports']['jsx'] = $file_headers['supports_jsx'] === 'true' ? true : false; + $data['supports']['jsx'] = $file_headers['supports_jsx'] === 'true' ? true : false; } // If the SupportsAlignText header is set in the template, restrict this block mode feature if (!empty($file_headers['supports_align_text'])) { - $data['supports']['align_text'] = $file_headers['supports_align_text'] === 'true' ? true : false; + $data['supports']['align_text'] = $file_headers['supports_align_text'] === 'true' ? true : false; } // If the SupportsAlignContent header is set in the template, restrict this block mode feature if (!empty($file_headers['supports_align_text'])) { - $data['supports']['align_content'] = $file_headers['supports_align_content'] === 'true' ? true : false; + $data['supports']['align_content'] = $file_headers['supports_align_content'] === 'true' ? true : false; } // If the SupportsMultiple header is set in the template, restrict this block multiple feature @@ -150,7 +149,7 @@ } // Register the block with ACF - \acf_register_block_type( apply_filters( "sage/blocks/$slug/register-data", $data ) ); + \acf_register_block_type(apply_filters("sage/blocks/$slug/register-data", $data)); } } } @@ -192,16 +191,14 @@ function sage_blocks_callback($block, $content = '', $is_preview = false, $post_ $view = ltrim($directory, 'views/') . '/' . $slug; if (isSage10()) { - if (\Roots\view()->exists($view)) { // Use Sage's view() function to echo the block and populate it with data echo \Roots\view($view, ['block' => $block]); } - } else { try { // Use Sage 9's template() function to echo the block and populate it with data - echo \App\template($view, ['block' => $block]); + echo \App\template(locate_template("${directory}/${slug}"), ['block' => $block]); } catch (\Exception $e) { // } @@ -222,7 +219,7 @@ function removeBladeExtension($filename) return $matches[1]; } // Return FALSE if the filename doesn't match the pattern. - return FALSE; + return false; } /**