balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

class-redux-validate.php (976B)


      1 <?php
      2 /**
      3  * Redux Validate Class
      4  *
      5  * @class Redux_Validate
      6  * @version 4.0.0
      7  * @package Redux Framework
      8  */
      9 
     10 defined( 'ABSPATH' ) || exit;
     11 
     12 if ( ! class_exists( 'Redux_Validate', false ) ) {
     13 
     14 	/**
     15 	 * Class Redux_Validate
     16 	 */
     17 	abstract class Redux_Validate {
     18 
     19 		/**
     20 		 * Redux_Validate constructor.
     21 		 *
     22 		 * @param object       $parent ReduxFramework pointer.
     23 		 * @param array        $field Fields array.
     24 		 * @param array|string $value Values array.
     25 		 * @param mixed        $current Current.
     26 		 */
     27 		public function __construct( $parent, array $field, $value, $current ) {
     28 			$this->parent  = $parent;
     29 			$this->field   = $field;
     30 			$this->value   = $value;
     31 			$this->current = $current;
     32 
     33 			if ( isset( $this->field['validate_msg'] ) ) {
     34 				$this->field['msg'] = $this->field['validate_msg'];
     35 
     36 				unset( $this->field['validate_msg'] );
     37 			}
     38 
     39 			$this->validate();
     40 		}
     41 
     42 		/**
     43 		 * Validate.
     44 		 *
     45 		 * @return mixed
     46 		 */
     47 		abstract public function validate();
     48 	}
     49 }