コード例 #1
0
ファイル: vip-compat.php プロジェクト: Shelob9/eight-day-week
/**
 * Get a list of capabilities for a role.
 *
 * @param string $role Role name
 *
 * @return array Array of caps for the role
 */
function get_role_caps($role)
{
    if (function_exists('wpcom_vip_get_role_caps')) {
        $caps = wpcom_vip_get_role_caps($role);
    } else {
        $caps = array();
        $role_obj = get_role($role);
        if ($role_obj && isset($role_obj->capabilities)) {
            $caps = $role_obj->capabilities;
        }
    }
    return $caps;
}
コード例 #2
0
/**
 * Duplicate an existing role and modify some caps
 *
 * Usage: wpcom_vip_duplicate_role( 'administrator', 'station-administrator', 'Station Administrator', array( 'manage_categories' => false ) );
 *
 * @param string $from_role Role name
 * @param string $to_role_slug Role name
 * @param string $to_role_name Display name for the role
 * @param array $modified_caps Key/value array of capabilities for the role
 */
function wpcom_vip_duplicate_role($from_role, $to_role_slug, $to_role_name, $modified_caps)
{
    $caps = array_merge(wpcom_vip_get_role_caps($from_role), $modified_caps);
    wpcom_vip_add_role($to_role_slug, $to_role_name, $caps);
}