| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* @package Logtivity |
| 5 |
* @contact logtivity.io, [email protected] |
| 6 |
* @copyright 2024-2026 Logtivity. All rights reserved |
| 7 |
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL |
| 8 |
* |
| 9 |
* This file is part of Logtivity. |
| 10 |
* |
| 11 |
* Logtivity is free software: you can redistribute it and/or modify |
| 12 |
* it under the terms of the GNU General Public License as published by |
| 13 |
* the Free Software Foundation, either version 2 of the License, or |
| 14 |
* (at your option) any later version. |
| 15 |
* |
| 16 |
* Logtivity is distributed in the hope that it will be useful, |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
* GNU General Public License for more details. |
| 20 |
* |
| 21 |
* You should have received a copy of the GNU General Public License |
| 22 |
* along with Logtivity. If not, see <https://www.gnu.org/licenses/>. |
| 23 |
*/ |
| 24 |
|
| 25 |
class Logtivity_Download_Monitor extends Logtivity_Abstract_Logger |
| 26 |
{ |
| 27 |
/** |
| 28 |
* @inheritDoc |
| 29 |
*/ |
| 30 |
protected function registerHooks(): void |
| 31 |
{ |
| 32 |
add_action('dlm_downloading', [$this, 'itemDownloaded']); |
| 33 |
} |
| 34 |
|
| 35 |
public function itemDownloaded($download) |
| 36 |
{ |
| 37 |
Logtivity::log() |
| 38 |
->setAction('File Downloaded') |
| 39 |
->setContext($download->get_title()) |
| 40 |
->setPostType(get_post_type($download->get_id())) |
| 41 |
->setPostId($download->get_id()) |
| 42 |
->addMeta('Download Slug', $download->get_slug()) |
| 43 |
->addMeta('Download ID', $download->get_id()) |
| 44 |
->addMeta('Download Count', $download->get_download_count()) |
| 45 |
->addMeta('Is Featured', $download->is_featured()) |
| 46 |
->addMeta('Is Members Only', $download->is_members_only()) |
| 47 |
->send(); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
$Logtivity_Download_Monitor = new Logtivity_Download_Monitor; |
| 52 |
|