PHP code example of flyntwp / acf-field-group-composer
1. Go to this page and download the library: Download flyntwp/acf-field-group-composer library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
flyntwp / acf-field-group-composer example snippets
ACFComposer\ACFComposer::registerFieldGroup($config);
$config = [
'name' => 'group1',
'title' => 'My Group',
'fields' => [
[
'label' => 'Subtitle',
'name' => 'subtitle',
'type' => 'text'
]
],
'location' => [
[
[
'param' => 'post_type',
'operator' => '==',
'value' => 'post'
]
]
]
];
add_filter('MyProject/ACF/fields/field1', function ($field) {
return [
'label' => 'Subtitle',
'name' => 'subtitle',
'type' => 'text'
];
});
$config = [
'name' => 'group1',
'title' => 'My Group',
'fields' => [
'MyProject/ACF/fields/field1'
],
'location' => [
[
[
'param' => 'post_type',
'operator' => '==',
'value' => 'post'
]
]
]
];
add_filter('MyProject/ACF/locations/postTypePost', function ($location) {
return [
'param' => 'post_type',
'operator' => '==',
'value' => 'post'
];
});
$config = [
'name' => 'group1',
'title' => 'My Group',
'fields' => [
'MyProject/ACF/fields/field1'
],
'location' => [
[
'MyProject/ACF/locations/postTypePost'
]
]
];
add_filter('MyProject/ACF/fields/field1', function ($field) {
return [
'label' => 'Subtitle',
'name' => 'subtitle',
'type' => 'text'
];
});
add_filter('MyProject/ACF/locations/postTypePost', function ($location) {
return [
'param' => 'post_type',
'operator' => '==',
'value' => 'post'
];
});
$config = [
'name' => 'group1',
'title' => 'My Group',
'fields' => [
'MyProject/ACF/fields/field1'
],
'location' => [
[
'MyProject/ACF/locations/postTypePost'
]
]
];
ACFComposer\ACFComposer::registerFieldGroup($config);
add_filter('MyProject/ACF/fields/wysiwyg', function ($field) {
return [
'label' => 'Content',
'name' => 'content',
'type' => 'wysiwyg'
];
});
$config = [
'name' => 'group1',
'title' => 'My Group',
'fields' => [
'MyProject/ACF/fields/wysiwyg',
'MyProject/ACF/fields/wysiwyg'
],
'location' => [
[
'MyProject/ACF/locations/postTypePost'
]
]
];
ACFComposer\ACFComposer::registerFieldGroup($config);
add_filter('MyProject/ACF/fields/wysiwyg', function ($field, $componentName) {
return [
'label' => 'Content',
'name' => 'content',
'type' => 'wysiwyg'
];
}, 10, 2);
$config = [
'name' => 'group1',
'title' => 'My Group',
'fields' => [
'MyProject/ACF/fields/wysiwyg#firstWysiwyg',
'MyProject/ACF/fields/wysiwyg#secondWysiwyg'
],
'location' => [
[
'MyProject/ACF/locations/postTypePost'
]
]
];
ACFComposer\ACFComposer::registerFieldGroup($config);
public static function registerFieldGroup(array $config)
public static function forFieldGroup(array $config)
public static function forField(array $config, array $parentKeys = [])
public static function forLayout(array $config, array $parentKeys = [])
public static function forLocation(array $config)