【问题标题】:Text formatting not working with qTranslate plugin文本格式不适用于 qTranslate 插件
【发布时间】:2012-04-05 06:34:40
【问题描述】:

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

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

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

有什么建议吗?

【问题讨论】:

    标签: wordpress qtranslate


    【解决方案1】:

    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 *******************************
    

    【讨论】:

      【解决方案2】:

      用html模式写一个简单的帖子来测试:

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

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

      【讨论】:

        【解决方案3】:

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

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

        【讨论】:

          猜你喜欢
          • 2015-07-08
          • 2020-12-19
          • 1970-01-01
          • 1970-01-01
          • 2018-09-16
          • 1970-01-01
          • 2023-04-08
          • 2014-08-15
          • 2018-08-12
          相关资源
          最近更新 更多