Skip to content

A wrapper around ACF Builder for registering ACF Blocks. Default usage is for Sage 10.

Notifications You must be signed in to change notification settings

kmdig/acf-block-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

$ composer require kmdigital/acf-block-builder

Usage

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:

$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).

About

A wrapper around ACF Builder for registering ACF Blocks. Default usage is for Sage 10.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages