문제

I have this line:

'paste_remove_spans': True,

that I want to use to stop TineMCE from automatically adding <span>'s to text that is pasted into the editor.

I know how to change the layout/buttons of the editor for wordpress like so:

function change_mce_options( $init ) {
 $init['theme_advanced_blockformats'] = 'p,address,pre,code,h3,h4,h5,h6';
 $init['theme_advanced_disable'] = 'forecolor';
 return $init;
}
add_filter('tiny_mce_before_init', 'change_mce_options');

But I can't seem to figure out how to add this new rule. Do I need to make a filter for that aswell?

도움이 되었습니까?

해결책

You should only have to modify your code to this:

function change_mce_options( $init ) {
  $init['theme_advanced_blockformats'] = 'p,address,pre,code,h3,h4,h5,h6';
  $init['theme_advanced_disable'] = 'forecolor';
  $init['paste_remove_spans'] = true;
  return $init;
}
add_filter('tiny_mce_before_init', 'change_mce_options');

Also, make sure so your cache is cleared by disabling/re-enabling your theme or plugin.

다른 팁

It's not working anymore...

But I've found out solution that works:

change tinyMCEPreInit variable : for example, when I want to show just H3 and <p>:

<script type="text/javascript">
    jQuery(document).ready(function($) {
        tinyMCEPreInit.mceInit.post_editor.block_formats = "Paragraph=p;Heading 3=h3";
    });
</script>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top