diff --git a/wp-mat.php b/wp-mat.php index ef3585d15f313f503e94c374266ab50db4b0dc55..1c6ebb88cb8d5f1f22413a3474bb37ecf5a83849 100644 --- a/wp-mat.php +++ b/wp-mat.php @@ -3,7 +3,7 @@ * Plugin Name: wp-mat * Plugin URI: https://git.autistici.org/noblogs/wp-mat * Description: Process uploaded files through MAT - * Version: 0.0.11 + * Version: 0.1.0 * Author: Autistici/Inventati * Author URI: https://www.autistici.org/ * License: MIT @@ -15,11 +15,13 @@ if (!defined("WP_MAT_ENDPOINT")) { } // Check if the mime type is one of those we want to clean up. +// Use a blacklist, currently empty. Send everything by default +// except video. function wp_mat_is_supported_mime_type($mimetype) { - if (substr($mimetype, 0, 6) === "image/") { - return true; + if (substr($mimetype, 0, 6) === "video/") { + return false; } - return false; + return true; } // Make a POST request to the MAT service with the uploaded file and @@ -51,10 +53,7 @@ function wp_mat_issue_request($path, $mimetype, $output_path) { } function wp_mat_handle_upload_prefilter($file) { - error_log("wp-mat: called with file=".json_encode($file)); - if (isset($file['error']) && $file['error']) { - error_log("wp-mat: upload has error set to ".$file['error']); return $file; } @@ -97,7 +96,10 @@ function wp_mat_handle_upload_prefilter($file) { add_filter('wp_handle_upload_prefilter', 'wp_mat_handle_upload_prefilter'); -function wp_handle_upload_error(&$file, $message) { - error_log("wp_handle_upload_error: ".$message); - return array( "error" => $message ); +// This is generally useful for debugging. +if (!function_exists('wp_handle_upload_error')) { + function wp_handle_upload_error(&$file, $message) { + error_log("wp_handle_upload_error: ".$message); + return array( "error" => $message ); + } }