Wordpress 文本格式不适用于qTranslate插件
我正在使用wordpress作为CMS创建一个多语言网站 我正在使用qTranslate插件来支持多语言。一旦我启用插件,所有文本格式都将丢失。i、 编辑中的所有段落都合并为一个段落 我在设置中启用了这个选项:“WordPress应该自动更正无效嵌套的XHTML”,但没有任何更改Wordpress 文本格式不适用于qTranslate插件,wordpress,qtranslate,Wordpress,Qtranslate,我正在使用wordpress作为CMS创建一个多语言网站 我正在使用qTranslate插件来支持多语言。一旦我启用插件,所有文本格式都将丢失。i、 编辑中的所有段落都合并为一个段落 我在设置中启用了这个选项:“WordPress应该自动更正无效嵌套的XHTML”,但没有任何更改 有什么建议吗?在html模式下写一篇简单的文章,进行如下测试: <p>lorem</p> <p>ipsum</p> 洛雷姆 ipsum wordpress中有用于格式
有什么建议吗?在html模式下写一篇简单的文章,进行如下测试:
<p>lorem</p>
<p>ipsum</p>
洛雷姆
ipsum
wordpress中有用于格式化文本的过滤器(plugin或functions.php),请尝试查找它们,否则请尝试其他插件,如Polylang。我在这里找到了一个解决方案:
但是,我怀疑插件中添加的代码在更新时会被删除。在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 *******************************
/**********************补丁程序启动*****************************
//修复qTranslate插件(在页面中不保留格式)
如果('html'!=wp\u default\u editor()){
删除筛选器(“编辑器内容”,“wp\u richedit\u pre”);
添加过滤器(“编辑器内容”,“wp\u htmledit\u pre”);
}
移除_过滤器('the_content'、'wp autop');
如果(!function_存在('tmce_replace')){
函数tmce_replace(){
$tadv_options=get_option('tadv_options',array());
$tadv_plugins=get_选项('tadv_plugins',array());
?>
if(typeof(jQuery)!=“未定义”){
jQuery('body').bind('afterPreWpautop',函数(e,o){
o、 数据=o.未过滤
.替换(/caption\]\+?/g,函数(a){
返回a.replace(/[\r\n]+/g',);
});
}).bind('afterWpautop',函数(e,o){
o、 数据=o.未过滤;
});
}