Skip to content

Instantly share code, notes, and snippets.

@kankadev
Created February 27, 2023 18:25
Show Gist options
  • Save kankadev/4da0a382006ad9612ed8f1a4a2c21e66 to your computer and use it in GitHub Desktop.
Save kankadev/4da0a382006ad9612ed8f1a4a2c21e66 to your computer and use it in GitHub Desktop.
[CF7 Replace Input-Submit with real button] Replaces <input type="submit"> with real button in CF7 #cf7 #functions.php #wordpress
#region CF7
#region Submit-Input durch Button ersetzen
remove_action('wpcf7_init', 'wpcf7_add_form_tag_submit');
add_action('wpcf7_init', 'nd_cf7_button');
if (!function_exists('nd_cf7_button')) {
function nd_cf7_button()
{
wpcf7_add_form_tag('submit', 'nd_cf7_button_handler');
}
}
if (!function_exists('nd_cf7_button_handler')) {
function nd_cf7_button_handler($tag)
{
$tag = new WPCF7_FormTag($tag);
$class = wpcf7_form_controls_class($tag->type);
$atts = array();
$atts['class'] = $tag->get_class_option($class);
$atts['class'] .= ' et_pb_button';
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
$value = isset($tag->values[0]) ? $tag->values[0] : '';
if (empty($value)) {
$value = "Send";
}
$atts['type'] = 'submit';
$atts = wpcf7_format_atts($atts);
$html = sprintf('<button class="wpcf7-form-control has-spinner wpcf7-submit et_pb_button" type="submit">%2$s</button>', $atts, $value);
return $html;
}
}
#endregion Submit-Input durch Button ersetzen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment