| 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 |
* |
| 30 |
* @deprecated 3.5.0 |
| 31 |
* |
| 32 |
* @return bool |
| 33 |
*/ |
| 34 |
private function is_elementor_media_upload() { |
| 35 |
Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Elementor\Plugin::$instance->uploads_manager->are_unfiltered_uploads_enabled()' ); |
| 36 |
|
| 37 |
return Plugin::$instance->uploads_manager->is_elementor_media_upload(); |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Is Enabled |
| 42 |
* |
| 43 |
* @deprecated 3.5.0 |
| 44 |
* |
| 45 |
* @return bool |
| 46 |
*/ |
| 47 |
final public static function is_enabled() { |
| 48 |
Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Elementor\Plugin::$instance->uploads_manager->are_unfiltered_uploads_enabled()' ); |
| 49 |
|
| 50 |
return Plugin::$instance->uploads_manager->are_unfiltered_uploads_enabled(); |
| 51 |
} |
| 52 |
|
| 53 |
final public function support_unfiltered_files_upload( $existing_mimes ) { |
| 54 |
Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Elementor\Plugin::$instance->uploads_manager->support_unfiltered_file_uploads()' ); |
| 55 |
|
| 56 |
return Plugin::$instance->uploads_manager->support_unfiltered_elementor_file_uploads( $existing_mimes ); |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* handle_upload_prefilter |
| 61 |
* |
| 62 |
* @deprecated 3.5.0 |
| 63 |
* |
| 64 |
* @param $file |
| 65 |
* |
| 66 |
* @return mixed |
| 67 |
*/ |
| 68 |
public function handle_upload_prefilter( $file ) { |
| 69 |
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()' ); |
| 70 |
|
| 71 |
return Plugin::$instance->uploads_manager->handle_elementor_wp_media_upload( $file ); |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* is_file_should_handled |
| 76 |
* |
| 77 |
* @deprecated 3.5.0 |
| 78 |
* |
| 79 |
* @param $file |
| 80 |
* |
| 81 |
* @return bool |
| 82 |
*/ |
| 83 |
protected function is_file_should_handled( $file ) { |
| 84 |
Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0' ); |
| 85 |
|
| 86 |
$ext = pathinfo( $file['name'], PATHINFO_EXTENSION ); |
| 87 |
|
| 88 |
return $this->is_elementor_media_upload() && $this->get_file_type() === $ext; |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* file_sanitizer_can_run |
| 93 |
* |
| 94 |
* @deprecated 3.5.0 |
| 95 |
* |
| 96 |
* @return bool |
| 97 |
*/ |
| 98 |
public static function file_sanitizer_can_run() { |
| 99 |
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()' ); |
| 100 |
|
| 101 |
return Svg::file_sanitizer_can_run(); |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Check filetype and ext |
| 106 |
* |
| 107 |
* A workaround for upload validation which relies on a PHP extension (fileinfo) |
| 108 |
* with inconsistent reporting behaviour. |
| 109 |
* ref: https://core.trac.wordpress.org/ticket/39550 |
| 110 |
* ref: https://core.trac.wordpress.org/ticket/40175 |
| 111 |
* |
| 112 |
* @deprecated 3.5.0 |
| 113 |
* |
| 114 |
* @param $data |
| 115 |
* @param $file |
| 116 |
* @param $filename |
| 117 |
* @param $mimes |
| 118 |
* |
| 119 |
* @return mixed |
| 120 |
*/ |
| 121 |
public function check_filetype_and_ext( $data, $file, $filename, $mimes ) { |
| 122 |
Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Elementor\Plugin::$instance->uploads_manager->check_filetype_and_ext()' ); |
| 123 |
|
| 124 |
Plugin::$instance->uploads_manager->check_filetype_and_ext( $data, $file, $filename, $mimes ); |
| 125 |
} |
| 126 |
} |
| 127 |
|