moxie-lean / wp-acf
Helper functions for working with Advanced Custom Fields
Installs: 32 948
Dependents: 5
Suggesters: 0
Security: 0
Stars: 2
Watchers: 6
Forks: 1
Open Issues: 5
Requires
- php: >=7.2 || >=8.0
Requires (Dev)
README
Helper functions for working with the Advanced Custom Fields plugin.
Requirements
- PHP 7.2+ or 8.0+
- Composer
Getting Started
The easiest way to install this package is by using running the following command from your terminal:
composer require moxie-lean/acf --save
Or by adding the following lines on your composer.json
file
"require": { "moxie-lean/acf": "dev-master" }
This will download the files from the packagelist site and set you up with the latest version located on master branch of the repository.
After that you can include the autoload.php
file in order to be able to autoload
the class during the object creation.
include '/vendor/autoload.php';
Filters
ln_acf_apply_default_transforms_{field_key}
This filter allows you to overwrite the default transforms applied to
the field. Where {field_key}
is replaced by the key of your field
for example: ln_acf_apply_default_transforms_field_56f293e024b74
.
The filter has the following parameters:
$target_id
: Theid
of the post or page that where the field belongs.$field_obj
: array of data containing all field settings
ln_acf_field_{field_key}
This filter allow you to overwrite the default value returned for a
particular field. The {field_key}
is replaced by the key of your field
for example: ln_acf_field_field_56f293e024b74
.
The filter has the following parameters:
$value
: The value of the field or the default value to be returned.$target_id
: Theid
of the post or page that where the field belongs.$field_obj
: array of data containing all field settings
ln_acf_image_size
This filter is applied to images before are returned and can be used to return a specifc size of the image.
The filter has the following parameters.
$size
: By default the value is false and the$attachment_id
is returned instead, here you can specify the size of the image you want to use.$field
: Is the field that has the image here you have all the information of that particular field such as:key
,name
and so on,$sub_field
: This is always false for fields that are not repeter fields otherwise contains the fields that are childs.