问题概述
如果您使用的是 Contact Form 7 Multilingual 插件,在查看包含已翻译联系表单的页面时,您可能会遇到 PHP 警告。警告内容如下:
Warning: Undefined array key "title" in /path-to-website/wp-content/plugins/contact-form-7/includes/contact-form-functions.php on line 239
临时解决方法
此问题已在 Contact Form 7 Multilingual 1.2.2 中修复。 更新即可在您的站点上解决此问题,因此只有在您还无法更新时,才需要此临时解决方法。
在继续操作之前,请确保对您的站点进行完整备份。
- 打开 …/wp-content/plugins/contact-form-7-multilingual/classes/shortcodes.php 文件。
- 找到以下代码:
if ( ! $form && ! empty( $atts['title'] ) ) { $form = wpcf7_get_contact_form_by_title( trim( $atts['title'] ) ); unset( $atts['title'] ); } - 注释掉第 30 行:
if ( ! $form && ! empty( $atts['title'] ) ) { $form = wpcf7_get_contact_form_by_title( trim( $atts['title'] ) ); //unset( $atts['title'] ); }