class-redux-validation-js.php (861B)
1 <?php 2 /** 3 * Javascript 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_Js', false ) ) { 14 15 /** 16 * Class Redux_Validation_Js 17 */ 18 class Redux_Validation_Js extends Redux_Validate { 19 20 /** 21 * Field Validation 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__( 'Javascript has been successfully escaped.', 'redux-framework' ); 28 29 $js = esc_js( $this->value ); 30 31 if ( $js !== $this->value ) { 32 $this->field['current'] = $js; 33 $this->warning = $this->field; 34 } 35 36 $this->value = $js; 37 } 38 } 39 }