Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devidw/acf-helper
https://github.com/devidw/acf-helper
acf acf-field acf-fields advanced-custom-fields helper helpers helpers-library
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/devidw/acf-helper
- Owner: devidw
- Created: 2022-02-11T13:15:43.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-04-11T13:59:34.000Z (over 2 years ago)
- Last Synced: 2024-05-02T01:47:04.704Z (5 months ago)
- Topics: acf, acf-field, acf-fields, advanced-custom-fields, helper, helpers, helpers-library
- Language: PHP
- Homepage: https://packagist.org/packages/devidw/acf-helper
- Size: 59.6 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
Awesome Lists containing this project
README
= ACF Helper
A set of PHP classes and methods to assist with ACF. Enables a straight forward way of working with ACF fields by providing a simple, clean and self describing intererface.
All methods are static and can be called directly from the class name from anywhere in the code.
The libary adds functionality to get the visibility state of a field and also provides a way to get the completeness amount of all fields in a field group based on the visibility state and the amount of filled fields by the user.
== Installation
Install the libary using Composer:
[source,zsh]
----
composer require devidw/acf-helper
----== Comparison
|===
| ACF Helper | ACFa|
[source,php]
----
Field::setKey('field_xxxxx')::get();
----a|
[source,php]
----
get_field_object('field_xxxxx');
----a|
[source,php]
----
Field::setKey('field_xxxxx')::get('label');
----a|
[source,php]
----
get_field_object('field_xxxxx')['label'];
----a|
[source,php]
----
Field::setKey('field_xxxxx')::setUserId(2458)::getValue();
----a|
[source,php]
----
get_field('field_xxxxx', 'user_2458');
----
|===== Usage Examples
=== Get _full_ field name
Gets the full field name of a field. Fields nested in fields like repeater, group or flexible content fields will also be returned as full field names.
With ACF you can only get the direct name of a field. This method allows you to get the full field name.
Let's say you have a group of `test_group_field` and a sub field of `test_sub_field` in the group. Using the `getName()` method you can get the full field name of the sub field: `test_group_field_test_sub_field`.
[source,php]
----