Codex

Function Reference/plugin basename

Contents

Description

Gets the basename of a plugin (extracts the name of a plugin from its filename).

Usage

 <?php plugin_basename($file); ?> 

Parameters

$file 
(string) The filename of a plugin.

Return

The basename of a plugin.

Example

If your plugin file is located at /home/www/wp-content/plugins/myplugin/myplugin.php, and you call:

 $x = plugin_basename(__FILE__); 

$x will equal "myplugin/myplugin.php".

If you would like to know the full url path to your plugin's directory, you can call:

$x = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));

$x will equal "http://[url-path-to-plugins]/[myplugin]/"


function writeCSS() {
 echo ( '<link rel=\"stylesheet\" type=\"text/css\" href=\"'. $x . 'myplugin.css\">' ); 
}
add_action('wp_head', 'writeCSS');

This page is marked as incomplete. You can help Codex by expanding it.