-
-
Save rilwis/0491dde925d20f9fff9b to your computer and use it in GitHub Desktop.
Create new field type
This file contains 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
<?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