Код: Выделить всё
class Media {
/* The class constructor runs on every upload, also when using REST API – and it runs before wp-includes/functions.php is called */
public function __construct() {
add_filter( 'upload_mimes', array( $this, 'extend_mimetypes' ) );
}
/* This function executes when uploading via the Media Library, but not using REST API */
public function extend_mimetypes($mimes) {
/* adding extra mimetypes */
return $mimes;
}
}
(function () {
global $my_media_handle;
if ( ! isset( $my_media_handle ) ) {
$my_media_handle = new Media();
}
return $my_media_handle;
})();
Подробнее здесь: https://stackoverflow.com/questions/795 ... pi-request
Мобильная версия