http://codex.wordpress.org/Function_Reference/plugin_dir_path
plugins_url(), plugin_dir_url(), plugin_dir_path()
Function Reference/plugin dir path
Contents[hide] |
Description
Gets the filesystem directory path (with trailing slash) for the plugin __FILE__ passed inUsage
<?php plugin_dir_path( $file ); ?>
Parameters
- $file
- (string) (required) The filename of the plugin (__FILE__)
- Default: None
Examples
Defining a constant to include files in a plugin, with the correct path<?php
define( 'MYPLUGINNAME_PATH', plugin_dir_path(__FILE__) );
require MYPLUGINNAME_PATH . 'includes/class-metabox.php';
require MYPLUGINNAME_PATH . 'includes/class-widget.php';
?>
Return Values
- (string)
- the filesystem path of the directory that contains the plugin
Change Log
Since: 2.8Source File
plugin_dir_path() is located inwp-includes/plugin.php Related
This can be fairly reliably used to find the local path to the plugins directory by using a string manipulation to remove just the base directory of the plugin (equivalent to the non-existentplugins_dir_path()).plugins_url(), plugin_dir_url(), plugin_dir_path()