Skip to content

Instantly share code, notes, and snippets.

@jurecuhalev
jurecuhalev / register-block-testimonial.php
Last active February 22, 2022 13:34 — forked from nicooprat/custom-callback.php
Create an ACF block with Sage 9 & Blade
add_action('acf/init', function() {
if( function_exists('acf_register_block') ) {
// Look into views/blocks
$dir = new \DirectoryIterator(\locate_template("views/blocks/"));
// Loop through found blocks
foreach ($dir as $fileinfo) {
if (!$fileinfo->isDot()) {
$slug = str_replace('.blade.php', '', $fileinfo->getFilename());
// Get infos from file
$file_path = \locate_template("views/blocks/${slug}.blade.php");