PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 2.0.3
Adminify – White Label, Admin Menu Editor, Login Customizer v2.0.3
4.3.2 4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 All 165 releases
adminify / Inc / Modules / ActivityLogs / Hooks / WP_Adminify_Logs_Attachments.php

WP_Adminify_Logs_Attachments.php in Adminify – White Label, Admin Menu Editor, Login Customizer 2.0.3, at Inc/Modules/ActivityLogs/Hooks/WP_Adminify_Logs_Attachments.php

49 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPAdminify\Inc\Modules\ActivityLogs\Hooks;
4
5 use WPAdminify\Inc\Modules\ActivityLogs\Inc\Hooks_Base;
6
7 // no direct access allowed
8 if (!defined('ABSPATH')) exit;
9
10 class WP_Adminify_Logs_Attachments extends Hooks_Base
11 {
12 public function __construct()
13 {
14 add_action('add_attachment', [$this, 'hooks_add_attachment']);
15 add_action('edit_attachment', [$this, 'hooks_edit_attachment']);
16 add_action('delete_attachment', [$this, 'hooks_delete_attachment']);
17
18 parent::__construct();
19 }
20
21 protected function _add_log_attachment($action, $attachment_id)
22 {
23 $post = get_post($attachment_id);
24
25 adminify_activity_logs(array(
26 'action' => $action,
27 'object_type' => 'Attachment',
28 'object_subtype' => $post->post_type,
29 'object_id' => $attachment_id,
30 'object_name' => esc_html(get_the_title($post->ID)),
31 ));
32 }
33
34 public function hooks_delete_attachment($attachment_id)
35 {
36 $this->_add_log_attachment('deleted', $attachment_id);
37 }
38
39 public function hooks_edit_attachment($attachment_id)
40 {
41 $this->_add_log_attachment('updated', $attachment_id);
42 }
43
44 public function hooks_add_attachment($attachment_id)
45 {
46 $this->_add_log_attachment('added', $attachment_id);
47 }
48 }
49