WP_Plugin_Dependencies::get_dependency_names( string $plugin_file ): array

In this article

Gets the names of plugins required by the plugin.

Parameters

$plugin_filestringrequired
The dependent plugin’s filepath, relative to the plugins directory.

Return

array An array of dependency names.

Source

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;
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.