Skip to content

Instantly share code, notes, and snippets.

@yatil
Created July 12, 2011 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yatil/1077512 to your computer and use it in GitHub Desktop.
Save yatil/1077512 to your computer and use it in GitHub Desktop.
html5 input types in wordpress w/ required attribute
<?php
/*
Plugin Name: html5 input-types
Plugin URI: http://notizblog.org/
Description: Adds the new HTML5 input-types to WordPress' default forms
Version: 0.1
Author: pfefferle
Author URI: http://notizblog.org/
*/
add_filter("comment_form_default_fields", "change_comment_input_types");
function change_comment_input_types($fields) {
$fields['email'] = preg_replace('/"text"/', '"email" required', $fields['email']);
$fields['url'] = preg_replace('/"text"/', '"url" required', $fields['url']);
return $fields;
}
add_filter("get_search_form", "change_search_form_input_types");
function change_search_form_input_types($form) {
return preg_replace('/"text"/', '"search"', $form);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment