PluginProbe
Patchstack – WordPress & Plugins Security / 2.2.10
Patchstack – WordPress & Plugins Security v2.2.10
2.3.7 trunk 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.17 2.1.18 2.1.19 2.1.2 2.1.20 2.1.21 2.1.22 2.1.23 2.1.24 2.1.25 2.1.3 2.1.4 2.1.5 2.1.6 All 49 releases
← All changes | includes/events/attachment.php +72 -72 trunk2.2.10 View file →
@@ -1,72 +1,72 @@
1 -<?php
2 -
3 -// Do not allow the file to be called directly.
4 -if ( ! defined( 'ABSPATH' ) ) {
5 - exit;
6 -}
7 -
8 -/**
9 - * This class is used to log any attachment related event.
10 - */
11 -class P_Event_Attachment extends P_Event_Log {
12 -
13 - /**
14 - * Hook into the actions so we can log it.
15 - *
16 - * @return void
17 - */
18 - public function __construct() {
19 - add_action( 'add_attachment', [ &$this, 'addAttachment' ] );
20 - add_action( 'edit_attachment', [ &$this, 'editAttachment' ] );
21 - add_action( 'delete_attachment', [ &$this, 'deleteAttachment' ] );
22 - }
23 -
24 - /**
25 - * Log the action regarding the attachment.
26 - *
27 - * @param string $action
28 - * @param integer $attachment_id
29 - * @return void
30 - */
31 - protected function _addLogAttachment( $action, $attachment_id ) {
32 - $attachment = get_post( $attachment_id );
33 - $this->insert(
34 - [
35 - 'action' => $action,
36 - 'object' => 'attachment',
37 - 'object_id' => $attachment_id,
38 - 'object_name' => esc_html( get_the_title( $attachment->ID ) ),
39 - ]
40 - );
41 - }
42 -
43 - /**
44 - * When an attachment is deleted.
45 - *
46 - * @param integer $attachment_id
47 - * @return void
48 - */
49 - public function deleteAttachment( $attachment_id ) {
50 - $this->_addLogAttachment( 'deleted', $attachment_id );
51 - }
52 -
53 - /**
54 - * When an attachment is modified.
55 - *
56 - * @param integer $attachment_id
57 - * @return void
58 - */
59 - public function editAttachment( $attachment_id ) {
60 - $this->_addLogAttachment( 'updated', $attachment_id );
61 - }
62 -
63 - /**
64 - * When an attachment is added.
65 - *
66 - * @param integer $attachment_id
67 - * @return void
68 - */
69 - public function addAttachment( $attachment_id ) {
70 - $this->_addLogAttachment( 'added', $attachment_id );
71 - }
72 -}
1 +<?php
2 +
3 +// Do not allow the file to be called directly.
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +
8 +/**
9 + * This class is used to log any attachment related event.
10 + */
11 +class P_Event_Attachment extends P_Event_Log {
12 +
13 + /**
14 + * Hook into the actions so we can log it.
15 + *
16 + * @return void
17 + */
18 + public function __construct() {
19 + add_action( 'add_attachment', [ &$this, 'addAttachment' ] );
20 + add_action( 'edit_attachment', [ &$this, 'editAttachment' ] );
21 + add_action( 'delete_attachment', [ &$this, 'deleteAttachment' ] );
22 + }
23 +
24 + /**
25 + * Log the action regarding the attachment.
26 + *
27 + * @param string $action
28 + * @param integer $attachment_id
29 + * @return void
30 + */
31 + protected function _addLogAttachment( $action, $attachment_id ) {
32 + $attachment = get_post( $attachment_id );
33 + $this->insert(
34 + [
35 + 'action' => $action,
36 + 'object' => 'attachment',
37 + 'object_id' => $attachment_id,
38 + 'object_name' => esc_html( get_the_title( $attachment->ID ) ),
39 + ]
40 + );
41 + }
42 +
43 + /**
44 + * When an attachment is deleted.
45 + *
46 + * @param integer $attachment_id
47 + * @return void
48 + */
49 + public function deleteAttachment( $attachment_id ) {
50 + $this->_addLogAttachment( 'deleted', $attachment_id );
51 + }
52 +
53 + /**
54 + * When an attachment is modified.
55 + *
56 + * @param integer $attachment_id
57 + * @return void
58 + */
59 + public function editAttachment( $attachment_id ) {
60 + $this->_addLogAttachment( 'updated', $attachment_id );
61 + }
62 +
63 + /**
64 + * When an attachment is added.
65 + *
66 + * @param integer $attachment_id
67 + * @return void
68 + */
69 + public function addAttachment( $attachment_id ) {
70 + $this->_addLogAttachment( 'added', $attachment_id );
71 + }
72 +}