Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸŽ‰ ACF Composer v3 #193

Merged
merged 23 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c98712e
πŸ”₯ Remove unnecessary compatibility workflow
Log1x Feb 26, 2024
7860b2b
βž• Add `roots/acorn` to the project
Log1x Feb 26, 2024
cab74f5
πŸ‘· Tidy up the dependabot configuration
Log1x Feb 26, 2024
cf8b5de
πŸ‘· Update the main workflow to use Pint
Log1x Feb 26, 2024
07a90fb
πŸ”§ Change the Options `redirect` property default value to `false`
Log1x Feb 26, 2024
5d4689c
🚨 Run Pint
Log1x Feb 26, 2024
9888659
πŸ—‘οΈ Deprecate the `get()` Partial method
Log1x Feb 26, 2024
6eb04a4
✨ Implement support for caching built field groups (Fixes #176)
Log1x Feb 26, 2024
2fc8d9d
✨ Implement a `FieldsBuilder` wrapper for improved builder support
Log1x Feb 26, 2024
061496e
πŸ§‘β€πŸ’» Update generation stubs to utilize the new Builder class
Log1x Feb 26, 2024
59cfe8b
πŸ§‘β€πŸ’» Add a warning when fields are generated without ACF being enabled
Log1x Feb 26, 2024
7751b29
✨ Add upgrade command to upgrade classes to v3
Log1x Feb 26, 2024
3298665
πŸ”§ Add `types` and `manifest` configuration to the ACF Composer config
Log1x Feb 26, 2024
1e5dc8f
πŸ”§ Add new commands to the Service Provider
Log1x Feb 26, 2024
e3be44c
πŸ“ Update the README for v3
Log1x Feb 26, 2024
e12c58c
πŸ‘· Update `actions/checkout` to v4
Log1x Feb 26, 2024
ea74d46
πŸ‘· Update the workflow branch
Log1x Feb 26, 2024
6ff595b
πŸ™ˆ Add `composer.lock` to `.gitignore`
Log1x Feb 26, 2024
f20cc7b
πŸ§‘β€πŸ’» Add ACF Composer to `acorn about`
Log1x Feb 26, 2024
1379355
✨ Add a `acf:clear` command to clear the ACF Composer cache
Log1x Feb 26, 2024
a9fdfac
πŸ§‘β€πŸ’» Add a `--status` option to the `acf:cache` command
Log1x Feb 26, 2024
539aa79
πŸ§‘β€πŸ’» Improve the ACF Composer lifecycle
Log1x Feb 26, 2024
86ac709
πŸ“ Sort namespaces on examples
Log1x Feb 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
- package-ecosystem: 'composer'
directory: '/'
schedule:
interval: 'monthly'
- package-ecosystem: 'composer'
interval: 'daily'

- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'monthly'
46 changes: 0 additions & 46 deletions .github/workflows/compatibility.yml

This file was deleted.

49 changes: 22 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
name: Main

on: [pull_request]
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
main:
runs-on: ${{ matrix.operating-system }}
php:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4', '8.0', '8.1', '8.2']
php: [8.1, 8.2]

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: xdebug
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php-versions }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.php-versions }}-composer-
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
coverage: none

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader --no-suggest
run: composer install --prefer-dist --no-interaction --no-progress

