]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/plugin.php
Wordpress 2.8
[autoinstalls/wordpress.git] / wp-includes / plugin.php
index b00ed08a1c321248a1ed525c8cc291807ef5c84d..0588bc9ac7a9f2ae62f02ff6986f3f5aa4a35aa4 100644 (file)
@@ -492,10 +492,38 @@ function plugin_basename($file) {
        $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
        $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
        $plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash
-       $file = preg_replace('|^' . preg_quote($plugin_dir, '|') . '/|','',$file); // get relative path from plugins dir
+       $mu_plugin_dir = str_replace('\\','/',WPMU_PLUGIN_DIR); // sanitize for Win32 installs
+       $mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash
+       $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
        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.
  *
@@ -512,8 +540,6 @@ function plugin_basename($file) {
  * @subpackage Plugin
  * @since 2.0
  *
- * @access private
- *
  * @param string $file The filename of the plugin including the path.
  * @param callback $function the function hooked to the 'activate_PLUGIN' action.
  */
@@ -539,8 +565,6 @@ function register_activation_hook($file, $function) {
  * @subpackage Plugin
  * @since 2.0
  *
- * @access private
- *
  * @param string $file The filename of the plugin including the path.
  * @param callback $function the function hooked to the 'activate_PLUGIN' action.
  */
@@ -641,13 +665,14 @@ function _wp_call_all_hook($args) {
  *
  * @global array $wp_filter Storage for all of the filters and actions
  * @param string $tag Used in counting how many hooks were applied
- * @param string|array $function Used for creating unique id
+ * @param callback $function Used for creating unique id
  * @param int|bool $priority Used in counting how many hooks were applied.  If === false and $function is an object reference, we return the unique id only if it already has one, false otherwise.
  * @param string $type filter or action
- * @return string Unique ID for usage as array key
+ * @return string|bool Unique ID for usage as array key or false if $priority === false and $function is an object reference, and it does not already have a uniqe id.
  */
 function _wp_filter_build_unique_id($tag, $function, $priority) {
        global $wp_filter;
+       static $filter_id_count = 0;
 
        // If function then just skip all of the tests and not overwrite the following.
        if ( is_string($function) )
@@ -658,10 +683,8 @@ function _wp_filter_build_unique_id($tag, $function, $priority) {
                if ( !isset($function[0]->wp_filter_id) ) {
                        if ( false === $priority )
                                return false;
-                       $count = isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : 0;
-                       $function[0]->wp_filter_id = $count;
-                       $obj_idx .= $count;
-                       unset($count);
+                       $obj_idx .= isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : 0;
+                       $function[0]->wp_filter_id = $filter_id_count++;
                } else
                        $obj_idx .= $function[0]->wp_filter_id;
                return $obj_idx;