Forked from landru247/WordPress: Contactfrom 7 - modifys contactform 7's default 'select' value
Created
September 18, 2020 12:32
-
-
Save webdevsuperfast/e042e9745e78a8521df183074ac386de to your computer and use it in GitHub Desktop.
WordPress: Contactfrom 7 - modifys contactform 7's default 'select' value of ---
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// modifys contact form 7's default select value of --- to Please select... | |
function my_wpcf7_form_elements($html) { | |
$text = 'Please select...'; | |
$html = str_replace('<option value="">---</option>', '<option value="">' . $text . '</option>', $html); | |
return $html; | |
} | |
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements'); | |
// Modify multiple selects | |
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); | |
} | |
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements'); | |
} | |
ov3rfly_replace_include_blank('menu-569', 'Choose language', $html); | |
ov3rfly_replace_include_blank('menu-614', 'Choose country', $html); | |
return $html; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// modifys contact form 7's default select value of --- to Please select... | |
function my_wpcf7_form_elements($html) { | |
$text = 'Please select...'; | |
$html = str_replace('<option value="">---</option>', '<option value="">' . $text . '</option>', $html); | |
return $html; | |
} | |
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment