Create a gist now

Instantly share code, notes, and snippets.

@rilwis /field-phone.php Secret
Last active Aug 29, 2015

What would you like to do?
Create new field type
<?php
/**
* This class defines new "phone" field type for Meta Box class
*
* @author Tran Ngoc Tuan Anh <rilwis@gmail.com>
* @package Meta Box
* @see http://metabox.io/?post_type=docs&p=390
*/
if ( class_exists( 'RWMB_Field' ) )
{
class RWMB_Phone_Field extends RWMB_Field
{
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static public function html( $meta, $field )
{
return sprintf(
'<input type="tel" name="%s" id="%s" value="%s" pattern="\d{3}-\d{4}">',
$field['field_name'],
$field['id'],
$meta
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment