$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>tinymce - How to stop editor removing space ( ) in the beginning of the paragraph|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

tinymce - How to stop editor removing space ( ) in the beginning of the paragraph

matteradmin10PV0评论

I use WordPress with TinyMCE in Chinese.

It needs double white spaces in the beginning of each paragraph. But the editor will automatically removing all spaces(white space and nbsp; code) in the beginning of the paragraph when I toggle the editor between WYSIWYG mode and HTML mode.

When I used WordPress 3.8, I could stop it doing this with these code

add_filter('tiny_mce_before_init', 'preserve_nbsp_chars');
function preserve_nbsp_chars($initArray) {
    $initArray['entities'] = $initArray['entities'].',160,nbsp';
    return $initArray;
}

The bad thing is it does not work after I updated WP to 4.0.

I use WordPress with TinyMCE in Chinese.

It needs double white spaces in the beginning of each paragraph. But the editor will automatically removing all spaces(white space and nbsp; code) in the beginning of the paragraph when I toggle the editor between WYSIWYG mode and HTML mode.

When I used WordPress 3.8, I could stop it doing this with these code

add_filter('tiny_mce_before_init', 'preserve_nbsp_chars');
function preserve_nbsp_chars($initArray) {
    $initArray['entities'] = $initArray['entities'].',160,nbsp';
    return $initArray;
}

The bad thing is it does not work after I updated WP to 4.0.

Share Improve this question edited Sep 24, 2014 at 4:01 Mark Kaplun 23.8k7 gold badges43 silver badges65 bronze badges asked Sep 24, 2014 at 3:36 sunsam7sunsam7 111 gold badge1 silver badge2 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 4

An ugly workaround I have always used in WordPress to add spaces is use <b>&nbsp;</b>

It's ugly, but it works.

//[nbsp] shortcode
function nbsp_shortcode( $atts, $content = null ) {
$content = '&nbsp';
return $content;
}
add_shortcode( 'nbsp', 'nbsp_shortcode' );

Then call it like this:

[nbsp]

Instead of:

&nbsp;

Hat tip to this post on wordpress: https://wordpress/support/topic/prevent-nbsp-characters-from-getting-removed-by-the-visual-editor

Post a comment

comment list (0)

  1. No comments so far