- name: PHP lint
run: composer run-script lint
- name: Run Pint
run: vendor/bin/pint --test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/vendor
/vendor
composer.lock
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Latest Stable Version](https://img.shields.io/packagist/v/log1x/acf-composer.svg?style=flat-square)
![Total Downloads](https://img.shields.io/packagist/dt/log1x/acf-composer.svg?style=flat-square)
![Build Status](https://img.shields.io/github/actions/workflow/status/log1x/acf-composer/compatibility.yml?branch=master&style=flat-square)
![Build Status](https://img.shields.io/github/actions/workflow/status/log1x/acf-composer/main.yml?branch=master&style=flat-square)

ACF Composer is the ultimate tool for creating fields, blocks, widgets, and option pages using [ACF Builder](https://github.com/stoutlogic/acf-builder) alongside [Sage 10](https://github.com/roots/sage).

Expand All @@ -14,14 +14,15 @@ ACF Composer is the ultimate tool for creating fields, blocks, widgets, and opti
- πŸ”₯ Instantly generate working fields, blocks, widgets, and option pages. Batteries included.
- πŸ”₯ Instantly generate re-usable field group partials.
- πŸ”₯ Blocks and widgets are fully rendered using Blade with a native Sage 10 feel for passing view data.
- πŸ”₯ Blocks are automatically generated with `<InnerBlocks />` support if [ACF v5.9.0+](https://www.advancedcustomfields.com/blog/acf-5-9-exciting-new-features/#InnerBlocks) is installed.
- πŸ”₯ Blocks are automatically generated with `<InnerBlocks />` support.
- πŸ”₯ Automatically hooks widgets with `WP_Widget` making them instantly ready to use.
- πŸ”₯ Automatically sets field location on blocks, widgets, and option pages.
- πŸ”₯ Globally set default field type and field group settings. No more repeating `['ui' => 1]` on every select field.

## Requirements

- [Sage](https://github.com/roots/sage) >= 10.0
- [Acorn](https://github.com/roots/acorn) >= 3.0
- [ACF Pro](https://www.advancedcustomfields.com/) >= 5.8.0

## Installation
Expand All @@ -39,7 +40,7 @@ $ composer require log1x/acf-composer
Start by publishing the `config/acf.php` configuration file using Acorn:

```bash
$ wp acorn vendor:publish --provider="Log1x\AcfComposer\Providers\AcfComposerServiceProvider"
$ wp acorn vendor:publish --tag="acf-composer"
```

### Generating a Field
Expand All @@ -59,8 +60,8 @@ Taking a glance at the generated `Example.php` stub, you will notice that it has

namespace App\Fields;

use Log1x\AcfComposer\Builder;
use Log1x\AcfComposer\Field;
use StoutLogic\AcfBuilder\FieldsBuilder;

class Example extends Field
{
Expand All @@ -71,7 +72,7 @@ class Example extends Field
*/
public function fields()
{
$example = new FieldsBuilder('example');
$example = Builder::make('example');

$example
->setLocation('post_type', '==', 'post');
Expand Down Expand Up @@ -103,8 +104,8 @@ $ wp acorn acf:partial ListItems

namespace App\Fields\Partials;

use Log1x\AcfComposer\Builder;
use Log1x\AcfComposer\Partial;
use StoutLogic\AcfBuilder\FieldsBuilder;

class ListItems extends Partial
{
Expand All @@ -115,7 +116,7 @@ class ListItems extends Partial
*/
public function fields()
{
$listItems = new FieldsBuilder('listItems');
$listItems = Builder::make('listItems');

$listItems
->addRepeater('items')
Expand All @@ -131,16 +132,16 @@ Looking at `ListItems.php`, you will see out of the box it consists of an identi

A key difference to note compared to an ordinary field is the omitting of `->build()` instead returning the `FieldsBuilder` instance itself.

This can be utilized in our _Example_ field by passing the `::class` constant to `->addFields()`.
This can be utilized in our _Example_ field by passing the `::class` constant to `->addPartial()`:

```php
<?php

namespace App\Fields;

use Log1x\AcfComposer\Field;
use StoutLogic\AcfBuilder\FieldsBuilder;
use App\Fields\Partials\ListItems;
use Log1x\AcfComposer\Builder;
use Log1x\AcfComposer\Field;

class Example extends Field
{
Expand All @@ -151,13 +152,13 @@ class Example extends Field
*/
public function fields()
{
$example = new FieldsBuilder('example');
$example = Builder::make('example');

$example
->setLocation('post_type', '==', 'post');

$example
->addFields($this->get(ListItems::class));
->addPartial(ListItems::class);

return $example->build();
}
Expand All @@ -180,7 +181,7 @@ $ wp acorn acf:block Example
namespace App\Blocks;

use Log1x\AcfComposer\Block;
use StoutLogic\AcfBuilder\FieldsBuilder;
use Log1x\AcfComposer\Builder;

class Example extends Block
{
Expand Down Expand Up @@ -231,7 +232,7 @@ class Example extends Block
*/
public function fields()
{
$example = new FieldsBuilder('example');
$example = Builder::make('example');

$example
->addRepeater('items')
Expand Down Expand Up @@ -289,7 +290,7 @@ Simply duplicate your existing view prefixing it with `preview-` (e.g. `preview-

> [!IMPORTANT]
> With WordPress 5.8, Blocks can now be used as widgets making this feature somewhat deprecated as you would just make a block instead.
>
>
> If you are on the latest WordPress and would like to use the classic widget functionality from ACF Composer, you will need to [opt-out of the widget block editor](https://developer.wordpress.org/block-editor/how-to-guides/widgets/opting-out/).

Creating a sidebar widget using ACF Composer is extremely easy. Widgets are automatically loaded and rendered with Blade, as well as registered with `WP_Widget` which is usually rather annoying.
Expand All @@ -305,8 +306,8 @@ $ wp acorn acf:widget Example

namespace App\Widgets;

use Log1x\AcfComposer\Builder;
use Log1x\AcfComposer\Widget;
use StoutLogic\AcfBuilder\FieldsBuilder;

class Example extends Widget
{
Expand Down Expand Up @@ -352,7 +353,7 @@ class Example extends Widget
*/
public function fields()
{
$example = new FieldsBuilder('example');
$example = Builder::make('example');

$example
->addText('title');
Expand Down Expand Up @@ -408,8 +409,8 @@ $ wp acorn acf:options Example

namespace App\Options;

use Log1x\AcfComposer\Builder;
use Log1x\AcfComposer\Options as Field;
use StoutLogic\AcfBuilder\FieldsBuilder;

class Example extends Field
{
Expand All @@ -434,7 +435,7 @@ class Example extends Field
*/
public function fields()
{
$example = new FieldsBuilder('example');
$example = Builder::make('example');

$example
->addRepeater('items')
Expand Down
15 changes: 4 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,18 @@
}
},
"require": {
"php": "^7.4|^8.0",
"stoutlogic/acf-builder": "^1.11"
"php": "^8.0",
"stoutlogic/acf-builder": "^1.11",
"roots/acorn": "^3.0|^4.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5"
},
"suggest": {
"log1x/modern-acf-options": "Gives ACF option pages a much needed design overhaul."
"laravel/pint": "^1.14"
},
"extra": {
"acorn": {
"providers": [
"Log1x\\AcfComposer\\Providers\\AcfComposerServiceProvider"
]
}
},
"scripts": {
"lint": [
"phpcs --ignore=vendor --extensions=php --standard=PSR12 ."
]
}
}
Loading