All Projects → StoutLogic → Acf Builder

StoutLogic / Acf Builder

Licence: gpl-2.0
An Advanced Custom Field Configuration Builder

Projects that are alternatives of or similar to Acf Builder

Private Composer Installer
Composer install helper outsourcing sensitive keys from the package URL into environment variables
Stars: ✭ 168 (-65.85%)
Mutual labels:  wordpress, acf, composer
Acf Pro Installer
A composer install helper for Advanced Custom Fields PRO
Stars: ✭ 265 (-46.14%)
Mutual labels:  wordpress, acf, composer
React Wp Rest
A boilerplate for pairing the WP Rest API with a server-rendered React app
Stars: ✭ 167 (-66.06%)
Mutual labels:  wordpress, acf
Wordpress Heroku
This project is a template for installing and running WordPress 5.x on Heroku.
Stars: ✭ 198 (-59.76%)
Mutual labels:  wordpress, composer
Acf Extended
ACF Extended Plugin
Stars: ✭ 199 (-59.55%)
Mutual labels:  wordpress, acf
Acf Codifier
A wrapper class to help write more readable ACF field declarations.
Stars: ✭ 114 (-76.83%)
Mutual labels:  wordpress, acf
Acf Tools
Advanced Custom Fields code made simple! 🙌
Stars: ✭ 121 (-75.41%)
Mutual labels:  wordpress, acf
Wpstarter
Easily bootstrap whole site Composer packages for WordPress.
Stars: ✭ 182 (-63.01%)
Mutual labels:  wordpress, composer
Podlove Publisher
Podlove Podcast Publisher for WordPress
Stars: ✭ 241 (-51.02%)
Mutual labels:  wordpress, composer
Acf Fluent
✒️ A fluent interface for the Advanced Custom Fields WordPress plugin
Stars: ✭ 264 (-46.34%)
Mutual labels:  wordpress, acf
Plate
Plate: a super stripped-down WordPress starter theme for developers.
Stars: ✭ 110 (-77.64%)
Mutual labels:  wordpress, acf
Awps
A Modern WordPress Starter Theme for savvy Developers
Stars: ✭ 319 (-35.16%)
Mutual labels:  wordpress, composer
Wordplate
WordPlate is a wrapper around WordPress. It's like building any other WordPress website with themes and plugins. Just with sprinkles on top.
Stars: ✭ 1,594 (+223.98%)
Mutual labels:  wordpress, composer
Base Camp
Awesome WordPress starter theme for developers based on modern web technologies.
Stars: ✭ 135 (-72.56%)
Mutual labels:  wordpress, composer
Fewbricks
Write code to create ACF field groups, fields and re-usable modules.
Stars: ✭ 100 (-79.67%)
Mutual labels:  wordpress, acf
Acf Star Rating Field
A simple star rating field for ACF.
Stars: ✭ 94 (-80.89%)
Mutual labels:  wordpress, acf
Wordpress
Automatically updated WordPress composer package
Stars: ✭ 94 (-80.89%)
Mutual labels:  wordpress, composer
Beetbox
Pre-provisioned L*MP stack
Stars: ✭ 94 (-80.89%)
Mutual labels:  wordpress, composer
Extended Acf
Register advanced custom fields with object oriented PHP
Stars: ✭ 212 (-56.91%)
Mutual labels:  wordpress, acf
Mozart
Developers tool for WordPress plugins: Wraps all your projects dependencies in your own namespace, in order to prevent conflicts with other plugins loading the same dependencies in different versions.
Stars: ✭ 277 (-43.7%)
Mutual labels:  wordpress, composer

ACF Builder

Create configuration arrays for Advanced Custom Fields Pro using the builder pattern and a fluent API.

Quickly create, register, and reuse ACF configurations, and keep them in your source code repository. To read more about registering ACF fields via php consult https://www.advancedcustomfields.com/resources/register-fields-via-php/

Latest Stable Version Build Status Scrutinizer Code Quality Join the chat at https://gitter.im/StoutLogic/acf-builder

Simple Example

$banner = new StoutLogic\AcfBuilder\FieldsBuilder('banner');
$banner
    ->addText('title')
    ->addWysiwyg('content')
    ->addImage('background_image')
    ->setLocation('post_type', '==', 'page')
        ->or('post_type', '==', 'post');

add_action('acf/init', function() use ($banner) {
   acf_add_local_field_group($banner->build());
});

$banner->build(); will return:

[
    'key' => 'group_banner',
    'title' => 'Banner',
    'fields' => [
        [
            'key' => 'field_title',
            'name' => 'title',
            'label' => 'Title',
            'type' => 'text'
        ],
        [
            'key' => 'field_content',
            'name' => 'content',
            'label' => 'Content',
            'type' => 'wysiwyg'
        ],
        [
            'key' => 'field_background_image',
            'name' => 'background_image',
            'label' => 'Background Image',
            'type' => 'image'
        ],
    ],
    'location' => [
        [
            [
                'param' => 'post_type',
                'operator' => '==',
                'value' => 'page'
            ]
        ],
        [
            [
                'param' => 'post_type',
                'operator' => '==',
                'value' => 'post'
            ]
        ]
    ]
]

As you can see it saves you a lot of typing and is less error-prone. But brevity and correctness isn't the only benefit, you can reuse field configurations in multiple places. For example, a group of fields used for backgrounds:

Reuse Example

use StoutLogic\AcfBuilder\FieldsBuilder;

$background = new FieldsBuilder('background');
$background
    ->addTab('Background')
    ->addImage('background_image')
    ->addTrueFalse('fixed')
        ->instructions("Check to add a parallax effect where the background image doesn't move when scrolling")
    ->addColorPicker('background_color');

$banner = new FieldsBuilder('banner');
$banner
    ->addTab('Content')
    ->addText('title')
    ->addWysiwyg('content')
    ->addFields($background)
    ->setLocation('post_type', '==', 'page');

$section = new FieldsBuilder('section');
$section
    ->addTab('Content')
    ->addText('section_title')
    ->addRepeater('columns', ['min' => 1, 'layout' => 'block'])
        ->addTab('Content')
        ->addText('title')
        ->addWysiwyg('content')
        ->addFields($background)
        ->endRepeater()
    ->addFields($background)
    ->setLocation('post_type', '==', 'page');

Here a background field group is created, and then used in two other field groups, including twice in the section field group. This can really DRY up your code and keep your admin UI consistent. If you wanted to add a light/dark field for the text color field based on the background used, it would just need to be added in one spot and used everywhere.

Install

Use composer to install:

composer require stoutlogic/acf-builder

If your project isn't using composer, you can require the autoload.php file.

Tests

To run the tests you can manually run

vendor/bin/phpunit

or you can use the built in gulp task to run it on file change

npm install
gulp

Requirements

PHP 5.4 through 7.4 supported. Untested on 8.0

Documentation

See the wiki for more thorough documentation. The documentation has its own repository and accepts pull requests for contributions. Any merges to master will get synced with the wiki here under the main project.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].