ACF (advanced custom fields) post wrapper class.
This class wrap a WP_Post object and give them some of the ACF capabilities like get_field, get_field_object, have_rows, etc...
$acfPost = new \WPS\ACF_Post($wp_post);
while($acfPost->have_rows('parent_field')) {
$acfPost->the_row();
$field = $acfPost->get_sub_field('sub_field');
}Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
See : See more : https://www.advancedcustomfields.com/resources/#functions
Extends \WPS\Post
Class constructor
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $wp_post | { WP_Post } | The wordpress post to encapsulate | required |
Public
Returns the value of a specific field. Intuitive and powerful (much like ACF itself ?), this function can be used to load the value of any field from any location. Please note that each field type returns different forms of data (string, int, array, etc).
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $key | { String } | The field key to get | required | |
| $format_value | { Boolean } | Whether to apply formatting logic | optional | true |
Return { String } The field value
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Returns the settings of a specific field. Each field contains many settings such as a label, name and type. This function can be used to load these settings as an array along with the field’s value.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $key | { String } | The field key to get | required | |
| $format_value | { Boolean } | Whether to apply formatting logic | optional | true |
| $load_value | { Boolean } | Whether to load the field’s value | optional | true |
Return { Array } An array with the field settings
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Returns an array of values (name => value) for a the post.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $format_value | { Boolean } | Whether to apply formatting to the value | optional | true |
Return { Array } An array of values (name => value) for a the post
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Returns an array of custom field objects for a specific page / post. This is a very simple function which finds ALL custom field values (that don’t start with an “_”) in the wp_postmeta table and returns them in an associated array where the $field_name => field object You should only use this function when you do not know the fields which which will be appearing on a template or if you have a large amount of fields which you would prefer not to code independently.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $format_value | { Boolean } | Whether to apply formatting logic | optional | true |
| $load_value | { Boolean } | Whether to load the field’s value | optional | true |
Return { Array } An array of fields object in key=>value pairs format
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
This function checks to see if a field (such as a Repeater or Flexible Content field) has any rows of data to loop over. This is a boolean function, meaning it returns either true or false.
This function is intended to be used in conjunction with the_row() to step through available values.
Using have_rows() together with the_row() is intended to feel native much like the have_posts() and the_post() WordPress functions.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $key | { String } | The field key to get | required |
Return { Boolean } true if has rows, false if not
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Set the current row to work with. This has to be used in conjunction with the have_rows method like the have_posts is used with the the_post function.
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Returns the value of a specific sub field.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $sub_field_name | { String } | the name of the field to be retrieved. eg “page_content” | required | |
| $format_value | { Boolean } | whether or not to format the value loaded from the db | optional | true |
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Returns the settings (array) of a specific sub field within a have_rows() loop. The field’s value will also be loaded unless otherwise specified.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $selector | { String } | The field name or field key | required | |
| $format_value | { Boolean } | Whether to apply formatting logic | optional | true |
| $load_value | { Boolean } | Whether to load the field’s value | optional | true |
Return { Array } An array of the field properties
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Return an array containing all sub field values for the current row. This function will return an array containing all sub field values for the current row within a have_rows() loop.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $format_value | { Boolean } | whether or not to format the value loaded from the db | optional | true |
Return { Array } Return an array containing all sub field values for the current row
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
This function will return the current loop count within a have_rows() loop.
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
This function returns the current layout (string) within a the_flexible_field() loop. A flexible content field may hold many different layout options which can be placed on a page in any order. It is necessary to use this function in your template to decide what code to write and which sub fields to call.
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Return an array with the row fields in case the field requested if a repeatable or a flexible one.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $selector | { String } | The field name or field key | required |
Return { Array } An array with the row fields objects
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public