I managed to include ACF PRO in Sage 9. Here’s how:
Note: If you need only the ACF free version just add the dependency from wpackagist like it’s described here
I used the ACF pro installer by Philipp Baschke so I added the repository to my composer.json
like so:
"repositories": [
{
"type": "package",
"package": {
"name": "advanced-custom-fields/advanced-custom-fields-pro",
"version": "5.6.4",
"type": "library",
"dist": {
"type": "zip",
"url": "https://connect.advancedcustomfields.com/index.php?p=pro&a=download"
},
"require": {
"philippbaschke/acf-pro-installer": "^1.0",
"composer/installers": "^1.0"
}
}
}
],
and then required ACF:
"advanced-custom-fields/advanced-custom-fields-pro": "*"
then I added the following filters to my filters.php
file and included the path to the ACF main file:
/**
* Customize ACF path
*/
add_filter('acf/settings/path', function ( $path ) {
$path = get_stylesheet_directory() . '/../vendor/advanced-custom-fields/advanced-custom-fields-pro/';
return $path;
});
/**
* Customize ACF dir
*/
add_filter('acf/settings/dir', function ( $dir ) {
$dir = get_stylesheet_directory_uri() . '/../vendor/advanced-custom-fields/advanced-custom-fields-pro/';
return $dir;
});
/**
* Hide ACF field group menu item
*/
// add_filter('acf/settings/show_admin', '__return_false');
/**
* include ACF
*/
include_once( get_stylesheet_directory() . '/../vendor/advanced-custom-fields/advanced-custom-fields-pro/acf.php' );
to submit your ACF Pro key just create an .env
file in your theme directory and put it there:
ACF_PRO_KEY=PASTE_YOUR_ACF_PRO_KEY_HERE
now run composer update
and you are good to go.
I also recommend creating a folder named acf-json in your resources folder. The plugin will then automatically detect it and save your field groups in json format. Find it in the ACF documentation