WP_Plugin_Dependencies::get_dependency_names()public staticWP 6.5.0

Gets the names of plugins required by the plugin.

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

Хуков нет.

Возвращает

Массив. An array of dependency names.

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

$result = WP_Plugin_Dependencies::get_dependency_names( $plugin_file );
$plugin_file(строка) (обязательный)
The dependent plugin's filepath, relative to the plugins directory.

Список изменений

С версии 6.5.0 Введена.

Код WP_Plugin_Dependencies::get_dependency_names() WP 6.7.2

public static function get_dependency_names( $plugin_file ) {
	$dependency_api_data = self::get_dependency_api_data();
	$dependencies        = self::get_dependencies( $plugin_file );
	$plugins             = self::get_plugins();

	$dependency_names = array();
	foreach ( $dependencies as $dependency ) {
		// Use the name if it's available, otherwise fall back to the slug.
		if ( isset( $dependency_api_data[ $dependency ]['name'] ) ) {
			$name = $dependency_api_data[ $dependency ]['name'];
		} else {
			$dependency_filepath = self::get_dependency_filepath( $dependency );
			if ( false !== $dependency_filepath ) {
				$name = $plugins[ $dependency_filepath ]['Name'];
			} else {
				$name = $dependency;
			}
		}

		$dependency_names[ $dependency ] = $name;
	}

	return $dependency_names;
}