<?php
function is_download_monitor_attachment(int $id): bool
{
$parentPostId = wp_get_post_parent_id($id);
return is_int($parentPostId) && 'dlm_download' === get_post_type($parentPostId);
}
add_filter('as3cf_pre_upload_attachment', function (bool $pre, int $postId): bool {
if (is_download_monitor_attachment($postId)) {
$message = __('Refuse to offload Download Monitor files', 'disallow-offloading-download-monitor-files');
throw new RuntimeException($message);
}
return $pre;
}, -1000, 3);
add_filter('as3cf_upload_acl', function (string $acl, array $data, int $postId): string {
return is_download_monitor_attachment($postId) ? 'private' : $acl;
}, 10, 3);