Skip to content

Instantly share code, notes, and snippets.

@styledev
Created June 18, 2013 18:34

Revisions

  1. styledev created this gist Jun 18, 2013.
    17 changes: 17 additions & 0 deletions number.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    function create_field( $field )
    {
    $o = array( 'id', 'class', 'min', 'max', 'step', 'name', 'value' );
    $e = '<input type="number"';

    foreach( $o as $k )
    {
    $val = $field[ $k ];
    if ( $k == 'step' && empty($val) ) $val = 'any';
    $e .= ' ' . $k . '="' . esc_attr( $val ) . '"';
    }

    $e .= ' />';

    echo $e;

    }