WordPress函数:plugin_dir_path 获取插件文件目录的路径
WordPress函数 plugin_dir_path 专为获取插件文件目录的路径而设计。这函数和 plugin_dir_url 是一对。
函数原型:
plugin_dir_path( string $file ): string
函数源码:
function plugin_dir_path( $file ) {
return trailingslashit( dirname( $file ) );
}
使用举例:
//当前目录:/home/user/var/www/wordpress/wp-content/plugins/my-plugin/
$dir = plugin_dir_path( __DIR__ );
//$dir 的值当为: /home/user/var/www/wordpress/wp-content/plugins/
这函数用法很简单,一看例子什么都明白了。如有兴趣还可以参考:《三分钟热度教程:WordPress插件开发之插件目录下文件路径与URL》
-
WordPress函数:human_time_diff 几秒几分几小时前WordPress 自带更友好的时间显示处理函数
-
WordPress函数:wp_is_mobile 判断是否是移动设备WordPress 中如何判断是否是移动设备
-
WordPress函数:wp_die 增强版的 PHP die函数wp_die 优雅的处理异常
-
WordPress函数:get_search_form 获取搜索表单如何在 WordPress 主题中添加搜索表单
-
WordPress函数:get_category_link()通过分类ID获取分类链接get_category_link()是一个通过分类ID获取分类链接的WordPress函数。该函数位于 wp-includes/category-template.php
-
WordPress函数:get_post_field 获取文章字段直接获取文章的字段
暂无评论,抢个沙发...