plugin_dir_path()获取插件所在的系统路径

目录

描述

Gets the filesystem directory path (with trailing slash) for the file passed in.

It is a wrapper for trailingslashit( dirname( $file ) );.

The "plugin" part of the name is misleading - it can be used for any file, and will not return the directory of a plugin unless you call it within a file in the plugin's base directory.

plugin_dir_path() 描述

用法

<?php $path plugin_dir_path$file ); ?>

plugin_dir_path() 用法

参数

$file

(string) (必填) A full file path (e.g. __FILE__).

默认值: None

plugin_dir_path() 参数

返回值

(string

The absolute path of the directory that contains the file, with trailing slash.

plugin_dir_path() 返回值

示例

Get the directory of the current file:

Including all PHP files from a plugin sub folder and avoiding adding a unnecessary global just to determine a path that is already available everywhere just using WP core functions.

plugin_dir_path() 示例

历史

添加于 版本: 2.8

plugin_dir_path() 历史

源文件

plugin_dir_path() 函数的代码位于 wp-includes/plugin.php

plugin_dir_path() 源文件