Edit File by line
/home/zeestwma/ajeebong.../wp-conte.../plugins/image-op.../modules/backups/componen...
File: handle-backups-removing.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace ImageOptimization\Modules\Backups\Components;
[2] Fix | Delete
[3] Fix | Delete
use ImageOptimization\Classes\Async_Operation\Async_Operation_Hook;
[4] Fix | Delete
use ImageOptimization\Classes\Image\Image_Backup;
[5] Fix | Delete
use WP_Post;
[6] Fix | Delete
[7] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[8] Fix | Delete
exit; // Exit if accessed directly.
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
class Handle_Backups_Removing {
[12] Fix | Delete
public function remove_backups_on_attachment_removing( int $attachment_id, WP_Post $attachment_post ) {
[13] Fix | Delete
if ( ! wp_attachment_is_image( $attachment_post ) ) {
[14] Fix | Delete
return;
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
Image_Backup::remove( $attachment_id );
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
/** @async */
[21] Fix | Delete
public function remove_many_backups( array $attachment_ids ) {
[22] Fix | Delete
Image_Backup::remove_many( $attachment_ids );
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
public function __construct() {
[26] Fix | Delete
add_action( 'delete_attachment', [ $this, 'remove_backups_on_attachment_removing' ], 10, 2 );
[27] Fix | Delete
add_action( Async_Operation_Hook::REMOVE_MANY_BACKUPS, [ $this, 'remove_many_backups' ] );
[28] Fix | Delete
}
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function