Support » Fixing WordPress » Correct way to allow nbsp entity in TinyMCE?

  • Hi,

    Running a new installation of WP 2.9.2. Importing posts containing many   entities. By default WP’s implementation of TinyMCE strips these out.

    This post explains succinctly that I need to allow entity 160,nbsp.

    What is the correct way to do that? So far the only method I have found is to hack wp-admin/includes/posts.php around line 1421, changing

    ‘entities’ => ’38,amp,60,lt,62,gt’,
    to

    ‘entities’ => ‘160,nbsp,38,amp,60,lt,62,gt’,

    Is there a way to do this without hacking the core?

    Thanks,

    Mark Berry
    MCB Systems

Viewing 2 replies - 1 through 2 (of 2 total)
  • You can use the tiny_mce_before_init filter and alter the array that way instead.

    just further to what Karl says above (and for my own future reference) you can add a function to your themes functions.php file like the below.

    In this example I’m pretty much killing off every HTML rewritting feature that tinyMCE does (which for many people may be a bad idea but I have my reasons). Have added in also how to add the entities values asked by mcbsys.

    function change_mce_options($initArray) {
    
    	$initArray['verify_html'] = false;
    	$initArray['cleanup_on_startup'] = false;
    	$initArray['cleanup'] = false;
    	$initArray['forced_root_block'] = false;
    	$initArray['validate_children'] = false;
    	$initArray['remove_redundant_brs'] = false;
    	$initArray['remove_linebreaks'] = false;
    	$initArray['force_p_newlines'] = false;
    	$initArray['force_br_newlines'] = false;
    	$initArray['fix_table_elements'] = false;
    
    	$initArray['entities'] = '160,nbsp,38,amp,60,lt,62,gt';	
    
    	return $initArray;
    }
    
    add_filter('tiny_mce_before_init', 'change_mce_options');

    the full list of values you can adjust are here
    tinymce.moxiecode.com/wiki.php/Configuration

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Correct way to allow nbsp entity in TinyMCE?’ is closed to new replies.