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 | |
/** | |
* Filter the step parameter in Number fields to return decimals | |
*/ | |
function prefix_number_field_step( $step, $item ) { | |
return 0.01; | |
} | |
add_filter( 'pewc_number_field_step', 'prefix_number_field_step', 10, 2 ); | |
/** | |
* Filter the step parameter in some Number fields to return decimals | |
*/ | |
function prefix_specific_number_field_step( $step, $item ) { | |
if( $item['field_id'] = 1234 ) { // Change this to the ID of your field | |
return 0.01; | |
} | |
return $step; | |
} | |
add_filter( 'pewc_number_field_step', 'prefix_specific_number_field_step', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And for more flexibility (applying a custom step for some fields only), it's also possible to use either the 'field_id' or 'group_id' key of the $item array (here with field_id):