sage-acf-wp-blocks
sage-acf-wp-blocks copied to clipboard
Fixed error in Sage9 with multiple block folders
New feature with multiple folders in sage9 throw the critical error with wrong file paths. Foreach loop for filter "sage-acf-gutenberg-blocks-templates" mixed wrong path with block files and return the error. I've added new filter "sage-acf-gutenberg-blocks-other-templates" for other folders. This filter can be override in filters.php by new array. (readme updated with example). Default filter "sage-acf-gutenberg-blocks-templates" return only 'views/blocks' if developer not decide to use more block folders.
Not tested with sage10 but, the variable $view return the same result as before
Duplicate of #51
Not exactly, previous request with bug fixes not working. Foreach loop return each blocks to all folders and return error because can't find duplicate blocks in different location.
Hi @blift, thank you for your feedback. I had another look at my code. If I understand you correctly, you ran into an issue when having a duplicate block in a different location? So for example /blocks/banner.blade.php and /blokks/banner.blade.php? Interesting, I did not test that scenario. 😊 In this case I see that both blocks render in the page.
However, I see the same issue / result happening in your solution when using your filter in this scenario:
add_filter('sage-acf-gutenberg-blocks-other-templates', function ($folders) {
$folders[] = 'views/blokks';
return $folders;
});
I don't think that having a different filter with the same purpose fixes the issue in this scenario. Am I overlooking something in your PR? 🤔
Hi @robmeijerink, thanks for new commit and code check. No that wasn't issue with duplicate the same block in different location. Previous pull #51 mixed wrong path to folder with blocks. I've checked your fixed commit, added yesterday, and works fine.