| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\Components; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
class Components_Access_Controller { |
| 10 |
const TIER_CORE = 'core'; |
| 11 |
const TIER_EXPIRED = 'expired'; |
| 12 |
const TIER_PRO = 'pro'; |
| 13 |
|
| 14 |
public static function get_access_tier(): string { |
| 15 |
if ( ! class_exists( '\ElementorPro\License\API' ) ) { |
| 16 |
return self::TIER_CORE; |
| 17 |
} |
| 18 |
|
| 19 |
if ( \ElementorPro\License\API::is_license_active() ) { |
| 20 |
return self::TIER_PRO; |
| 21 |
} |
| 22 |
|
| 23 |
if ( \ElementorPro\License\API::is_license_expired() ) { |
| 24 |
return self::TIER_EXPIRED; |
| 25 |
} |
| 26 |
|
| 27 |
return self::TIER_CORE; |
| 28 |
} |
| 29 |
|
| 30 |
public static function is_pro_tier(): bool { |
| 31 |
return self::TIER_PRO === self::get_access_tier(); |
| 32 |
} |
| 33 |
|
| 34 |
public static function is_expired_or_pro_tier(): bool { |
| 35 |
$tier = self::get_access_tier(); |
| 36 |
|
| 37 |
return self::TIER_EXPIRED === $tier || self::TIER_PRO === $tier; |
| 38 |
} |
| 39 |
|
| 40 |
public static function can_create(): bool { |
| 41 |
return self::is_pro_tier(); |
| 42 |
} |
| 43 |
|
| 44 |
public static function can_delete(): bool { |
| 45 |
return self::is_pro_tier(); |
| 46 |
} |
| 47 |
|
| 48 |
public static function can_rename(): bool { |
| 49 |
return self::is_pro_tier(); |
| 50 |
} |
| 51 |
|
| 52 |
public static function can_publish(): bool { |
| 53 |
return self::is_expired_or_pro_tier(); |
| 54 |
} |
| 55 |
|
| 56 |
public static function can_add_to_page(): bool { |
| 57 |
return self::is_pro_tier(); |
| 58 |
} |
| 59 |
|
| 60 |
public static function can_edit(): bool { |
| 61 |
return self::is_expired_or_pro_tier(); |
| 62 |
} |
| 63 |
|
| 64 |
public static function can_lock(): bool { |
| 65 |
return self::is_expired_or_pro_tier(); |
| 66 |
} |
| 67 |
} |
| 68 |
|