| @@ -58,8 +58,11 @@ | ||
| 58 | 58 | protected function add_extra_html_atts( $args, &$input_html ) { |
| 59 | 59 | $this->add_min_max( $args, $input_html ); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | + /** | |
| 63 | + * @param array $args | |
| 64 | + */ | |
| 62 | 65 | public function validate( $args ) { |
| 63 | 66 | $errors = array(); |
| 64 | 67 | |
| 65 | 68 | $this->remove_commas_from_number( $args ); |
| @@ -162,12 +165,14 @@ | ||
| 162 | 165 | * |
| 163 | 166 | * @return void |
| 164 | 167 | */ |
| 165 | 168 | private function remove_commas_from_number( &$args ) { |
| 166 | - if ( str_contains( $args['value'], ',' ) ) { | |
| 167 | - $args['value'] = str_replace( ',', '', $args['value'] ); | |
| 168 | - FrmEntriesHelper::set_posted_value( $this->field, $args['value'], $args ); | |
| 169 | + if ( ! str_contains( $args['value'], ',' ) ) { | |
| 170 | + return; | |
| 169 | 171 | } |
| 172 | + | |
| 173 | + $args['value'] = str_replace( ',', '', $args['value'] ); | |
| 174 | + FrmEntriesHelper::set_posted_value( $this->field, $args['value'], $args ); | |
| 170 | 175 | } |
| 171 | 176 | |
| 172 | 177 | /** |
| 173 | 178 | * Force the value to be numeric before it's saved in the DB |
| @@ -176,13 +181,9 @@ | ||
| 176 | 181 | * |
| 177 | 182 | * @return float |
| 178 | 183 | */ |
| 179 | 184 | public function set_value_before_save( $value ) { |
| 180 | - if ( ! is_numeric( $value ) ) { | |
| 181 | - $value = (float) $value; | |
| 182 | - } | |
| 183 | - | |
| 184 | - return $value; | |
| 185 | + return is_numeric( $value ) ? $value : (float) $value; | |
| 185 | 186 | } |
| 186 | 187 | |
| 187 | 188 | /** |
| 188 | 189 | * @since 4.0.04 |