Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Permissions
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 1
 rest_is_authorized_admin
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
6
 is_authorized_admin
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2namespace NewfoldLabs\WP\Module\Migration\Helpers;
3
4/**
5 * Permissions and Authorization constants and utilities.
6 */
7final class Permissions {
8
9    /**
10     * WordPress Admin capability string
11     */
12    const ADMIN = 'manage_options';
13
14    /**
15     * Confirm REST API caller has ADMIN user capabilities.
16     *
17     * @return boolean
18     */
19    public static function rest_is_authorized_admin() {
20        return is_user_logged_in() && current_user_can( self::ADMIN );
21    }
22
23    /**
24     * Confirm logged-in user is in wp-admin and has ADMIN user capabilities.
25     *
26     * @return boolean
27     */
28    public static function is_authorized_admin() {
29        return is_admin() && self::rest_is_authorized_admin();
30    }
31}