コード例 #1
0
/**
 * Checks if a specific capability has been given to at least one role. If it has, return true.
 * Else, return false.
 *
 * @since  0.1.0
 * @access public
 * @param  string  $cap
 * @return bool
 */
function members_check_for_cap($cap = '')
{
    // Without a capability, we have nothing to check for.  Just return false.
    if (!$cap) {
        return false;
    }
    // Check if the cap is assigned to any role.
    return in_array($cap, members_get_role_capabilities());
}
コード例 #2
0
/**
 * Checks if a specific capability has been given to at least one role. If it has, return true. Else, return false.
 *
 * @since 0.1.0
 * @uses members_get_role_capabilities() Checks for capability in array of role caps.
 * @param string $cap Name of the capability to check for.
 * @return true|false bool Whether the capability has been given to a role.
 */
function members_check_for_cap($cap = '')
{
    /* Without a capability, we have nothing to check for.  Just return false. */
    if (!$cap) {
        return false;
    }
    /* Gets capabilities that are currently mapped to a role. */
    $caps = members_get_role_capabilities();
    /* If the capability has been given to at least one role, return true. */
    if (in_array($cap, $caps)) {
        return true;
    }
    /* If no role has been given the capability, return false. */
    return false;
}