-
-
Save cristianstan/7afc7d69ace0b047fc12116161af90c3 to your computer and use it in GitHub Desktop.
CMB2 Number Field
This file contains hidden or 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 | |
$cmb->add_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', | |
) ); | |
$cmb->add_field( 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', | |
) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment