【发布时间】:2016-01-22 19:49:09
【问题描述】:
如何使用附加的代码解决以下问题?似乎 Wordpress(或某种插件)以某种方式调用了该函数两次。
function my_wpcf7_form_elements($html) {
function ov3rfly_replace_include_blank($name, $text, &$html) {
$matches = false;
preg_match('/<select name="' . $name . '"[^>]*>(.*)<\/select>/iU', $html, $matches);
if ($matches) {
$select = str_replace('<option value="">---</option>', '<option value="">' . $text . '</option>', $matches[0]);
$html = preg_replace('/<select name="' . $name . '"[^>]*>(.*)<\/select>/iU', $select, $html);
}
}
ov3rfly_replace_include_blank('countrylist', 'España', $html);
return $html;
}
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');
致命错误:无法在 /Applications/XAMPP/xamppfiles 中重新声明 ov3rfly_replace_include_blank()(之前在 /Applications/XAMPP/xamppfiles/htdocs/w/wp-content/themes/bulwark_child/functions.php:21 中声明) /htdocs/w/wp-content/themes/bulwark_child/functions.php 第 21 行
【问题讨论】:
-
简单你不能有两个相同的函数名,除非你重载