<?php
/**
 * Wrapper for NinjaForms Integration
 *
 * @link https://personalizewp.com/
 * @since 3.2.0
 *
 * @package PersonalizeWP
 * @subpackage PersonalizeWP/Integrations
 */

namespace PersonalizeWP\Integrations\NinjaForms;

use PersonalizeWP\Integrations\NinjaForms\NinjaForms;

/**
 * Register the NinjaForms integation, and setup various actions/filters.
 *
 * @param \PersonalizeWP\PersonalizeWP $personalizewp Instance of plugin
 *
 * @return void
 */
function register_integration( $personalizewp ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found

	// Use WP functions to check activeness.
	require_once ABSPATH . 'wp-admin/includes/plugin.php';

	// Check for plugin.
	if ( ! is_plugin_active( 'ninja-forms/ninja-forms.php' ) ) {
		return;
	}

	add_action(
		'ninja_forms_register_actions',
		function ( $actions ) {
			$actions['personalizewp'] = NinjaForms::get_instance();
			return $actions;
		}
	);
}
add_action( 'personalizewp_register_integrations', __NAMESPACE__ . '\register_integration' );
