plugin_basename()
plugin_basename( string $file ) 获取插件的基名称。Gets the basen…
plugin_basename( string $file )
获取插件的基名称。
Gets the basename of a plugin.
获取插件的基名称。
Gets the basename of a plugin.
目录锚点:#说明#参数#返回#源码#笔记
说明(Description)
此方法从插件的文件名中提取插件的名称。
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $file | (string) | 必需 | 插件的文件名。 |
返回(Return)
(string)插件的名称。
源码(Source)
/**
* Gets the basename of a plugin.
*
* This method extracts the name of a plugin from its filename.
*
* @since 1.5.0
*
* @global array $wp_plugin_paths
*
* @param string $file The filename of plugin.
* @return string The name of a plugin.
*/
function plugin_basename( $file ) {
global $wp_plugin_paths;
foreach ( $wp_plugin_paths as $dir => $realdir ) {
if ( strpos( $file, $realdir ) === 0 ) {
$file = $dir . substr( $file, strlen( $realdir ) );
}
}
$file = wp_normalize_path( $file );
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
$mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
$file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
$file = trim($file, '/');
return $file;
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 1.5.0 | wp-includes/plugin.php:679 | 17 | 1 function |
笔记(Notes)
如果您的插件文件位于/home/www/wp content/plugins/wpdocs plugin/wpdocs-plugin.php,然后你打电话给:
如果需要访问awesome插件中的目录,例如类目录,可以通过以下方式访问:
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
还没有任何评论,赶紧来占个楼吧!