plugin_basename()
Gets the basename of a plugin.
This method extracts the name of a plugin from its filename.
1 time — 0.000039 sec (very fast) | 50000 times — 0.63 sec (very fast)
No Hooks.
Return
String
. The name of a plugin.
Usage
plugin_basename( $file );
- $file(string) (required)
- The filename of plugin.
Examples
#1 Demo: get plugin basic name - folder_name/main_file.php
Suppose the plugin file is in this path: /home/www/wp-content/plugins/my-plugin/my-plugin.php
then by calling plugin_basename we get the following:
$plug_basename = plugin_basename( __FILE__ ); // my-plugin/my-plugin.php
Note if plugin consist of one PHP file and lies directly in plugins folder.
For a plugin that consist of just a PHP file (e.g. wp-content/plugin.php
) and for a must-use plugin (e.g. wp-content/mu-plugins/plugin.php
), plugin_basename( __FILE__ ) returns plugin.php
.
Notes
- Global. Array. $wp_plugin_paths
Changelog
Since 1.5.0 | Introduced. |