简体   繁体   English

在 Wordpress + q-translate + CMB2 + 可重复组中丢失换行符

[英]Losing line breaks in Wordpress + q-translate + CMB2 + repeatable group

I'll try to be short: Multilingual Wordpress site with custom post type registered in functions.php and CMB2 for creating custom forms.我会尽量简短:在functions.php 和CMB2 中注册自定义帖子类型的多语言Wordpress 站点,用于创建自定义表单。 The plugin for multilingual is q-translate-x and also using CMB2-qTranslate.多语言插件是 q-translate-x,也使用 CMB2-qTranslate。

My problem is that I'm losing all line breaks and all <p> tags when I switch the language but it only fails if the editor is contained in a repeatable group.我的问题是,当我切换语言时,我会丢失所有换行符和所有<p>标记,但只有当编辑器包含在可重复组中时才会失败。 If I add the wysiwyg edit as normal field It works fine.如果我将所见即所得编辑添加为普通字段它工作正常。

-Relevant code for the normal field (this works fine): - 普通字段的相关代码(这很好用):

$cmb_tb->add_field( array(
    'name'    => esc_html__( 'Historia', 'cmb2' ),
    'desc'    => esc_html__( 'field description (optional)', 'cmb2' ),
    'id'      => $prefix . 'historia',
    'type'    => 'wysiwyg',
    'options' => array( 'textarea_rows' => 5, 'editor_class' => 'cmb2-qtranslate'),
) );

-Relevant code for repeatable field (this loses line breaks and <p> tags on language switching): - 可重复字段的相关代码(在语言切换时会丢失换行符和<p>标签):

<pre><code>
$group_field_id = $cmb_tb->add_field( array(
'id'          => 'Fincas',
'type'        => 'group',
'description' => __( 'Fincas', 'cmb2' ),
// 'repeatable'  => false, // use false if you want non-repeatable group
'options'     => array(
    'group_title'   => __( 'Finca {#}', 'cmb2' ), // since version 1.1.4, {#} gets replaced by row number
    'add_button'    => __( 'Añadir otra Finca', 'cmb2' ),
    'remove_button' => __( 'Eliminar Finca', 'cmb2' ),
 //   'sortable'      => true, // beta
    'closed'     => false, // true to have the groups closed by default
),
) );

$cmb_tb->add_group_field($group_field_id, array(
    'name'    => esc_html__( 'Nombre Finca', 'cmb2' ),
    'desc'    => esc_html__( '', 'cmb2' ),
    'id'      => $prefix . 'nombre_finca',
    'type'    => 'wysiwyg',
    'options' => array( 'textarea_rows' => 5, 'editor_class' => 'cmb2-qtranslate')
) );

</code></pre>

This is driving me crazy.这真让我抓狂。 I've created a sample website with this problem for testing.我已经创建了一个示例网站来测试这个问题。 I can give access to anyone who feels that can help.我可以让任何认为可以提供帮助的人访问。

Many thanks in advance.提前谢谢了。

Finally, I figured out.终于,我想通了。 It was as easy to add 'wpautop' => false to options array'wpautop' => false到 options 数组很容易

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM