# 404-solution/trunk/includes/php/wordpress/WPNotices.php

404 Solution, version trunk. 77 lines.

- Page: https://pluginprobe.com/plugins/404-solution/trunk/code/includes/php/wordpress/WPNotices.php
- Raw: https://pluginprobe.com/plugins/404-solution/trunk/raw/includes/php/wordpress/WPNotices.php
- Modified: 2026-06-23T05:55:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/404-solution/trunk/code/includes/php/wordpress/WPNotices.php#L10-L20`.

```php
<?php


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

class ABJ_404_Solution_WPNotices {
    
    /** @var array<ABJ_404_Solution_WPNotice> */
    private static $adminNotices = array();

    /**
     * Test seam: clear the accumulated admin-notice queue without private-field
     * reflection. Resets to the empty-array default (M105 singleton-reset seam).
     *
     * @return void
     */
    public static function resetForTests(): void {
        self::$adminNotices = array();
    }

    /** Display a message with the specified importance level.
     * @param string $noticeLevel see ABJ_404_Solution_WPNotice for notice levels.
     * @param string $message
     */
    /**
     * @param string $noticeLevel
     * @param string $message
     * @return void
     */
    public static function registerAdminMessage(string $noticeLevel, string $message): void {
        $notice = new ABJ_404_Solution_WPNotice($noticeLevel, $message);
        
        self::registerAdminNotice($notice);
    }

    /** Display a message with the specified importance level.
     * @param ABJ_404_Solution_WPNotice $adminNotice
     */
    /**
     * @param ABJ_404_Solution_WPNotice $adminNotice
     * @return void
     */
    public static function registerAdminNotice(ABJ_404_Solution_WPNotice $adminNotice): void {
        self::$adminNotices[] = $adminNotice;
        
        self::$adminNotices = array_unique(self::$adminNotices, SORT_REGULAR);
    }

    /**
     * @return string the messages to display.
     */
    static function echoAdminNotices() {
    	$f = abj_service('functions');

    	$allHTML = '';
    	if (!abj_service('admin_access_policy')->isPluginAdmin()) {
            return '';
        }

        foreach (self::$adminNotices as $oneNotice) {
            $html = ABJ_404_Solution_FileSystemService::readFileContents(ABJ404_PATH . "/includes/html/notice.html");
            $html = $f->str_replace('{class}', 'notice is-dismissable is-dismissible ' . $oneNotice->getType(), $html);
            $msg = $oneNotice->getMessage();
            $html = $f->str_replace('{message}', esc_html(is_string($msg) ? $msg : (is_scalar($msg) ? (string)$msg : '')), $html);
            
            $allHTML .= $html;
        }
        
        echo $allHTML;
        
        return $allHTML;
    }

}

```
