<?php

/**
 * Card Oracle Admin Notices functionality
 *
 * Handles the display and management of administrative notices within the
 * WordPress admin interface. Manages success, error, warning, and info messages
 * for the Card Oracle plugin operations.
 *
 * @package     Card_Oracle
 * @subpackage  Admin/Notices
 * @copyright   Copyright (c) 2020, Christopher Graham
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       0.16.0
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Card Oracle Admin Notices Class
 *
 * Manages the display of admin notices for plugin operations including
 * success confirmations, error messages, warnings, and informational notices.
 * Integrates with WordPress admin_notices hook for proper display.
 *
 * @since 0.16.0
 * @package Card_Oracle/Admin
 * @author  Christopher Graham <support@chillichalli.com>
 */
class CardOracleNotices {

	/**
	 * Initialize the notices system.
	 *
	 * Sets up the admin_notices hook to display notices in the WordPress admin.
	 * Called during plugin initialization to ensure notices are properly handled.
	 *
	 * @since 0.16.0
	 */
	public function __construct() {
		add_action( 'admin_notices', array( $this, 'display' ) );
	}

	/**
	 * Show relevant notices
	 *
	 * @since 0.16.0
	 *
	 * @param string $notice The name of the notice.
	 * @param string $message The text to display.
	 * @param string $type The type of the notice, error, warn, update, info.
	 */
	public function add( $notice, $message, $type ) {
		add_settings_error( 'card-oracle-notices', $notice, $message, $type );
	}

	/**
	 * Show relevant notices
	 *
	 * @since 0.16.0
	 */
	public function display() {
		settings_errors( 'card-oracle-notices' );
	}

	/**
	 * Show relevant notices
	 *
	 * @since 0.16.0
	 *
	 * @param string $notice The name of the notice.
	 * @param string $message The text to display.
	 * @param string $type The type of the notice, error, warn, update, info.
	 */
	public function add_display( $notice, $message, $type ) {
		add_settings_error( 'card-oracle-notices', $notice, $message, $type );

		settings_errors( 'card-oracle-notices' );
	}
}

// Initiate the logging system.
$GLOBALS['co_notices'] = new CardOracleNotices();
