File "validate.php"

Full Path: /home/arielcor/public_html/wp-content/plugins/lastudio-core/functions/validate.php
File size: 1.11 KB
MIME-type: text/x-php
Charset: utf-8

<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
/**
 *
 * Email validate
 *
 * @since 1.0.0
 * @version 1.0.0
 *
 */
if( ! function_exists( 'la_validate_email' ) ) {
  function la_validate_email( $value, $field ) {

    if ( ! sanitize_email( $value ) ) {
      return __( 'Please write a valid email address!', 'la-studio' );
    }

  }
  add_filter( 'la_validate_email', 'la_validate_email', 10, 2 );
}

/**
 *
 * Numeric validate
 *
 * @since 1.0.0
 * @version 1.0.0
 *
 */
if( ! function_exists( 'la_validate_numeric' ) ) {
  function la_validate_numeric( $value, $field ) {

    if ( ! is_numeric( $value ) ) {
      return __( 'Please write a numeric data!', 'la-studio' );
    }

  }
  add_filter( 'la_validate_numeric', 'la_validate_numeric', 10, 2 );
}

/**
 *
 * Required validate
 *
 * @since 1.0.0
 * @version 1.0.0
 *
 */
if( ! function_exists( 'la_validate_required' ) ) {
  function la_validate_required( $value ) {
    if ( empty( $value ) ) {
      return __( 'Fatal Error! This field is required!', 'la-studio' );
    }
  }
  add_filter( 'la_validate_required', 'la_validate_required' );
}