Home › Forums › General Issues › Message field, and wp_kses_allowed_html › Reply To: Message field, and wp_kses_allowed_html
Yes it is. I have it set up to allow both input and textarea fields for a plugin. I use it to shoe input and textareas to allow copy and paste of shortcodes from the editor for my CPT.
<?php
add_filter('acf/prepare_field/key=field_619663d258c1e', 'shortcodes_messages', 20);
function shortcodes_messages($field) {
global $post;
if (is_a($post, 'WP_POST')) {
ob_start();
// I generate message here
$field['message'] = ob_get_clean();
}
return $field;
}
add_filter('wp_kses_allowed_html', 'allow_input_in_acf', 20, 2);
function allow_input_in_acf($tags, $context) {
$attributes = array(
'type',
'disabled',
'checked',
'style',
'name',
'value',
'class',
'id',
'style',
'readonly'
);
if ('acf' === $context) {
if (!isset($tags['input'])) {
$tags['input'] = array();
}
foreach ($attributes as $attribute) {
$tags['input'][$attribute] = true;
}
if (!isset($tags['textarea'])) {
$tags['textarea'] = array();
}
foreach ($attributes as $attribute) {
$tags['textarea'][$attribute] = true;
}
}
return $tags;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.