Skip to content

Commit

Permalink
🐛 Fix error preventing debugging messages from appearing
Browse files Browse the repository at this point in the history
Addresses #60, closes #54. Is #51 still needed?
  • Loading branch information
MWDelaney committed Apr 29, 2021
1 parent 795527e commit 0fe333e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions sage-acf-gutenberg-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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));
}
}
}
Expand Down Expand Up @@ -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) {
//
}
Expand All @@ -222,7 +219,7 @@ function removeBladeExtension($filename)
return $matches[1];
}
// Return FALSE if the filename doesn't match the pattern.
return FALSE;
return false;
}

/**
Expand Down

0 comments on commit 0fe333e

Please sign in to comment.