PluginProbe
Elementor Website Builder – more than just a page builder / 3.5.4
Elementor Website Builder – more than just a page builder v3.5.4
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / core / files / assets / files-upload-handler.php

files-upload-handler.php in Elementor Website Builder – more than just a page builder 3.5.4, at core/files/assets/files-upload-handler.php

135 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Core\Files\Assets;
4
5 use Elementor\Core\Files\File_Types\Svg;
6 use Elementor\Core\Files\Uploads_Manager;
7 use Elementor\Plugin;
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12
13 /**
14 * Files Upload Handler
15 *
16 * Deprecated, use Elementor\Core\Files\Uploads_Manager instead.
17 *
18 * @deprecated 3.5.0
19 */
20 abstract class Files_Upload_Handler {
21 const OPTION_KEY = 'elementor_unfiltered_files_upload';
22
23 abstract public function get_mime_type();
24
25 abstract public function get_file_type();
26
27 /**
28 * is_elementor_media_upload
29 * @deprecated 3.5.0
30 * @return bool
31 */
32 private function is_elementor_media_upload() {
33 return isset( $_POST['uploadTypeCaller'] ) && 'elementor-wp-media-upload' === $_POST['uploadTypeCaller']; // phpcs:ignore
34 }
35
36 /**
37 * @return bool
38 */
39 final public static function is_enabled() {
40 $enabled = ! ! get_option( self::OPTION_KEY ) && Svg::file_sanitizer_can_run();
41
42 /**
43 * @deprecated 3.0.0 Use `elementor/files/allow_unfiltered_upload` filter instead.
44 */
45 $enabled = apply_filters( 'elementor/files/svg/enabled', $enabled );
46
47 /**
48 * Allow Unfiltered Files Upload.
49 *
50 * Determines whether to enable unfiltered file uploads.
51 *
52 * @since 3.0.0
53 *
54 * @param bool $enabled Whether upload is enabled or not.
55 */
56 $enabled = apply_filters( 'elementor/files/allow_unfiltered_upload', $enabled );
57
58 return $enabled;
59 }
60
61 final public function support_unfiltered_files_upload( $existing_mimes ) {
62 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Elementor\Plugin::$instance->uploads_manager->support_unfiltered_file_uploads()' );
63
64 return Plugin::$instance->uploads_manager->support_unfiltered_elementor_file_uploads( $existing_mimes );
65 }
66
67 /**
68 * handle_upload_prefilter
69 *
70 * @deprcated 3.5.0
71 *
72 * @param $file
73 *
74 * @return mixed
75 */
76 public function handle_upload_prefilter( $file ) {
77 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Elementor\Plugin::$instance->uploads_manager->handle_elementor_wp_media_upload()' );
78
79 return Plugin::$instance->uploads_manager->handle_elementor_wp_media_upload( $file );
80 }
81
82 /**
83 * is_file_should_handled
84 *
85 * @deprcated 3.5.0
86 *
87 * @param $file
88 *
89 * @return bool
90 */
91 protected function is_file_should_handled( $file ) {
92 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0' );
93
94 $ext = pathinfo( $file['name'], PATHINFO_EXTENSION );
95
96 return $this->is_elementor_media_upload() && $this->get_file_type() === $ext;
97 }
98
99 /**
100 * file_sanitizer_can_run
101 *
102 * @deprcated 3.5.0
103 *
104 * @return bool
105 */
106 public static function file_sanitizer_can_run() {
107 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Elementor\Core\Files\File_Types\Svg::file_sanitizer_can_run()' );
108
109 return Svg::file_sanitizer_can_run();
110 }
111
112 /**
113 * Check filetype and ext
114 *
115 * A workaround for upload validation which relies on a PHP extension (fileinfo)
116 * with inconsistent reporting behaviour.
117 * ref: https://core.trac.wordpress.org/ticket/39550
118 * ref: https://core.trac.wordpress.org/ticket/40175
119 *
120 * @deprcated 3.5.0
121 *
122 * @param $data
123 * @param $file
124 * @param $filename
125 * @param $mimes
126 *
127 * @return mixed
128 */
129 public function check_filetype_and_ext( $data, $file, $filename, $mimes ) {
130 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Elementor\Plugin::$instance->uploads_manager->check_filetype_and_ext()' );
131
132 Plugin::$instance->uploads_manager->check_filetype_and_ext( $data, $file, $filename, $mimes );
133 }
134 }
135