下面的答案是对 WordPress v4.7.5 上的 Contact Form 7 Multi-Step Forms v2.1 的错误的非官方修复。
根据author's update,插件无法正常工作。
更新:对于大多数人来说,这个插件仍然可以正常工作,但对某些人来说却不是。
要解决这个问题,您必须编辑插件的一些代码。
在wp-content/plugins/contact-form-7-multi-step-module/form-tags/module-back.php更新这个函数。
/**
* Handle the back form shortcode.
*/
function cf7msm_back_shortcode_handler( $tag ) {
if (!class_exists('WPCF7_Shortcode') || !function_exists('wpcf7_form_controls_class'))
return;
$tag = new WPCF7_Shortcode( $tag );
$class = wpcf7_form_controls_class( $tag->type );
$atts = array();
$atts['class'] = $tag->get_class_option( $class );
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
$value = isset( $tag->values[0] ) ? $tag->values[0] : '';
$previous_url = isset( $tag->values[1] ) ? $tag->values[1] : '.';
if ( empty( $value ) ) {
if ( $tag->type == 'previous') {
$value = __( 'Previous', 'contact-form-7-multi-step-module' );
}
else {
//using old version
$value = __( 'Back', 'contact-form-7-multi-step-module' );
}
}
$atts['type'] = 'button';
$atts['value'] = $value;
$atts['href'] = $previous_url;
$atts = wpcf7_format_atts( $atts );
$html = sprintf( '<input %1$s />', $atts );
return $html;
}
并更新 wp-content/plugins/contact-form-7-multi-step-module/resources/cf7msm.js 中的 1 行更改
window.location.href = val[step_field.val()];
到
window.location.href = $(this).attr('href');
最后,您需要更改在联系表单中插入[previous] 标记的方式。进行上述更改后,[previous] 标签的工作方式如下。
[previous "Button Label" "URL of previous step"]