class-redux-validation-url.php (976B)
1 <?php 2 /** 3 * URL 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_Url', false ) ) { 14 15 /** 16 * Class Redux_Validation_Url 17 */ 18 class Redux_Validation_Url extends Redux_Validate { 19 20 /** 21 * Field Render Function. 22 * Takes the vars and validates them 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 valid URL for this option.', 'redux-framework' ); 28 29 if ( false === filter_var( $this->value, FILTER_VALIDATE_URL ) ) { 30 $this->value = ( isset( $this->current ) ) ? $this->current : ''; 31 $this->field['current'] = $this->value; 32 33 $this->error = $this->field; 34 } else { 35 $this->value = esc_url_raw( $this->value ); 36 } 37 } 38 } 39 }