<?php
/**
 * Flush Rewrite Rules Upgrade.
 *
 * Flushes rewrite rules to register custom endpoints added in 1.2.0.
 *
 * @package Awesomemotive\Rewardswp\Database\Upgrades
 * @since 1.2.0
 */

namespace Awesomemotive\Rewardswp\Database\Upgrades;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use Awesomemotive\Rewardswp\Abstracts\AbstractDatabaseUpgrade;

/**
 * Class FlushRewriteRulesUpgrade
 *
 * @since 1.2.0
 */
class FlushRewriteRulesUpgrade extends AbstractDatabaseUpgrade {

	/**
	 * The version this upgrade targets.
	 *
	 * @since 1.2.0
	 * @var string
	 */
	protected string $version = '1.2.0';

	/**
	 * Run the upgrade.
	 *
	 * Sets a transient to flush rewrite rules on the next init hook,
	 * after rewrite rules have been registered by controllers.
	 *
	 * @since 1.2.0
	 * @return void
	 */
	public function up(): void {
		// Set transient - flush will happen after controllers register their rules.
		set_transient( 'rewardswp_flush_rewrite_rules', true, 60 );
	}
}

