PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 2.0.9
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v2.0.9
3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / widgets / lottie / json-handler.php
elementskit-lite / widgets / lottie Last commit date
assets 5 years ago json-handler.php 5 years ago lottie-handler.php 5 years ago lottie.php 5 years ago
json-handler.php
90 lines
1 <?php
2
3 namespace ElementsKit_Lite;
4
5 defined('ABSPATH') || exit;
6
7 class ElementsKit_Json_Handler {
8
9 const MIME_TYPE = 'application/json';
10 const EXT = 'json';
11
12
13 /**
14 * The plugin instance.
15 */
16 public static $instance = null;
17
18
19 /**
20 * constructor function.
21 */
22 public function __construct() {
23 add_filter('upload_mimes', array($this, 'upload_mimes'));
24 add_filter('wp_handle_upload_prefilter', array($this, 'wp_handle_upload_prefilter'));
25 add_filter('wp_check_filetype_and_ext', array($this, 'wp_check_filetype_and_ext'), 10, 4);
26 }
27
28
29 /**
30 * Adds json file format
31 */
32 public function upload_mimes($allowed_types) {
33 $allowed_types[self::EXT] = self::MIME_TYPE;
34
35 return $allowed_types;
36 }
37
38
39 public function wp_handle_upload_prefilter($file) {
40 if(self::MIME_TYPE !== $file['type']) {
41 return $file;
42 }
43
44 $ext = pathinfo($file['name'], PATHINFO_EXTENSION);
45
46 if(self::EXT !== $ext) {
47 $file['error'] = sprintf(
48 __('The uploaded %s file is not supported. Please upload a valid JSON file', 'elementskit-lite'),
49 $file['name']
50 );
51
52 return $file;
53 }
54
55 return $file;
56 }
57
58
59 public function wp_check_filetype_and_ext($data, $file, $filename, $mimes) {
60 if(!empty($data['ext']) && !empty($data['type'])) {
61 return $data;
62 }
63
64 $filetype = wp_check_filetype($filename, $mimes);
65
66 if(self::EXT === $filetype['ext']) {
67 $data['ext'] = self::EXT;
68 $data['type'] = self::MIME_TYPE;
69 }
70
71 return $data;
72 }
73
74
75 /**
76 * Instance.
77 */
78 public static function instance() {
79 if(is_null(self::$instance)) {
80 // Fire when ElementsKit_Lite instance.
81 self::$instance = new self();
82 }
83
84 return self::$instance;
85 }
86 }
87
88 // Run the instance.
89 ElementsKit_Json_Handler::instance();
90