| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Description of AccessHelper |
| 5 |
* |
| 6 |
* @author Ali2Woo Team |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace AliNext_Lite;; |
| 10 |
|
| 11 |
class PageGuardHelper |
| 12 |
{ |
| 13 |
public const ROLE_ADMIN = 'administrator'; |
| 14 |
public const ROLE_SHOP_MANAGER = 'shop_manager'; |
| 15 |
|
| 16 |
public static function getAllRoles(): array |
| 17 |
{ |
| 18 |
return [ |
| 19 |
self::ROLE_ADMIN, |
| 20 |
self::ROLE_SHOP_MANAGER, |
| 21 |
]; |
| 22 |
} |
| 23 |
|
| 24 |
public static function isAdmin(): bool { |
| 25 |
return in_array(self::ROLE_ADMIN, wp_get_current_user()->roles); |
| 26 |
} |
| 27 |
|
| 28 |
public static function canAccessPage(string $slug): bool |
| 29 |
{ |
| 30 |
// Block early if user lacks plugin-level access |
| 31 |
if (!current_user_can(Capability::pluginAccess())) { |
| 32 |
return false; |
| 33 |
} |
| 34 |
|
| 35 |
if (EditionHelper::isLite()) { |
| 36 |
return true; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
} |
| 41 |
|
| 42 |
} |
| 43 |
|