Make WordPress Core

Changeset 10765


Ignore:
Timestamp:
03/10/2009 07:50:55 PM (16 years ago)
Author:
markjaquith
Message:

Introducing plugin_dir_path(FILE) and plugin_dir_url(FILE) ... simple API functions for determining the directory path/url of the current plugin file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/plugin.php

    r10411 r10765  
    495495    $file = preg_replace('|^' . preg_quote($plugin_dir, '|') . '/|','',$file); // get relative path from plugins dir
    496496    return $file;
     497}
     498
     499/**
     500 * Gets the filesystem directory path (with trailing slash) for the plugin __FILE__ passed in
     501 * @package WordPress
     502 * @subpackage Plugin
     503 * @since 2.8
     504 *
     505 * @param string $file The filename of the plugin (__FILE__)
     506 * @return string the filesystem path of the directory that contains the plugin
     507 */
     508function plugin_dir_path( $file ) {
     509    return trailingslashit( dirname( $file ) );
     510}
     511
     512/**
     513 * Gets the URL directory path (with trailing slash) for the plugin __FILE__ passed in
     514 * @package WordPress
     515 * @subpackage Plugin
     516 * @since 2.8
     517 *
     518 * @param string $file The filename of the plugin (__FILE__)
     519 * @return string the URL path of the directory that contains the plugin
     520 */
     521function plugin_dir_url( $file ) {
     522    return trailingslashit( plugins_url( '', $file ) );
    497523}
    498524
Note: See TracChangeset for help on using the changeset viewer.