Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kmdig/acf-block-builder
A wrapper around ACF Builder for registering ACF Blocks. Default usage is for Sage 10.
https://github.com/kmdig/acf-block-builder
Last synced: 3 months ago
JSON representation
A wrapper around ACF Builder for registering ACF Blocks. Default usage is for Sage 10.
- Host: GitHub
- URL: https://github.com/kmdig/acf-block-builder
- Owner: kmdig
- Created: 2019-04-20T21:28:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-06-16T01:07:03.000Z (over 5 years ago)
- Last Synced: 2024-05-02T04:17:14.375Z (7 months ago)
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 10
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ACF Block Builder
A light wrapper around ACF Builder for registering ACF Blocks.
Default usage is for Sage 10, however, other themes are
supported.## Installation
Within your theme or plugin:
```shell
$ composer require kmdigital/acf-block-builder
```## Usage
```php
use KMDigital\AcfBlockBuilder\Block;$testimonial = new Block('testimonial');
$testimonial
->addWysiwyg('content')
->addText('person')
->addText('where')
->addText('when');add_action('acf/init', function () use ($testimonial) {
acf_add_local_field_group($testimonial->build());
});
```There are additional methods you can use for setting and
overriding block options:```php
$testimonial
// Allows you to set a custom title for the block.
// Default is the block name/slug titlized.
->setTitle('Review')// Allows you to set the block description. Default is none.
->setDescription('A review with meta.')// Allows you to set the block description. Default is a block.
->setIcon('star-half')// Allows you to set the block category. Default is none.
->setCategory('common')// Allows you to set the block keywords. Default is none.
->setKeywords('review', 'testimonial')// Allows you to use a different rendering function. Default is Sage 10 (Acorn).
->renderWith(['Me\\View\\', 'render']);
```## Default rendering function
The default rendering function is for Sage 10 or projects using
Acorn. It searches for templates in `resources/views/blocks` (if
`resources/views` is your default views path).