1

我正在使用 wordpress 作为 CMS 创建一个多语言网站。

我正在使用 qTranslate 插件来支持多语言。一旦我启用插件,所有文本格式都会丢失。即编辑器中的所有段落都合并为一个段落。

我在设置中启用了这个选项:“WordPress 应该自动更正无效嵌套的 XHTML”,但没有任何变化。

请问有什么建议吗?

4

3 回答 3

2

在wp-content\themes\your-theme-name\functions.php的末尾添加此代码:

//************************** PATCH START *****************************

// Fix for qTranslate plugin (that does not retain formatting in pages)

if('html' != wp_default_editor()) {
                remove_filter('the_editor_content', 'wp_richedit_pre');
                add_filter('the_editor_content', 'wp_htmledit_pre');
        }
remove_filter( 'the_content', 'wpautop' );
if ( ! function_exists('tmce_replace') ) {
        function tmce_replace() {
                $tadv_options = get_option('tadv_options', array());
                $tadv_plugins = get_option('tadv_plugins', array());    
?>
<script type="text/javascript">
if ( typeof(jQuery) != 'undefined' ) {
  jQuery('body').bind('afterPreWpautop', function(e, o){
    o.data = o.unfiltered
    .replace(/caption\]\ +?<\/object>/g, function(a) {
      return a.replace(/[\r\n]+/g, ' ');
    });
  }).bind('afterWpautop', function(e, o){
    o.data = o.unfiltered;
  });
}
</script>
<?php
        }
        add_action( 'after_wp_tiny_mce', 'tmce_replace' );
}
function teslina_tinymce_config( $init ) { 
    $init['remove_linebreaks'] = false;
    $init['apply_source_formatting'] = true;
    $init['preformatted'] = true;
    $init['remove_redundant_brs'] = false;    
    return $init;
}
add_filter('tiny_mce_before_init', 'teslina_tinymce_config');


//************************** PATCH END *******************************
于 2012-08-29T14:06:30.410 回答
0

在 html 模式下编写简单的帖子进行测试,如下所示:

<p>lorem</p>
<p>ipsum</p>

wordpress 中有过滤器来格式化文本(插件或functions.php)尝试找到它们,否则尝试另一个插件,如 Polylang。

于 2012-04-05T09:02:58.513 回答
0

我在这里找到了解决方案: http ://www.teslina.com/en/748/wordpress/qtranslate-code-syntax-bugfix/

但是我怀疑插件中添加的代码在更新时会被删除。

于 2012-04-15T10:58:49.713 回答