// 1. افزودن پشتیبانی فرمت فایل STP به کتابخانه رسانه
add_filter( 'upload_mimes', 'allow_stp_mime_type' );
function allow_stp_mime_type( $mime_types ) {
$mime_types['stp'] = 'application/stp';
return $mime_types;
}
// 2. بررسی فرمت فایل آپلود شده و مجاز بودن آن
add_filter( 'wp_handle_upload_prefilter', 'check_stp_file_extension' );
function check_stp_file_extension( $file ) {
$allowed_extensions = array( 'stp' );
$file_extension = pathinfo( $file['name'], PATHINFO_EXTENSION );
if ( ! in_array( $file_extension, $allowed_extensions ) ) {
$file['error'] = 'فرمت فایل مجاز نیست. فقط فایلهای STP مجاز هستند.';
}
return $file;
}