<?php
/**
 * NotFound admin warning helpers.
 *
 * @package SEOvaultSEO\NotFound
 */

namespace SEOvaultSEO\NotFound;

use SEOvaultSEO\Core\Options;

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

/**
 * Supplies warning state and copy for fallback settings.
 */
class Warnings {

	/**
	 * Initialize warning hooks if needed in a later phase.
	 */
	public static function init() {
	}

	/**
	 * Determine whether the permanent fallback soft-404 warning applies.
	 *
	 * Null arguments use the currently persisted fallback settings.
	 *
	 * @param mixed $mode   Fallback mode, or null to read the option.
	 * @param mixed $status Redirect status, or null to read the option.
	 * @return bool
	 */
	public static function should_show_soft404_warning( $mode = null, $status = null ) {
		if ( null === $mode ) {
			$mode = Options::get_notfound_fallback_mode();
		}

		if ( null === $status ) {
			$status = Options::get_notfound_fallback_status();
		}

		$mode   = Sanitizer::sanitize_fallback_mode( $mode );
		$status = Sanitizer::sanitize_fallback_status( $status );

		return 301 === $status && in_array( $mode, array( 'home', 'custom' ), true );
	}

	/**
	 * Get plain-text copy for the permanent fallback soft-404 warning.
	 *
	 * Consumers must escape the translated string for their output context.
	 *
	 * @return string
	 */
	public static function get_soft404_warning_message() {
		return __( 'A permanent 301 fallback sends every unmatched 404 to another page. Search engines may treat unrelated destinations as soft 404s. Use 302 or 307 unless the destination permanently replaces the missing URL.', 'seovault-ai' );
	}
}
