<?php
/**
 * Plugin activation handler.
 *
 * @package EventimUSEventListings
 */

defined( 'ABSPATH' ) || exit;

/**
 * Initialize plugin on activation.
 *
 * @return void
 */
function evusel_activate_plugin() {
	$plugin_dir = plugin_dir_path( __FILE__ );

	if ( ! function_exists( 'evusel_init_post_type' ) ) {
		if ( file_exists( $plugin_dir . 'evusel-event-post-type.php' ) ) {
			require_once $plugin_dir . 'evusel-event-post-type.php';
		} else {
			return;
		}
	}

	if ( ! isset( $GLOBALS['evuselConfig'] ) ) {
		if ( file_exists( $plugin_dir . 'EvuselConfig.php' ) ) {
			$GLOBALS['evuselConfig'] = require_once $plugin_dir . 'EvuselConfig.php';
		} else {
			return;
		}
	}

	if ( function_exists( 'evusel_init_post_type' ) ) {
		evusel_init_post_type();
	}

    //phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules
	if ( function_exists( 'flush_rewrite_rules' ) ) {
		flush_rewrite_rules();
	}
}
