Try to set example data for ACF blocks automatically based on field type. If theme sets the example data, plugin tries to fill those where suitable. So the theme example data is always the defining place, if automatic data isn't wanted.
Plugin creates automatically page /blocks
that shows all registered ACF blocks with their example data. The page is visible on production environment when user is logged in, other environment do not require login.
Currently following ACF field types are supported:
- Text
- Textarea
- Wysiwyg
- Link
- Url
- Image
- Gallery
- Relationship
- Repeater
- Select (only with icon_svg fields)
The default example datas for fields can be totally modified with general hooks or tweaked a little. For field type tweaks, all filters receive $field_name
and $field
as an addigional parameters.
Default content for fields can be modified with air_block_acf_example_data
filter. All filters modifying data receive $field_type
, $field_name
and $field
as an addigional parameters.
air_block_acf_example_data/{$field_type}
air_block_acf_example_data/{$field_name}
Set filename for the svg icon that is used as default one for svg icon select fields. Svg file should be placed in svg/foruser
directory.
add_filter( 'air_acf_block_example_data_default_svg_icon', function() {
return 'icon.svg';
} );
By default, all gallery blocks do get assigned with three images. This can be changed via hook for all gallery fields or by field name.
add_filter( 'air_block_acf_example_data_gallery_images_count/{$field_name}', function() {
return 5;
} );
add_filter( 'air_block_acf_example_data_gallery_images_count', function() { return 5; } );
### Repeater field items count
By default, repeater field tries to use value set to min on determining how many items the repeater should contain. If no value is set, three is used. This can be changed via hook for all gallery fields or by field name.
add_filter( 'air_block_acf_example_data_repeater_count/{$field_name}', function() { return 5; } );
add_filter( 'air_block_acf_example_data_repeater_count', function() {
return 5;
} );
Modify the WP_Query arguments used to get example data for relationship field.
air_block_acf_example_data_relationship_query_args/{$field_name}
air_block_acf_example_data_relationship_query_args