Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| Permissions | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
6 | |
100.00% |
1 / 1 |
| is_admin | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| is_editor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| is_authorized_admin | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace NewfoldLabs\WP\Module\EditorChat; |
| 3 | |
| 4 | /** |
| 5 | * Permissions and Authorization constants and utilities. |
| 6 | */ |
| 7 | final class Permissions { |
| 8 | |
| 9 | /** |
| 10 | * WordPress Admin capabilities. |
| 11 | */ |
| 12 | const ADMIN = 'manage_options'; |
| 13 | |
| 14 | /** |
| 15 | * WordPress Editor capabilities. |
| 16 | */ |
| 17 | const EDITOR = 'edit_pages'; |
| 18 | |
| 19 | /** |
| 20 | * Confirm user is logged in and has admin capabilities. |
| 21 | * |
| 22 | * @return boolean |
| 23 | */ |
| 24 | public static function is_admin() { |
| 25 | return \is_user_logged_in() && \current_user_can( self::ADMIN ); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Confirm user is logged in and has editor user capabilities. |
| 30 | * |
| 31 | * @return boolean |
| 32 | */ |
| 33 | public static function is_editor() { |
| 34 | return \is_user_logged_in() && \current_user_can( self::EDITOR ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Confirm user is logged in and has admin user capabilities. |
| 39 | * |
| 40 | * @return boolean |
| 41 | */ |
| 42 | public static function is_authorized_admin() { |
| 43 | return \is_user_logged_in() && \current_user_can( self::ADMIN ); |
| 44 | } |
| 45 | } |