<?php
namespace OxygenApp\Hooks;

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

use OxygenApp\Models\BackgroundSound;

class ActionAdminNotice implements IHook {
    static function register() {
        add_action('admin_notices', [self::class, 'onAdminNotice'], 20);
    }

    static function onAdminNotice() {
        $error_message = get_transient(BackgroundSound::POST_SAVE_TRANSIENT_KEY);
        if ($error_message) {
            echo '<div class="notice notice-error is-dismissible">';
            echo '<p>' . esc_html($error_message) . '</p>';
            echo '</div>';

            delete_transient(BackgroundSound::POST_SAVE_TRANSIENT_KEY);
        }
    }
}