','gt',$_POST['custom_ents']);
$_POST['custom_ents'] = str_replace('<','lt',$_POST['custom_ents']);
$_POST['custom_ents'] = str_replace("'",'39',$_POST['custom_ents']);
$_POST['custom_ents'] = str_replace('"','quot',$_POST['custom_ents']);
$_POST['custom_ents'] = str_replace('&','',$_POST['custom_ents']);
$_POST['custom_ents'] = str_replace('#','',$_POST['custom_ents']);
$_POST['custom_ents'] = str_replace(';','',$_POST['custom_ents']);
update_option('char_map',array('safe'=>$_POST['safe'],'custom_ents'=>$_POST['custom_ents']));
$char_map = get_option('char_map');
char_map_build_map('2');
}elseif (strpos($_SERVER['PHP_SELF'], '-new.php')||$_REQUEST['post'] != ''){
// if($char_map['safe'] != 1){
// add_filter('content_save_pre', 'fix_chars');
// add_filter('the_editor_content','unfix_chars');
// }
add_filter('edit_form_advanced', 'get_char_map_html');
add_filter('edit_page_form', 'get_char_map_html');
add_action('admin_head', 'char_map_javascript');
}
function char_map_javascript(){
wp_print_scripts('sack');
$home = get_option('home');
?>
Charecter Map
';
char_map_build_list();
echo ' | ';
char_map_build_map(1);
echo ' |
';
}
function char_map_build_list() {
global $charsheet;
$output.='';
$x=1;
foreach($charsheet as $chargroup){
$output .= '- ';
$output .= ''.$chargroup[2].'';
$output .= '
'."\n";
$x++;
}
$output.='
';
echo $output;
}
function char_map_build_map($chars='') {
global $charsheet, $char_map;
$chargroup = $charsheet[$chars-1];
//If in safe mode will add html entities directly to the textbox.
if($char_map['safe'] == 1){$k = '&'; $sc='checked="checked"';}else{$k = '&';}
if($chargroup[2] == 'Options'){
$output .= '';
}elseif($chargroup[2] == 'Custom'){
$chars = explode(' ', $char_map['custom_ents']);
foreach($chars as $char){
if($char != ''){
$m = (is_numeric($char)) ? '#' : '';
$output .= '&'.$m.$char.'; ';
}
}
}else{
for($i = $chargroup[0]; $i<=$chargroup[1]; $i++){
$output .= ''.$i.'; '."\n";
}
}
echo $output;
}
// function fix_chars($content){
// $encoding = get_option('blog_charset');
// if(!$encoding){$encoding = "AUTO";}
// $content=mb_convert_encoding($content,"HTML-ENTITIES",$encoding);
// return $content;
// }
//
// function unfix_chars($content){
// $content=html_entity_decode($content);
// return $content;
// }
if(!function_exists('add_char_enc_button')){
if(strpos($_SERVER['PHP_SELF'], '-new.php')|| $_REQUEST['post'] != ''){
add_action('admin_footer', 'add_char_enc_button');
}
function add_char_enc_button(){
?>