php - 未定义变量:第 451 行 F:\websites\websitename\wp-content\plugins\contact-form-7-multi-step-module\cf7msm.php 中的 curr_step
问题描述
#我遇到了contact Form 7 Multi Step Form plugin 4.0.8版本的问题,填写第一个表格后我无法进入下一步,它正在提交成功消息。
我在第 451 行得到未定义的变量:F:\websites\websitename\wp-content\plugins\contact-form-7-multi-step-module\cf7msm.php 中的 curr_step
{
$curr_step = '';
$last_step = '';
$is_last_step = false;
if ( empty($cf7_posted_data['cf7msm-step']) && empty($cf7_posted_data['cf7msm_options']) ) {
return $cf7_posted_data;
}
if ( isset( $cf7_posted_data['cf7msm-step'] ) ) {
if ( preg_match( '/(\\d+)-(\\d+)/', $cf7_posted_data['cf7msm-step'], $matches ) ) {
$curr_step = $matches[1];
$last_step = $matches[2];
$is_last_step = $curr_step == $last_step;
}
}
if ( !empty($curr_step) && !empty($last_step) ) {
//for step-restricted back button
$prev_urls = cf7msm_get( 'cf7msm_prev_urls' );
if ( empty($prev_urls) ) {
$prev_urls = array();
}
//old example:
// on step 1,
// prev url {"2-3":"page-2"} will be set.
// back button is pressed, key "1-3" is looked up and returns undefined
// on step 2,
// prev url {"3-3":"page-2"} will be set.
// back button is pressed, key "2-3" is looked up and returns "page-1"
// on step 3,
// prev url {"4-3":"page-3"} will be set. - not used
// back button is pressed, key "3-3" is looked up and returns "page-2"
// step
$prev_urls[$curr_step + 1 . '-' . $last_step] = cf7msm_current_url();
cf7msm_set( 'cf7msm_prev_urls', $prev_urls );
}
// TODO: set curr_step and last_step for new tag when implemented.
if ( !empty($cf7_posted_data['cf7msm_options']) ) {
$options = json_decode( stripslashes( $cf7_posted_data['cf7msm_options'] ), true );
$is_last_step = !empty($options['last_step']);
}
$use_cookies = true;
if ( !empty($cf7_posted_data['cf7msm-no-ss']) || $use_cookies ) {
$prev_data = cf7msm_get( 'cf7msm_posted_data', '' );
if ( !is_array( $prev_data ) ) {
$prev_data = array();
}
//remove empty [form] tags from posted_data so $prev_data can be stored.
$fes = wpcf7_scan_form_tags();
foreach ( $fes as $fe ) {
if ( empty($fe['name']) || $fe['type'] != 'form' && $fe['type'] != 'multiform' ) {
continue;
}
unset( $cf7_posted_data[$fe['name']] );
}
$free_text_keys = array();
foreach ( $prev_data as $key => $value ) {
if ( strpos( $key, CF7MSM_FREE_TEXT_PREFIX_RADIO ) === 0 ) {
$free_text_keys[$key] = str_replace( CF7MSM_FREE_TEXT_PREFIX_RADIO, '', $key );
} else {
if ( strpos( $key, CF7MSM_FREE_TEXT_PREFIX_CHECKBOX ) === 0 ) {
$free_text_keys[$key] = str_replace( CF7MSM_FREE_TEXT_PREFIX_CHECKBOX, '', $key );
}
}
}
//if original key is set and not free text, remove free text to reflect posted data.
foreach ( $free_text_keys as $free_text_key => $original_key ) {
if ( isset( $cf7_posted_data[$original_key] ) && !isset( $cf7_posted_data[$free_text_key] ) ) {
unset( $prev_data[$free_text_key] );
}
}
$cf7_posted_data = array_merge( $prev_data, $cf7_posted_data );
}
return $cf7_posted_data;
}
add_filter( 'wpcf7_posted_data', 'cf7msm_add_other_steps_filter', 9 );
/**
* If use cookies and not the last step, store the values here after it's been validated.
*/
function cf7msm_store_data_steps()
{
$use_cookies = true;
if ( $use_cookies ) {
$cf7_posted_data = WPCF7_Submission::get_instance()->get_posted_data();
$is_last_step = false;
if ( !empty($cf7_posted_data['cf7msm_options']) ) {
$options = json_decode( stripslashes( $cf7_posted_data['cf7msm_options'] ), true );
$is_last_step = !empty($options['last_step']);
}
if ( !$is_last_step ) {
// don't track big cookies on last step bc submitting on the last step doesn't use the cookie.
cf7msm_track_big_cookie( $curr_step, $cf7_posted_data );
cf7msm_set( 'cf7msm_posted_data', $cf7_posted_data );
}
}
}
add_action( 'wpcf7_before_send_mail', 'cf7msm_store_data_steps' );```
解决方案
推荐阅读
- r - 当这两个词被其他词包围时,是否有可能匹配字符中的两个词?
- apache-spark - 如何在 AWS DyanmoDB 上执行 ETL 作业以仅在使用 AWS Glue 的新数据上获取 S3 中的 csv 文件
- java - 检查所有 Dto 成员中的空条件。如果不是,则将该值设置为 pojo 类的相同属性
- mysql - 调用 MySql 存储过程
- ios - 对于键名或我在代码中给出的任何值,此类不符合键值编码
- android - Google 权限策略更改对 READ_CALL_LOG 权限的 CRM 应用程序的影响
- ios - 如何从 App Store Connect 中删除“未解决的问题”横幅?
- html - 如何将角度分量输出提取到外部 div
- sql-server - 我创建并运行了一个 sqlserver 容器,我停止了它,我不知道如何再次运行它?
- r - 如何绑定两个数据框的行,使 ID 列中具有相同值的行彼此相邻