Improve float sanitization

This commit is contained in:
Tetrakern 2024-02-12 13:58:11 +01:00
parent 22b7952cd4
commit e38ffa05f1
2 changed files with 5 additions and 5 deletions

View File

@ -1359,16 +1359,16 @@ function fictioneer_sanitize_positive_float( $value, $default = 0.0 ) {
}
/**
* Sanitizes the word count modifier
* Sanitize callback with positive float or default 1.0
*
* @since 5.9.4
* @since 5.10.1
*
* @param mixed $value The value to be sanitized.
*
* @return float The sanitized float.
* @return float The sanitized positive float.
*/
function fictioneer_sanitize_word_count_modifier( $value ) {
function fictioneer_sanitize_float_field( $value ) {
// Ensure $value is numeric in the first place
if ( ! is_numeric( $value ) ) {
return 1.0;

View File

@ -783,7 +783,7 @@ define( 'FICTIONEER_OPTIONS', array(
'fictioneer_word_count_multiplier' => array(
'name' => 'fictioneer_word_count_multiplier',
'group' => 'fictioneer-settings-general-group',
'sanitize_callback' => 'fictioneer_sanitize_word_count_modifier',
'sanitize_callback' => 'fictioneer_sanitize_float_field',
'label' => __( 'Multiplier for displayed word counts.', 'fictioneer' ),
'default' => 1.0
)