give
/
vendor
/
vendor-prefixed
/
stellarwp
/
admin-notices
/
src
/
Actions
/
DisplayNoticesInAdmin.php
DisplayNoticesInAdmin.php
1 year ago
EnqueueNoticesScriptsAndStyles.php
1 year ago
NoticeShouldRender.php
1 year ago
RenderAdminNotice.php
1 year ago
DisplayNoticesInAdmin.php
39 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | |
| 6 | namespace Give\Vendors\StellarWP\AdminNotices\Actions; |
| 7 | |
| 8 | use Give\Vendors\StellarWP\AdminNotices\AdminNotice; |
| 9 | use Give\Vendors\StellarWP\AdminNotices\Traits\HasNamespace; |
| 10 | |
| 11 | /** |
| 12 | * Displays the provided notices in the admin based on the conditions set in the notice. |
| 13 | * |
| 14 | * @since 1.1.0 added namespacing |
| 15 | * @since 1.0.0 |
| 16 | */ |
| 17 | class DisplayNoticesInAdmin |
| 18 | { |
| 19 | use HasNamespace; |
| 20 | |
| 21 | /** |
| 22 | * @since 1.1.0 passed the namespace to RenderAdminNotice |
| 23 | * @since 1.0.0 |
| 24 | */ |
| 25 | public function __invoke(AdminNotice ...$notices) |
| 26 | { |
| 27 | if (empty($notices)) { |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | foreach ($notices as $notice) { |
| 32 | if ((new NoticeShouldRender($this->namespace))($notice)) { |
| 33 | echo (new RenderAdminNotice($this->namespace))($notice); |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | |
| 39 |