2014-02-28 08:27:15 +00:00
|
|
|
<?php
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
|
|
|
2021-11-15 18:45:56 +02:00
|
|
|
class AAL_Hook_Attachments extends AAL_Hook_Base {
|
2014-02-28 08:27:15 +00:00
|
|
|
|
|
|
|
protected function _add_log_attachment( $action, $attachment_id ) {
|
|
|
|
$post = get_post( $attachment_id );
|
|
|
|
|
|
|
|
aal_insert_log( array(
|
|
|
|
'action' => $action,
|
2021-11-15 18:45:56 +02:00
|
|
|
'object_type' => 'Attachments',
|
2014-02-28 08:27:15 +00:00
|
|
|
'object_subtype' => $post->post_type,
|
|
|
|
'object_id' => $attachment_id,
|
2018-03-08 13:37:03 +02:00
|
|
|
'object_name' => esc_html( get_the_title( $post->ID ) ),
|
2014-02-28 08:27:15 +00:00
|
|
|
) );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hooks_delete_attachment( $attachment_id ) {
|
|
|
|
$this->_add_log_attachment( 'deleted', $attachment_id );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hooks_edit_attachment( $attachment_id ) {
|
|
|
|
$this->_add_log_attachment( 'updated', $attachment_id );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hooks_add_attachment( $attachment_id ) {
|
2021-03-25 15:15:35 +02:00
|
|
|
$this->_add_log_attachment( 'uploaded', $attachment_id );
|
2014-02-28 08:27:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
add_action( 'add_attachment', array( &$this, 'hooks_add_attachment' ) );
|
|
|
|
add_action( 'edit_attachment', array( &$this, 'hooks_edit_attachment' ) );
|
|
|
|
add_action( 'delete_attachment', array( &$this, 'hooks_delete_attachment' ) );
|
2021-03-25 15:15:35 +02:00
|
|
|
|
2014-02-28 08:27:15 +00:00
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
2018-03-08 13:37:03 +02:00
|
|
|
}
|