PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / 2.5.7
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization v2.5.7
4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 3.12.0 3.12.1 All 134 releases
optimole-wp / inc / traits / validator.php

validator.php in Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization 2.5.7, at inc/traits/validator.php

62 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Validation traits.
5 *
6 * @package \Optml\Inc\Traits
7 * @author Optimole <friends@optimole.com>
8 */
9 trait Optml_Validator {
10
11 /**
12 * Check if the value is a valid numeric.
13 *
14 * @param mixed $value The value to check.
15 *
16 * @return bool
17 */
18 public function is_valid_numeric( $value ) {
19 if ( isset( $value ) && ! empty( $value ) && is_numeric( $value ) ) {
20 return true;
21 }
22
23 return false;
24 }
25
26 /**
27 * Check if the URl is a GIF url.
28 *
29 * @param string $url URL to check.
30 *
31 * @return bool Is Gif?
32 */
33 public function is_valid_gif( $url ) {
34 $type = wp_check_filetype( $url, [ 'gif' => 'image/gif' ] );
35
36 if ( ! isset( $type['ext'] ) || empty( $type['ext'] ) ) {
37 return false;
38 }
39
40 return true;
41 }
42
43 /**
44 * Check if the url has an accepted mime type extension.
45 *
46 * @param mixed $url The url to check.
47 *
48 * @return bool
49 */
50 public function is_valid_mimetype_from_url( $url, $filters = [] ) {
51 $type = wp_check_filetype( $url, Optml_Config::$all_extensions );
52
53 if ( ! isset( $type['ext'] ) || empty( $type['ext'] ) ) {
54 return false;
55 }
56
57 return Optml_Filters::should_do_extension( $filters, $type['ext'] );
58 }
59
60
61 }
62