PHPackages                             itinerisltd/acf-gutenblocks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. itinerisltd/acf-gutenblocks

Abandoned → [log1x/acf-composer](/?search=log1x%2Facf-composer)Wordpress-plugin[Utility &amp; Helpers](/categories/utility)

itinerisltd/acf-gutenblocks
===========================

Easily create Gutenberg Blocks with Advanced Custom Fields

0.5.0(4y ago)8314.5k14[4 issues](https://github.com/ItinerisLtd/acf-gutenblocks/issues)[1 PRs](https://github.com/ItinerisLtd/acf-gutenblocks/pulls)MITPHPPHP ^7.3CI passing

Since Feb 26Pushed 3mo ago9 watchersCompare

[ Source](https://github.com/ItinerisLtd/acf-gutenblocks)[ Packagist](https://packagist.org/packages/itinerisltd/acf-gutenblocks)[ RSS](/packages/itinerisltd-acf-gutenblocks/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)Dependencies (3)Versions (10)Used By (0)

acf-gutenblocks
===============

[](#acf-gutenblocks)

[![Packagist Version](https://camo.githubusercontent.com/c224c38131f4c8e3b02f3a3cfe500e69227ab078b538183d460c479d09fe6ed4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6974696e657269736c74642f6163662d677574656e626c6f636b732e737667)](https://packagist.org/packages/itinerisltd/acf-gutenblocks)[![PHP from Packagist](https://camo.githubusercontent.com/9f16e31a34c3267caf7065c040cabf7153f08da01c2037be812e9405c490f9ad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6974696e657269736c74642f6163662d677574656e626c6f636b732e737667)](https://packagist.org/packages/itinerisltd/acf-gutenblocks)[![Packagist Downloads](https://camo.githubusercontent.com/32930dc871012d467511c570b801ccfca9e9b47f2415a2e343a7ec10a5b02706/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6974696e657269736c74642f6163662d677574656e626c6f636b732e737667)](https://packagist.org/packages/itinerisltd/acf-gutenblocks)[![GitHub License](https://camo.githubusercontent.com/a37576c46653fead9355df52fdc00eeab686a949f0b8f9b8f6844dd9769f72d6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6974696e657269736c74642f6163662d677574656e626c6f636b732e737667)](https://github.com/ItinerisLtd/acf-gutenblocks/blob/master/LICENSE)[![Hire Itineris](https://camo.githubusercontent.com/28070f6fe57ce0e650e45ceddf0f294c6ebb8e5248af50e801ed5d81026c076c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f486972652d4974696e657269732d6666363962342e737667)](https://www.itineris.co.uk/contact/)

Easily create Gutenberg Blocks with Advanced Custom Fields.

- [Minimum Requirements](#minimum-requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Block definition](#block-definition)
    - [Block constructors](#block-constructors)
        - [`AbstractBlock`](#abstractblock)
        - [`AbstractBladeBlock`](#abstractbladeblock)
- [Template data](#template-data)
- [Fields](#fields)
    - [Simple array](#simple-array)
    - [ACF Builder](#acf-builder)
- [Filters](#filters)
    - [`acf_gutenblocks/blocks` - `(array $blocks)`](#acf_gutenblocksblocks---array-blocks)
    - [`acf_gutenblocks/get_initializables` - `(array $initializables)`](#acf_gutenblocksget_initializables---array-initializables)
    - [`acf_gutenblocks/render_block_frontend_path` - `(string $path, Block $block)`](#acf_gutenblocksrender_block_frontend_path---string-path-block-block)
    - [`acf_gutenblocks/render_block_html_output` - `(string $html, Block $block)`](#acf_gutenblocksrender_block_html_output---string-html-block-block)
    - [`acf_gutenblocks/default_icon` - `(string $icon)`](#acf_gutenblocksdefault_icon---string-icon)
    - [`acf_gutenblocks/block_settings` - `(array $settings, string $name)`](#acf_gutenblocksblock_settings---array-settings-string-name)
- [FAQ](#faq)
    - [Can I use a different template rendering option?](#can-i-use-a-different-template-rendering-option)
    - [Do I need to adhere to any structure or standard?](#do-i-need-to-adhere-to-any-structure-or-standard)
    - [Why not load all Blocks from a given directory? It's much easier!](#why-not-load-all-blocks-from-a-given-directory-its-much-easier)
    - [My Blade template doesn't load.](#my-blade-template-doesnt-load)
- [Author Information](#author-information)
- [Feedback](#feedback)
- [Change log](#change-log)
- [License](#license)

Minimum Requirements
--------------------

[](#minimum-requirements)

- [PHP](https://secure.php.net/manual/en/install.php) &gt;= 8.1
- [WordPress](https://wordpress.org/download/) (preferrably [Bedrock](https://roots.io/bedrock/)) &gt;= 5.0
- [Advanced Custom Fields](https://www.advancedcustomfields.com/) &gt;= 5.8.0

Installation
------------

[](#installation)

```
$ composer require itinerisltd/acf-gutenblocks
```

Usage
-----

[](#usage)

1. Activate the plugin
2. Create a directory to store your Blocks in your plugin or theme
3. Define your [Block](#block-definition) and frontend template

```
Blocks/
  └── Testimonial/
      ├── views/
      │   └── frontend.php # Block template file
      └── Testimonial.php # Block constructor and controller

```

4. Register your Block by appending the Block class name as a string to the `acf_gutenblocks/blocks` filter

```
use Fully\Qualified\Namespace\Testimonial;
use App\Blocks\Banner;

add_filter('acf_gutenblocks/blocks', function (array $blocks): array {
    $new_blocks = [
        Testimonial::class,
        Banner::class,
    ];
    return array_merge($blocks, $new_blocks);
});
```

Block definition
----------------

[](#block-definition)

Blocks are registered using PHP classes to provide a simple "Controller" to allow separation of logic and functionality from your template. This can really help to isolate and organise code that is intended only for that Block.

To create a Block, you must extend your class from the available Block constructors and pass any valid [`acf_register_block()`](https://www.advancedcustomfields.com/resources/acf_register_block/) arguments to the parent constructor. Here can also define your controller methods for use within your template.

```
# Blocks/Testimonial/Testimonial.php
