PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.1.1
Kirki – Freeform Page Builder, Website Builder & Customizer v6.1.1
6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / includes / FormValidator / Validate.php
kirki / includes / FormValidator Last commit date
FormValidator.php 2 months ago Validate.php 2 months ago
Validate.php
70 lines
1 <?php
2
3 /**
4 * Validate
5 *
6 * @package kirki
7 */
8
9 namespace Kirki\FormValidator;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 class Validate {
16
17 public static function email( $email = '' ) {
18 return is_email( $email );
19 }
20
21 public static function number( $input ) {
22 return ! empty( $input ) && is_numeric( $input );
23 }
24
25 public static function tel( $input ) {
26 $tel_regex = '/^[0-9]{10}+$/';
27
28 return preg_match( $tel_regex, $input );
29 }
30
31 public static function date( $input ) {
32 $date_regex = '/^\d{4}-\d{2}-\d{2}$/';
33
34 return preg_match( $date_regex, $input );
35 }
36
37 public static function datetime( $input ) {
38 $datetime_regex = '/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/';
39
40 return preg_match( $datetime_regex, $input );
41 }
42
43 public static function max_char( $input, $max_length ) {
44 return strlen( (string) $input ) <= (int) $max_length;
45 }
46
47 public static function min_char( $input, $min_length ) {
48 return strlen( (string) $input ) >= (int) $min_length;
49 }
50
51 public static function accepted_file_type( $file_type, $accepted_file_types ) {
52 // kirki supported media types for file input
53 $kirki_supported_media_types = KIRKI_SUPPORTED_MEDIA_TYPES_FOR_FILE_INPUT[ $accepted_file_types ];
54
55 // check if file type is in kirki supported media types
56 if ( ! empty( $kirki_supported_media_types ) && in_array( $file_type, $kirki_supported_media_types, true ) ) {
57 return true;
58 }
59
60 return false;
61 }
62
63 public static function max_file_size( $file_size, $max_file_size ) {
64 // convert file size to MB
65 $file_size = ! empty( $file_size ) ? (float) number_format( $file_size / 1048576, 2 ) : 2;
66
67 return $file_size <= (int) $max_file_size;
68 }
69 }
70