PluginProbe
Metricool – Social media and site statistics / trunk
Metricool – Social media and site statistics vtrunk
2.1.0 2.0.2 2.0.1 2.0.0 1.27 trunk
metricool / app / Traits / HasAllowlistControl.php

HasAllowlistControl.php in Metricool – Social media and site statistics trunk, at app/Traits/HasAllowlistControl.php

28 lines 696 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }
28