{"id":14954925,"url":"https://github.com/stoutlogic/acf-builder","last_synced_at":"2025-04-13T18:37:35.321Z","repository":{"id":39005805,"uuid":"58671723","full_name":"StoutLogic/acf-builder","owner":"StoutLogic","description":"An Advanced Custom Field Configuration Builder","archived":false,"fork":false,"pushed_at":"2023-11-13T18:50:25.000Z","size":273,"stargazers_count":811,"open_issues_count":62,"forks_count":62,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-04-13T17:43:25.616Z","etag":null,"topics":["acf","composer","wordpress"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StoutLogic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-05-12T19:44:19.000Z","updated_at":"2025-04-09T08:16:05.000Z","dependencies_parsed_at":"2024-01-16T22:18:08.746Z","dependency_job_id":"a06e2b06-13cb-42f4-82a4-99839c90f090","html_url":"https://github.com/StoutLogic/acf-builder","commit_stats":{"total_commits":163,"total_committers":17,"mean_commits":9.588235294117647,"dds":0.4601226993865031,"last_synced_commit":"15637531e7456f11a2ba65448e0254fc43467447"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StoutLogic%2Facf-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StoutLogic%2Facf-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StoutLogic%2Facf-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StoutLogic%2Facf-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StoutLogic","download_url":"https://codeload.github.com/StoutLogic/acf-builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248762277,"owners_count":21157705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acf","composer","wordpress"],"created_at":"2024-09-24T13:10:14.860Z","updated_at":"2025-04-13T18:37:35.303Z","avatar_url":"https://github.com/StoutLogic.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ACF Builder\n\nCreate configuration arrays for [Advanced Custom Fields Pro](https://www.advancedcustomfields.com/pro/) using the builder pattern and a fluent API.\n\nQuickly 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/\n\n[![Latest Stable Version](https://poser.pugx.org/stoutlogic/acf-builder/v/stable)](https://packagist.org/packages/stoutlogic/acf-builder)\n[![Build Status](https://github.com/stoutlogic/acf-builder/workflows/TESTS/badge.svg)](https://github.com/StoutLogic/acf-builder/actions?query=workflow%3ATESTS)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/StoutLogic/acf-builder/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/StoutLogic/acf-builder/?branch=master)\n[![Join the chat at https://gitter.im/StoutLogic/acf-builder](https://badges.gitter.im/StoutLogic/acf-builder.svg)](https://gitter.im/StoutLogic/acf-builder?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n### Simple Example\n```php\n$banner = new StoutLogic\\AcfBuilder\\FieldsBuilder('banner');\n$banner\n    -\u003eaddText('title')\n    -\u003eaddWysiwyg('content')\n    -\u003eaddImage('background_image')\n    -\u003esetLocation('post_type', '==', 'page')\n        -\u003eor('post_type', '==', 'post');\n\nadd_action('acf/init', function() use ($banner) {\n   acf_add_local_field_group($banner-\u003ebuild());\n});\n```\n\n`$banner-\u003ebuild();` will return:\n```php\n[\n    'key' =\u003e 'group_banner',\n    'title' =\u003e 'Banner',\n    'fields' =\u003e [\n        [\n            'key' =\u003e 'field_title',\n            'name' =\u003e 'title',\n            'label' =\u003e 'Title',\n            'type' =\u003e 'text'\n        ],\n        [\n            'key' =\u003e 'field_content',\n            'name' =\u003e 'content',\n            'label' =\u003e 'Content',\n            'type' =\u003e 'wysiwyg'\n        ],\n        [\n            'key' =\u003e 'field_background_image',\n            'name' =\u003e 'background_image',\n            'label' =\u003e 'Background Image',\n            'type' =\u003e 'image'\n        ],\n    ],\n    'location' =\u003e [\n        [\n            [\n                'param' =\u003e 'post_type',\n                'operator' =\u003e '==',\n                'value' =\u003e 'page'\n            ]\n        ],\n        [\n            [\n                'param' =\u003e 'post_type',\n                'operator' =\u003e '==',\n                'value' =\u003e 'post'\n            ]\n        ]\n    ]\n]\n```\n\nAs 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:\n\n### Reuse Example\n\n```php\n\nuse StoutLogic\\AcfBuilder\\FieldsBuilder;\n\n$background = new FieldsBuilder('background');\n$background\n    -\u003eaddTab('Background')\n    -\u003eaddImage('background_image')\n    -\u003eaddTrueFalse('fixed')\n        -\u003einstructions(\"Check to add a parallax effect where the background image doesn't move when scrolling\")\n    -\u003eaddColorPicker('background_color');\n\n$banner = new FieldsBuilder('banner');\n$banner\n    -\u003eaddTab('Content')\n    -\u003eaddText('title')\n    -\u003eaddWysiwyg('content')\n    -\u003eaddFields($background)\n    -\u003esetLocation('post_type', '==', 'page');\n\n$section = new FieldsBuilder('section');\n$section\n    -\u003eaddTab('Content')\n    -\u003eaddText('section_title')\n    -\u003eaddRepeater('columns', ['min' =\u003e 1, 'layout' =\u003e 'block'])\n        -\u003eaddTab('Content')\n        -\u003eaddText('title')\n        -\u003eaddWysiwyg('content')\n        -\u003eaddFields($background)\n        -\u003eendRepeater()\n    -\u003eaddFields($background)\n    -\u003esetLocation('post_type', '==', 'page');\n```\n\nHere 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.\n\n## Install\nUse composer to install:\n```\ncomposer require stoutlogic/acf-builder\n```\n\nIf your project isn't using composer, you can require the `autoload.php` file.\n\n## Tests\nTo run the tests you can manually run\n```\nvendor/bin/phpunit\n```\nor you can use the built in gulp task to run it on file change\n```\nnpm install\ngulp\n```\n\n## Requirements\nPHP 5.4 through 7.2 supported but automated tests cannot be run anymore so it might stop working at some point.\n\u003e= 7.4, 8 Tested\n\n## Documentation\nSee the [wiki](https://github.com/StoutLogic/acf-builder/wiki) for more thorough documentation. The documentation has its [own repository](https://github.com/StoutLogic/acf-builder-wiki) and accepts pull requests for contributions. Any merges to master will get synced with the wiki here under the main project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoutlogic%2Facf-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstoutlogic%2Facf-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoutlogic%2Facf-builder/lists"}