plugin_basename [ WordPress Function ]
plugin_basename ( $file )
| Access: |
|
| Parameters: |
|
| Uses: |
|
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: wp_basename, get_plugin_page_hookname, plugins_api, is_plugin_page, is_plugin_inactive
Gets the basename of a plugin.
This method extracts the name of a plugin from its filename.
Source
<?php
function plugin_basename($file) {
$file = str_replace('\\','/',$file); // sanitize for Win32 installs
$file = preg_replace('|/+|','/', $file); // remove any duplicate slash
$plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
$plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash
$mu_plugin_dir = str_replace('\\','/',WPMU_PLUGIN_DIR); // sanitize for Win32 installs
$mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash
$file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
$file = trim($file, '/');
return $file;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Function Reference/plugin basename « WordPress Codex
Description. Gets the basename of a plugin (extracts the name of a plugin from its filename). Usage. <?php plugin_basename($file); ?> Parameters. $file: (string) ...
codex.wordpress.org - plugin development - PHP Fatal error when using plugin_basename ...
I am in the process of writing my first plugin and my call to the plugin_basename( __FILE__) function results in a: PHP Fatal error: Call to undefined function ...
wordpress.stackexchange.com - plugin_basename | hakre on wordpress
Jun 27, 2010 ... Plugins in wordpress are to be identified by their so called “plugin basename”. That is basically the filename of the plugins PHP-file if it is ...
hakre.wordpress.com - Plugin_basename | WP Code Snippets
May 28, 2011 ... Recently, I was working on a plugin that needed to extract the first and last names of the site admin on which the plugin was activated.
wpcodesnippets.info