W3cubDocs

/WordPress

WP_Plugin_Dependencies::convert_to_slug( string $plugin_file ): string

Converts a plugin filepath to a slug.

Parameters

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

Return

string The plugin’s slug.

Source

protected static function convert_to_slug( $plugin_file ) {
	if ( 'hello.php' === $plugin_file ) {
		return 'hello-dolly';
	}
	return str_contains( $plugin_file, '/' ) ? dirname( $plugin_file ) : str_replace( '.php', '', $plugin_file );
}

Changelog

Version Description
6.5.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_plugin_dependencies/convert_to_slug