/** * Make sure that the givn role has or hasn't the provided capability * depending on existing roles. * * @since 1.7.2 * @param stdClass $role * @param array $role_info * @param string|array $existing_cap * @param string $new_cap */ private static function map_capability($role, $role_info, $existing_cap, $new_cap) { if (isset($role_info['capabilities'][$new_cap])) { // Already has new cap… if (!self::has_capability($role_info, $existing_cap)) { // But shouldn't have it! $role->remove_cap($new_cap); } } else { // Doesn't have new cap… if (self::has_capability($role_info, $existing_cap)) { // But should have it! $role->add_cap($new_cap); } } }