acf/load_field_defaults
The WordPress Core acf load field defaults hook.
Description
Parameters (1)
- 0. $array — Optional. (callback) =>
array( 'key' => 'field_clone', 'label' => __("New Field", 'acf'), 'name' => 'new_field', 'type' => 'text', )
- The array.
Usage
- To run the hook, copy the example below.
- $array = apply_filters( 'acf/load_field_defaults', $array );
- if ( !empty( $array ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the acf/load_field_defaults callback
- function filter_acf_load_field_defaults( $array ) {
- // make filter magic happen here...
- return $array;
- };
- // add the filter
- add_filter( 'acf/load_field_defaults', 'filter_acf_load_field_defaults', 10, 1 );
- To remove a hook callback, use the example below.
- // remove the filter
- remove_filter( 'acf/load_field_defaults', 'filter_acf_load_field_defaults', 10, 1 );
Defined (5)
The filter is defined in the following location(s).
- /core/views/meta_box_fields.php
- $fields[] = apply_filters('acf/load_field_defaults', array(
- /core/fields/_functions.php
- $field = apply_filters('acf/load_field_defaults', $field);
- $field = apply_filters('acf/load_field_defaults', $field);
- $field = apply_filters('acf/load_field_defaults', $field);
- add_filter('acf/load_field_defaults', array($this, 'load_field_defaults'), 5, 1);