HEX
Server: LiteSpeed
System: Linux server315.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: globfdxw (6114)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/globfdxw/www/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 );
		}
	}
}