I added your code at the beginning of my plugin and it doesn’t work.
This is the line in my code:
<strong><span contenteditable=”false”>Date du vol rando :</span></strong>’.$date.
and this is what’s returned in the post content:
<strong>Date du vol rando :</strong>22/11/2023
$allowed_protoco what is this variable?
I asked chatGPT for help and he gave me that code:
add_filter('content_save_pre', 'my_custom_content_filter'); function my_custom_content_filter($content) { global $allowedposttags; // Ajouter votre balise à la liste des balises autorisées $allowedposttags['span']['contenteditable'] = true; // Utiliser wp_kses pour valider le contenu avec les nouvelles balises autorisées $content = wp_kses($content, $allowedposttags); return $content; }
and it works!
-
This reply was modified 2 years, 4 months ago by
bcworkz. Reason: code format fixed
Hello @jackbluehouse2019,
I’m glad ChatGPT gave you a workable solution. Thanks for posting the solution, it might be useful to others. When you post code here in the forums in the future, please use the code block. When you do not, the forum’s parser corrupts the code, making it difficult for others to copy/paste it for their own use or to further help you.
I moved your code into a code block so it can be more useful to others. Unfortunately it contains no line feeds so it’s difficult to read, but at least it’ll copy/paste correctly. While it would have been nice to format code with line feeds and indents, it’s not essential.
add_filter('content_save_pre', 'my_custom_content_filter');
function my_custom_content_filter($content) {
global $allowedposttags;
// Ajouter votre balise à la liste des balises autorisées
$allowedposttags['span']['contenteditable'] = true;
// Utiliser wp_kses pour valider le contenu avec les nouvelles balises autorisées
$content = wp_kses($content, $allowedposttags);
return $content;
}
Very sorry for that I won’t do it again.
No worries at all. Thanks for taking the time to format the code and re-posting.