Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remplacer des variables/placeholders dans les champs ACF de type Message
<?php
// Article/tutoriel complet sur https://mosaika.fr/astuces-developpement-acf/
// Documentation officielle https://www.advancedcustomfields.com/resources/acf-load_field/
/**
* Injecter des données dynamiques dans les champs de type message
* Filtre : acf/load_field
*/
function msk_acf_variables_in_message_fields($field) {
$field['message'] = str_replace(
['%date_debut%', '%date_fin%'],
[date('Y') - 5, date('Y')],
$field['message']
);
return $field;
}
add_filter('acf/load_field/type=message', 'msk_acf_variables_in_message_fields');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment