File: /home/globfdxw/public_html/wp-content/plugins/wpforms-pdf/src/Cleanup.php
<?php
namespace WPFormsPDF;
/**
* Cleanup class for removing PDF files during entry deletion.
*
* @since 1.3.0
*/
class Cleanup {
/**
* Initialize.
*
* @since 1.3.0
*/
public function init(): void {
$this->hooks();
}
/**
* Register hooks.
*
* @since 1.3.0
*/
private function hooks(): void {
add_action( 'wpforms_pro_tasks_actions_purge_entries_task_delete_entries', [ $this, 'delete_entry_pdfs' ], 10, 2 );
}
/**
* Delete PDF files for purged entries.
*
* @since 1.3.0
*
* @param array $entry_ids Entry IDs being deleted.
* @param int $form_id Form ID.
*/
public function delete_entry_pdfs( array $entry_ids, int $form_id ): void {
foreach ( $entry_ids as $entry_id ) {
Storage::remove( $form_id, (int) $entry_id );
}
}
}