PluginProbe
Metricool – Social media and site statistics / 2.1.1
Metricool – Social media and site statistics v2.1.1
2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.27 trunk
← All changes | app/Traits/HasAllowlistControl.php +27 -0 2.0.1 → 2.1.1 View file →
@@ -1,0 +1,27 @@
1 +<?php
2 +
3 +declare(strict_types=1);
4 +
5 +namespace Metricool\Traits;
6 +
7 +trait HasAllowlistControl
8 +{
9 + /**
10 + * Check if the current user has the capability to manage the plugin.
11 + * This is the case when:
12 + * - The user is logged in and has the 'metricool_manage' capability
13 + * - This is a REST API request and the user is logged in
14 + * - This is a WPCLI request
15 + *
16 + * @internal This replaces Helper::user_can_manage()
17 + */
18 + public function userCanManage(): bool
19 + {
20 + // During activation, we need to allow access
21 + if (get_option('metricool_activation_flag')) {
22 + return true;
23 + }
24 +
25 + return current_user_can('metricool_manage');
26 + }
27 +}