Traits
HasNotices
v1.0.0Adds WordPress admin notice helpers for info, success, warning, and error states.
Use Trait
use Meteorack\Sdk\RuntimeWp\Traits\HasNotices;How To Use It
- Use these helpers for admin-facing feedback that should appear in the standard WordPress notices area.
- Prefer semantic helpers like addSuccessNotice() and addErrorNotice() so the notice styling matches the intent without manual class names.
Works Well With
Helpers
protected function addNotice(string $message, string $type = 'info', bool $dismissible = true): voidQueues an admin notice with an explicit notice type.
protected function addSuccessNotice(string $message): voidQueues a success notice.
protected function addWarningNotice(string $message): voidQueues a warning notice.
protected function addErrorNotice(string $message): voidQueues an error notice.
Example
bootstrap.php
public function handleLicenseFailure(): void
{
$this->addErrorNotice('License validation failed. Please re-enter your key.');
$this->getSdkContext()->logger()->warn('reports.license_notice_shown', []);
}