Codex

Function Reference/plugin dir path

Contents

Description

Gets the filesystem directory path (with trailing slash) for the plugin __FILE__ passed in

Usage

<?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.8

Source File

plugin_dir_path() is located in wp-includes/plugin.php

Related

plugins_url(), plugin_dir_url(), plugin_dir_path()