this is the url to the test site – http://gil.beastserv.com/hava/
i have this function, with some help from here
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('c_age', '×××', $html);
ov3rfly_replace_include_blank('c_area', '××××ר', $html);
ov3rfly_replace_include_blank('c_type', 'ס×× ×××××', $html);
ov3rfly_replace_include_blank('c_area', '××××ר', $html);
ov3rfly_replace_include_blank('c_cartype', 'ס×× ×¨××', $html);
ov3rfly_replace_include_blank('c_manifacture', '×צר×', $html);
ov3rfly_replace_include_blank('c_manifactureyear', '×©× ×ª ×צ×ר', $html);
ov3rfly_replace_include_blank('c_driversage', '××× ×× ××', $html);
ov3rfly_replace_include_blank('c_prevent', 'ש××××ת', $html);
ov3rfly_replace_include_blank('c_claim', 'ת×××¢×ת', $html);
return $html;
}
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');
its working great when there is only 1 form, but when im tring to place 2 forms in 1 page, im getting the Fatal error: Cannot redeclare ov3rfly_replace_include_blank() (previously declared
i tried to place the if (!function_exists('formatStr')) {}
as so:
if (!function_exists('formatStr')) {
function my_wpcf7_form_elements($html) {}
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');
}
but i guess that its not the problem.. the function is called twice, because there are 2 forms.. how can i overcome this?
Thanks alot.
From http://es2.php.net/manual/en/functions.user-defined.php:
function
ov3rfly_replace_include_blank
is being declared every time you callmy_wpcf7_form_elements
, and PHP does not support function overloading, hence the error. Since all PHP functions have global scope, they can be called inside a function even if they where defined outside. Try: