Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Forked from jtsternberg/cmb2-number-field.php
Last active September 8, 2016 21:40
Show Gist options
  • Save Shelob9/415b614e58ca2e11f502b6336110ef70 to your computer and use it in GitHub Desktop.
Save Shelob9/415b614e58ca2e11f502b6336110ef70 to your computer and use it in GitHub Desktop.
CMB2 Number Field
array(
'name' => __( 'Postive numbers', 'theme-domain' ),
'desc' => __( 'Numbers only', 'msft-newscenter' ),
'id' => $prefix . 'number',
'type' => 'text',
'attributes' => array(
'type' => 'number',
'pattern' => '\d*',
),
'sanitization_cb' => 'absint',
'escape_cb' => 'absint',
),
array(
'name' => __( 'Numbers', 'theme-domain' ),
'desc' => __( 'Numbers only', 'msft-newscenter' ),
'id' => $prefix . 'number',
'type' => 'text',
'attributes' => array(
'type' => 'number',
'pattern' => '\d*',
),
'sanitization_cb' => 'intval',
'escape_cb' => 'intval',
),
@jtsternberg
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment