You've already forked wc-licensed-product
Dashboard widget improvements and download counter feature (v0.3.7)
- Fixed: Dashboard widget "View All Licenses" link used wrong page slug - Fixed: Download links in customer account resulted in 404 errors - Removed: Redundant "Status Breakdown" section from dashboard widget - Changed: License Types section now uses card style layout - Added: Download counter for licensed product versions - Added: Download Statistics admin dashboard widget - Updated translations (356 strings) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,9 @@ final class DownloadController
|
||||
// Add download endpoint
|
||||
add_action('init', [$this, 'addDownloadEndpoint']);
|
||||
|
||||
// Register query var for the endpoint
|
||||
add_filter('query_vars', [$this, 'addDownloadQueryVar']);
|
||||
|
||||
// Handle download requests
|
||||
add_action('template_redirect', [$this, 'handleDownloadRequest']);
|
||||
}
|
||||
@@ -47,6 +50,15 @@ final class DownloadController
|
||||
add_rewrite_endpoint('license-download', EP_ROOT | EP_PAGES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the download query var
|
||||
*/
|
||||
public function addDownloadQueryVar(array $vars): array
|
||||
{
|
||||
$vars[] = 'license-download';
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle download request
|
||||
*/
|
||||
@@ -160,8 +172,12 @@ final class DownloadController
|
||||
$downloadUrl = $version->getDownloadUrl();
|
||||
|
||||
if ($attachmentId) {
|
||||
// Increment download count before serving
|
||||
$this->versionManager->incrementDownloadCount($versionId);
|
||||
$this->serveAttachment($attachmentId, $version->getVersion());
|
||||
} elseif ($downloadUrl) {
|
||||
// Increment download count before redirect
|
||||
$this->versionManager->incrementDownloadCount($versionId);
|
||||
// Redirect to external URL
|
||||
wp_redirect($downloadUrl);
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user