| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! class_exists( 'Redux_Validation_numeric' ) ) { |
| 4 |
class Redux_Validation_numeric { |
| 5 |
|
| 6 |
/** |
| 7 |
* Field Constructor. |
| 8 |
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function |
| 9 |
* |
| 10 |
* @since ReduxFramework 1.0.0 |
| 11 |
*/ |
| 12 |
function __construct( $parent, $field, $value, $current ) { |
| 13 |
|
| 14 |
$this->parent = $parent; |
| 15 |
$this->field = $field; |
| 16 |
$this->field['msg'] = ( isset( $this->field['msg'] ) ) ? $this->field['msg'] : __( 'You must provide a numerical value for this option.', 'redux-framework' ); |
| 17 |
$this->value = $value; |
| 18 |
$this->current = $current; |
| 19 |
|
| 20 |
$this->validate(); |
| 21 |
} //function |
| 22 |
|
| 23 |
/** |
| 24 |
* Field Render Function. |
| 25 |
* Takes the vars and outputs the HTML for the field in the settings |
| 26 |
* |
| 27 |
* @since ReduxFramework 1.0.0 |
| 28 |
*/ |
| 29 |
function validate() { |
| 30 |
|
| 31 |
if ( ! is_numeric( $this->value ) ) { |
| 32 |
$this->value = ( isset( $this->current ) ) ? $this->current : ''; |
| 33 |
$this->error = $this->field; |
| 34 |
} |
| 35 |
} //function |
| 36 |
} //class |
| 37 |
} |