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-user-journey/src/Admin/Form.php
<?php

namespace WPFormsUserJourney\Admin;

/**
 * Class for the form-related things in the admin area.
 *
 * @since 1.0.0
 */
class Form {

	/**
	 * Init the class.
	 *
	 * @since 1.0.0
	 */
	public function init() {

		$this->hooks();

		return $this;
	}

	/**
	 * Hooks.
	 *
	 * @since 1.0.0
	 */
	public function hooks() {

		if ( wpforms_is_admin_page( 'overview' ) ) {
			add_action( 'wpforms_delete_form', [ $this, 'delete_form_related_records' ] );
		}
	}

	/**
	 * Clean records that related to the deleted form.
	 *
	 * @since 1.0.0
	 *
	 * @param array $form_ids The collection with form IDs, which were deleted.
	 */
	public function delete_form_related_records( $form_ids ) {

		foreach ( $form_ids as $form_id ) {

			// If the user doesn't have permissions - the form wasn't deleted. So, nothing to do.
			if ( wpforms_current_user_can( 'delete_form_single', $form_id ) ) {
				wpforms_user_journey()->db->delete_by( 'form_id', $form_id );
			}
		}
	}
}