WPSEO_Abstract_Role_Manager::filter_existing_capabilties()protectedYoast 1.0

Filters out capabilities that are already set for the role.

This makes sure we don't override configurations that have been previously set.

Метод класса: WPSEO_Abstract_Role_Manager{}

Хуков нет.

Возвращает

Массив. Capabilties that can be safely set.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->filter_existing_capabilties( $role, $capabilities );
$role(строка) (обязательный)
The role to check against.
$capabilities(массив) (обязательный)
The capabilities that should be set.

Код WPSEO_Abstract_Role_Manager::filter_existing_capabilties() Yoast 24.0

protected function filter_existing_capabilties( $role, array $capabilities ) {
	if ( $capabilities === [] ) {
		return $capabilities;
	}

	$wp_role = get_role( $role );
	if ( ! $wp_role ) {
		return $capabilities;
	}

	foreach ( $capabilities as $capability => $grant ) {
		if ( $this->capability_exists( $wp_role, $capability ) ) {
			unset( $capabilities[ $capability ] );
		}
	}

	return $capabilities;
}