Wordpress 前端wp_编辑器未在视觉模式下保存,仅在文本模式下工作

Wordpress 前端wp_编辑器未在视觉模式下保存,仅在文本模式下工作,wordpress,woocommerce,hook-woocommerce,wp-editor,Wordpress,Woocommerce,Hook Woocommerce,Wp Editor,我在woocommerce中添加了wp_编辑器自定义字段,除wp_编辑器外,所有字段均正常工作,在可视化编辑器模式下不保存任何值。但只能在文本模式下保存值 此外,当使用文本模式时,所有html代码都将消失 你知道怎么解决这个问题吗 // Add a new checkout field function kia_filter_checkout_fields($fields){ $fields['extra_fields'] = array( 'descreportfie

我在woocommerce中添加了wp_编辑器自定义字段,除wp_编辑器外,所有字段均正常工作,在可视化编辑器模式下不保存任何值。但只能在文本模式下保存值

此外,当使用文本模式时,所有html代码都将消失

你知道怎么解决这个问题吗

// Add a new checkout field

function kia_filter_checkout_fields($fields){
    $fields['extra_fields'] = array(
        'descreportfield' => array(),
        'descanotherfield' => array(
            'type' => 'select',
            'options' => array( 'a' => __( 'apple' ), 'b' => __( 'bacon' ), 'c' => __( 'chocolate' ) ),
            'required'      => true,
            'label' => __( 'Another field' )
        )
    );

    return $fields;
}
add_filter( 'woocommerce_checkout_fields', 'kia_filter_checkout_fields' );

// display the extra field on the checkout form
function kia_extra_checkout_fields(){ 
    $settings =   array(
        'wpautop' => true, // use wpautop?
        'media_buttons' => true, // show insert/upload button(s)
        'textarea_name' => 'descreportfield', // set the textarea name to something different, square brackets [] can be used here
        'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..."
        'tabindex' => '',
        'editor_css' => '', // intended for extra styles for both visual and HTML editors buttons, needs to include the <style> tags, can use "scoped".
        'editor_class' => '', // add extra class(es) to the editor textarea
        'teeny' => false, // output the minimal editor config used in Press This
        'dfw' => false, // replace the default fullscreen with DFW (supported on the front-end in WordPress 3.4)
        'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
        'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array()
    );
    //$allowed_tags = wp_kses_allowed_html('post');
    $checkout = WC()->checkout(); ?>

<div class="extra-fields">
    <h3><?php _e( 'Additional Fields' ); ?></h3>
        <?php
    wp_editor('', 'descreportfield', $settings);
    woocommerce_form_field( 'descanotherfield', array(
            'type' => 'select',
            'options' => array( 'a' => __( 'apple' ), 'b' => __( 'bacon' ), 'c' => __( 'chocolate' ) ),
            'required'      => true,
            'label' => __( 'Another field' )
        ), $checkout->get_value( 'descanotherfield' ) );
    ?>
    </div>

<?php }
add_action( 'woocommerce_checkout_after_customer_details' ,'kia_extra_checkout_fields' );


function kia_save_extra_checkout_fields( $order, $data ){
    // don't forget appropriate sanitization if you are using a different field type
    if( isset( $data['descreportfield'] ) ) {
        $order->update_meta_data( '_descreportfield',$data['descreportfield']);
    }
    if( isset( $data['descanotherfield'] ) && in_array( $data['descanotherfield'], array( 'a', 'b', 'c' ) ) ) {
        $order->update_meta_data( '_descanotherfield', $data['descanotherfield'] );
    } 
}
add_action( 'woocommerce_checkout_create_order', 'kia_save_extra_checkout_fields', 10, 2 );

// display the extra data on order received page and my-account order review
function kia_display_order_data( $order_id ){  
    $order = wc_get_order( $order_id ); ?>
    <h2><?php _e( 'Additional Info' ); ?></h2>
    <table class="shop_table shop_table_responsive additional_info">
        <tbody>
            <tr>
                <th><?php _e( 'Some Field:' ); ?></th>
                <td><?php echo $order->get_meta( '_descreportfield' ); ?></td>
            </tr>
            <tr>
                <th><?php _e( 'Another Field:' ); ?></th>
                <td><?php echo $order->get_meta( '_descanotherfield' ); ?></td>
            </tr>
        </tbody>
    </table>
<?php }
add_action( 'woocommerce_thankyou', 'kia_display_order_data', 20 );
add_action( 'woocommerce_view_order', 'kia_display_order_data', 20 );
//添加新的签出字段
函数kia\u filter\u checkout\u字段($fields){
$fields['extra_fields']=数组(
'descreportfield'=>array(),
“descanotherfield”=>数组(
'类型'=>'选择',
'options'=>array('a'=>。'apple'),'b'=>。'bacon'),'c'=>。'cocolate'),
“必需”=>true,
“标签”=>(另一个字段)
)
);
返回$fields;
}
添加_过滤器('woocommerce_checkout_fields'、'kia_filter_checkout_fields');
//在签出窗体上显示额外字段
函数kia_extra_checkout_fields(){
$settings=数组(
'wpautop'=>true,//是否使用wpautop?
“媒体按钮”=>true,//显示插入/上载按钮
'textarea_name'=>'descreportfield',//将textarea名称设置为其他名称,此处可以使用方括号[]
'textarea_rows'=>get_选项('default_post_edit_rows',10),//rows=“…”
“tabindex'=>”,
'editor_css'=>'',//用于视觉和HTML编辑器按钮的额外样式,需要包括标记,可以使用“范围”。
'editor_class'=>'',//向编辑器文本区域添加额外的类
'teeny'=>false,//输出此按钮中使用的最小编辑器配置
'dfw'=>false,//用dfw替换默认全屏(在WordPress 3.4的前端支持)
'tinymce'=>true,//load tinymce可用于使用数组()将设置直接传递给tinymce
“quicktags”=>true//load quicktags可用于使用数组()将设置直接传递给quicktags
);
//$allowed_tags=wp_kses_allowed_html('post');
$checkout=WC()->checkout();?>