HEX
Server: Apache/2
System: Linux server1c 2.6.32-042stab145.3 #1 SMP Thu Jun 11 14:05:04 MSK 2020 x86_64
User: prospack (1025)
PHP: 8.2.23
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/prospack/public_html/wp-content/plugins/xpro-elementor-addons/widgets/lottie/json-handler.php
<?php

namespace XproElementorAddons\Widget;

defined( 'ABSPATH' ) || exit;

class Xpro_Elementor_Json_Handler {


	const MIME_TYPE = 'application/json';
	const EXT       = 'json';


	/**
	 * The plugin instance.
	 */
	public static $instance = null;


	/**
	 * constructor function.
	 */
	public function __construct() {
		add_filter( 'upload_mimes', array( $this, 'upload_mimes' ) );
		add_filter( 'wp_handle_upload_prefilter', array( $this, 'wp_handle_upload_prefilter' ) );
		add_filter( 'wp_check_filetype_and_ext', array( $this, 'wp_check_filetype_and_ext' ), 10, 4 );
	}

	/**
	 * Instance.
	 */
	public static function instance() {
		if ( is_null( self::$instance ) ) {
			// Fire when Xpro_Elementor_Lite instance.
			self::$instance = new self();
		}

		return self::$instance;
	}

	/**
	 * Adds json file format
	 */
	public function upload_mimes( $allowed_types ) {
		$allowed_types[ self::EXT ] = self::MIME_TYPE;

		return $allowed_types;
	}

	public function wp_handle_upload_prefilter( $file ) {
		if ( self::MIME_TYPE !== $file['type'] ) {
			return $file;
		}

		$ext = pathinfo( $file['name'], PATHINFO_EXTENSION );

		if ( self::EXT !== $ext ) {
			$file['error'] = sprintf(
			/* translators: %s: Name */
				__( 'The uploaded %s file is not supported. Please upload a valid JSON file', 'xpro-elementor-addons' ),
				$file['name']
			);

			return $file;
		}

		return $file;
	}

	public function wp_check_filetype_and_ext( $data, $file, $filename, $mimes ) {
		if ( ! empty( $data['ext'] ) && ! empty( $data['type'] ) ) {
			return $data;
		}

		$filetype = wp_check_filetype( $filename, $mimes );

		if ( self::EXT === $filetype['ext'] ) {
			$data['ext']  = self::EXT;
			$data['type'] = self::MIME_TYPE;
		}

		return $data;
	}
}

// Run the instance.
Xpro_Elementor_Json_Handler::instance();