dimanche 1 mars 2015

wp_editor() in theme option conflicts with htmlspecialchars

I'm using the Sahifa Theme on WP 4.1.1 and doing php modification for my client. untill now everything went pretty smooth, but now i'm stuck.


so this is the issue:


in the theme option page i successfully added a new option called login_block_login_text. usually i'd add this option as an array, but i wanted it to be a tinymce editor and not textarea so this is what i did:



<?php
$editor_args = array(
'textarea_name' => 'tie_options[login_block_login_text]'
);
$content = tie_get_option('login_block_login_text');
wp_editor( $content, 'login_block_login_text', $editor_args);
?>


now the option is saved, but after refresh it is printed html encoded. this is the pre-saving encoding function for ALL theme options, which i guess causes it:



function tie_clean_options(&$value) {
$value = htmlspecialchars(stripslashes($value));
}


BUT: if i add htmlspecialchars_decode to the first code, the option won't save at all. like this:



wp_editor( htmlspecialchars_decode($content), 'login_block_login_text', $editor_args);


Thank you very much,


Itamar


Aucun commentaire:

Enregistrer un commentaire