Instantly share code, notes, and snippets.

Embed
What would you like to do?
Enregistrer les configurations des metaboxes/champs d'ACF dans un dossier d'un plugin
<?php
// Article/tutoriel complet sur https://mosaika.fr/astuces-developpement-acf/
// Documentation officielle https://www.advancedcustomfields.com/resources/local-json/
define('MSK_ACF_PATH', plugin_dir_path(__FILE__));
/**
* Enregistrer la config de ses metaboxes & champs ACF dans un dossier de son plugin/thème
* Filtre : acf/settings/save_json
*/
function msk_acf_change_json_save_point($path) {
$path = MSK_ACF_PATH . 'acf-fields';
return $path;
}
add_filter('acf/settings/save_json', 'msk_acf_change_json_save_point');
/**
* Charger la config de ses metaboxes & champs ACF dans un dossier de son plugin/
* Filtre : acf/settings/load_json
*/
function msk_acf_change_json_load_point($path) {
$path[] = MSK_ACF_PATH . 'acf-fields';
return $path;
}
add_filter('acf/settings/load_json', 'msk_acf_change_json_load_point');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment