class-redux-validation-numeric.php (941B)
1 <?php 2 /** 3 * Numeric validation 4 * 5 * @package Redux Framework 6 * @subpackage Validation 7 * @author Kevin Provance (kprovance) & Dovy Paukstys 8 * @version 4.0.0 9 */ 10 11 defined( 'ABSPATH' ) || exit; 12 13 if ( ! class_exists( 'Redux_Validation_Numeric', false ) ) { 14 15 /** 16 * Class Redux_Validation_Numeric 17 */ 18 class Redux_Validation_Numeric extends Redux_Validate { 19 20 /** 21 * Field Render Function. 22 * Takes the vars and outputs the HTML for the field in the settings 23 * 24 * @since ReduxFramework 1.0.0 25 */ 26 public function validate() { 27 $this->field['msg'] = ( isset( $this->field['msg'] ) ) ? $this->field['msg'] : esc_html__( 'You must provide a numerical value for this option.', 'redux-framework' ); 28 29 if ( ! is_numeric( $this->value ) ) { 30 $this->value = ( isset( $this->current ) ) ? $this->current : ''; 31 $this->field['current'] = $this->value; 32 33 $this->error = $this->field; 34 } 35 } 36 } 37 }