“WooCommerce_form_field()”函数在最新的WooCommerce更新后出现问题

时间:2020-06-26 作者:vred

在woocommerce的最新更新之前,我有这个自定义代码,但在更新之后,选项字段中的HTML标记现在显示在live站点上。要清楚的是,标签现在显示出来了,而在它添加换行符之前,它应该这样做。

add_action( \'woocommerce_after_order_notes\', \'checkout_outofstockoption\' );

function checkout_outofstockoption( $checkout ) {

    echo \'<div id="my_custom_checkout_field"><h3>\' . __(\'Option if product is not available\') . \'</h3>\';

    woocommerce_form_field( \'outofstockoption\', array(
        \'type\'          => \'radio\',
        \'class\'         => array(\'my-field-class form-row-wide\'),
        \'label\'         => __(\'We try our best to ensure accurate stock levels. However, in the event that your product is out of stock, please let us know how you would like us to proceed:<br />\'),
        \'options\'       => array(\'Substitute\'=>\' Substitute with a similar item of equal or greater value (if no suitable substitute is available a credit will be issued)<br />\',\'Credit\'=>\' Receive store credit<br />\'),
        \'required\'      => true
        ), $checkout->get_value( \'outofstockoption\' ));

    echo \'</div>\';
}
在新的更新中有什么不同之处吗?

提前感谢您的帮助

1 个回复
SO网友:user141080

在版本中4.2.1 他们添加了功能esc_html 到选项文本。此处是版本的链接4.2.0 用于比较。