Codex tools: Log in / create account
Contents |
Gets the basename of a plugin (extracts the name of a plugin from its filename).
<?php plugin_basename($file); ?>
The basename of a plugin.
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');