PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.2.10
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.2.10
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
← All changes | admin/views/sp-framework/functions/validate.php +133 -57 2.3.62.2.10 View file →
@@ -1,76 +1,152 @@
1 -<?php if ( ! defined( 'ABSPATH' ) ) {
2 - die; } // Cannot access directly.
1 +<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 +/**
3 + *
4 + * Email validate
5 + *
6 + * @since 1.0.0
7 + * @version 1.0.0
8 + *
9 + */
10 +if( ! function_exists( 'spf_validate_email' ) ) {
11 + function spf_validate_email( $value ) {
3 12
4 -if ( ! function_exists( 'spf_validate_email' ) ) {
5 - /**
6 - * Email validate
7 - *
8 - * @param string $value The email.
9 - * @since 1.0.0
10 - * @version 1.0.0
11 - */
12 - function spf_validate_email( $value ) {
13 + if ( ! filter_var( $value, FILTER_VALIDATE_EMAIL ) ) {
14 + return esc_html__( 'Please write a valid email address!', 'smart-post-show' );
15 + }
13 16
14 - if ( ! filter_var( $value, FILTER_VALIDATE_EMAIL ) ) {
15 - return esc_html__( 'Please write a valid email address!', 'smart-post-show' );
16 - }
17 + }
18 +}
17 19
18 - }
20 +/**
21 + *
22 + * Numeric validate
23 + *
24 + * @since 1.0.0
25 + * @version 1.0.0
26 + *
27 + */
28 +if( ! function_exists( 'spf_validate_numeric' ) ) {
29 + function spf_validate_numeric( $value ) {
30 +
31 + if ( ! is_numeric( $value ) ) {
32 + return esc_html__( 'Please write a numeric data!', 'smart-post-show' );
33 + }
34 +
35 + }
19 36 }
20 37
38 +/**
39 + *
40 + * Required validate
41 + *
42 + * @since 1.0.0
43 + * @version 1.0.0
44 + *
45 + */
46 +if( ! function_exists( 'spf_validate_required' ) ) {
47 + function spf_validate_required( $value ) {
21 48
22 -if ( ! function_exists( 'spf_validate_numeric' ) ) {
23 - /**
24 - *
25 - * Numeric validate
26 - *
27 - * @param string $value The number.
28 - * @since 1.0.0
29 - * @version 1.0.0
30 - */
31 - function spf_validate_numeric( $value ) {
49 + if ( empty( $value ) ) {
50 + return esc_html__( 'Error! This field is required!', 'smart-post-show' );
51 + }
32 52
33 - if ( ! is_numeric( $value ) ) {
34 - return esc_html__( 'Please write a numeric data!', 'smart-post-show' );
35 - }
53 + }
54 +}
36 55
37 - }
56 +/**
57 + *
58 + * URL validate
59 + *
60 + * @since 1.0.0
61 + * @version 1.0.0
62 + *
63 + */
64 +if( ! function_exists( 'spf_validate_url' ) ) {
65 + function spf_validate_url( $value ) {
66 +
67 + if( ! filter_var( $value, FILTER_VALIDATE_URL ) ) {
68 + return esc_html__( 'Please write a valid url!', 'smart-post-show' );
69 + }
70 +
71 + }
38 72 }
39 73
74 +/**
75 + *
76 + * Email validate for Customizer
77 + *
78 + * @since 1.0.0
79 + * @version 1.0.0
80 + *
81 + */
82 +if( ! function_exists( 'spf_customize_validate_email' ) ) {
83 + function spf_customize_validate_email( $validity, $value, $wp_customize ) {
40 84
41 -if ( ! function_exists( 'spf_validate_required' ) ) {
42 - /**
43 - *
44 - * Required validate
45 - *
46 - * @param string $value The required data.
47 - * @since 1.0.0
48 - * @version 1.0.0
49 - */
50 - function spf_validate_required( $value ) {
85 + if ( ! sanitize_email( $value ) ) {
86 + $validity->add( 'required', esc_html__( 'Please write a valid email address!', 'smart-post-show' ) );
87 + }
51 88
52 - if ( empty( $value ) ) {
53 - return esc_html__( 'Error! This field is required!', 'smart-post-show' );
54 - }
89 + return $validity;
55 90
56 - }
91 + }
57 92 }
58 93
94 +/**
95 + *
96 + * Numeric validate for Customizer
97 + *
98 + * @since 1.0.0
99 + * @version 1.0.0
100 + *
101 + */
102 +if( ! function_exists( 'spf_customize_validate_numeric' ) ) {
103 + function spf_customize_validate_numeric( $validity, $value, $wp_customize ) {
59 104
60 -if ( ! function_exists( 'spf_validate_url' ) ) {
61 - /**
62 - *
63 - * URL validate
64 - *
65 - * @param string $value The URL.
66 - * @since 1.0.0
67 - * @version 1.0.0
68 - */
69 - function spf_validate_url( $value ) {
105 + if ( ! is_numeric( $value ) ) {
106 + $validity->add( 'required', esc_html__( 'Please write a numeric data!', 'smart-post-show' ) );
107 + }
70 108
71 - if ( ! filter_var( $value, FILTER_VALIDATE_URL ) ) {
72 - return esc_html__( 'Please write a valid url!', 'smart-post-show' );
73 - }
109 + return $validity;
74 110
75 - }
111 + }
112 +}
113 +
114 +/**
115 + *
116 + * Required validate for Customizer
117 + *
118 + * @since 1.0.0
119 + * @version 1.0.0
120 + *
121 + */
122 +if( ! function_exists( 'spf_customize_validate_required' ) ) {
123 + function spf_customize_validate_required( $validity, $value, $wp_customize ) {
124 +
125 + if ( empty( $value ) ) {
126 + $validity->add( 'required', esc_html__( 'Error! This field is required!', 'smart-post-show' ) );
127 + }
128 +
129 + return $validity;
130 +
131 + }
132 +}
133 +
134 +/**
135 + *
136 + * URL validate for Customizer
137 + *
138 + * @since 1.0.0
139 + * @version 1.0.0
140 + *
141 + */
142 +if( ! function_exists( 'spf_customize_validate_url' ) ) {
143 + function spf_customize_validate_url( $validity, $value, $wp_customize ) {
144 +
145 + if( ! filter_var( $value, FILTER_VALIDATE_URL ) ) {
146 + $validity->add( 'required', esc_html__( 'Please write a valid url!', 'smart-post-show' ) );
147 + }
148 +
149 + return $validity;
150 +
151 + }
76 152 }