WithAdminAccess.php
24 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Framework\Permissions\Traits; |
| 4 | |
| 5 | /** |
| 6 | * Trait for checking if the current user is an administrator. |
| 7 | * |
| 8 | * Provides a reusable method to check for admin access via manage_options capability. |
| 9 | * |
| 10 | * @since 4.14.0 |
| 11 | */ |
| 12 | trait WithAdminAccess |
| 13 | { |
| 14 | /** |
| 15 | * Check if the current user is an administrator (has manage_options capability). |
| 16 | * |
| 17 | * @since 4.14.0 |
| 18 | */ |
| 19 | protected function isAdmin(): bool |
| 20 | { |
| 21 | return current_user_can('manage_options'); |
| 22 | } |
| 23 | } |
| 24 |