From df58ca2a416ecdf5ebcf520c881bc0a7be52ec76 Mon Sep 17 00:00:00 2001 From: markjaquith Date: Tue, 10 Mar 2009 19:50:55 +0000 Subject: [PATCH] Introducing plugin_dir_path(__FILE__) and plugin_dir_url(__FILE__) ... simple API functions for determining the directory path/url of the current plugin file git-svn-id: http://svn.automattic.com/wordpress/trunk@10765 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/plugin.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php index ead0a229a..7b3ae86fb 100644 --- a/wp-includes/plugin.php +++ b/wp-includes/plugin.php @@ -496,6 +496,32 @@ function plugin_basename($file) { return $file; } +/** + * Gets the filesystem directory path (with trailing slash) for the plugin __FILE__ passed in + * @package WordPress + * @subpackage Plugin + * @since 2.8 + * + * @param string $file The filename of the plugin (__FILE__) + * @return string the filesystem path of the directory that contains the plugin + */ +function plugin_dir_path( $file ) { + return trailingslashit( dirname( $file ) ); +} + +/** + * Gets the URL directory path (with trailing slash) for the plugin __FILE__ passed in + * @package WordPress + * @subpackage Plugin + * @since 2.8 + * + * @param string $file The filename of the plugin (__FILE__) + * @return string the URL path of the directory that contains the plugin + */ +function plugin_dir_url( $file ) { + return trailingslashit( plugins_url( '', $file ) ); +} + /** * Set the activation hook for a plugin. *