Frontend
3 months ago
views
1 year ago
CapabilityCheck.php
3 years ago
ConditionCallbacks.php
3 years ago
ConditionalBlocksIntegration.php
3 years ago
ContentConditions.php
6 months ago
ElementorDisplayCondition.php
1 month ago
ElementorRestriction.php
3 years ago
Init.php
1 month ago
NavMenuProtection.php
3 years ago
SettingsPage.php
1 year ago
WPListTable.php
1 year ago
index.php
5 years ago
CapabilityCheck.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePress\Core\ContentProtection; |
| 4 | |
| 5 | class CapabilityCheck |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | add_filter('user_has_cap', array($this, 'user_has_cap'), 99, 3); |
| 10 | } |
| 11 | |
| 12 | public function user_has_cap($all_caps, $caps, $args) |
| 13 | { |
| 14 | if (isset($caps[0])) { |
| 15 | |
| 16 | if (false !== strpos($caps[0], 'ppress_plan_')) { |
| 17 | |
| 18 | preg_match('/ppress_plan_([0-9]+)/', $caps[0], $matches); |
| 19 | |
| 20 | $user_id = (int)$args[1]; |
| 21 | |
| 22 | if (isset($matches[1])) { |
| 23 | |
| 24 | $plan_id = (int)$matches[1]; |
| 25 | |
| 26 | if (ppress_has_active_subscription($user_id, $plan_id)) { |
| 27 | $all_caps[$caps[0]] = true; |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | return $all_caps; |
| 34 | } |
| 35 | |
| 36 | public static function get_instance() |
| 37 | { |
| 38 | static $instance = null; |
| 39 | |
| 40 | if (is_null($instance)) { |
| 41 | $instance = new self(); |
| 42 | } |
| 43 | |
| 44 | return $instance; |
| 45 | } |
| 46 | } |
| 47 |