]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/plugin.php
Wordpress 4.6
[autoinstalls/wordpress.git] / wp-includes / plugin.php
index 7f6217dedf5e880c057ff493deacc1554493d0d5..ca4985f1f030840bde3786f62c602228a6d6ad62 100644 (file)
@@ -8,7 +8,7 @@
  * To hook methods, you'll need to pass an array one of two ways.
  *
  * Any of the syntaxes explained in the PHP documentation for the
- * {@link http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback 'callback'}
+ * {@link https://secure.php.net/manual/en/language.pseudo-types.php#language.types.callback 'callback'}
  * type are valid.
  *
  * Also see the {@link https://codex.wordpress.org/Plugin_API Plugin API} for
@@ -465,8 +465,7 @@ function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1)
  * possible to create new action hooks by simply calling this function,
  * specifying the name of the new hook using the `$tag` parameter.
  *
- * You can pass extra arguments to the hooks, much like you can with
- * {@see apply_filters()}.
+ * You can pass extra arguments to the hooks, much like you can with apply_filters().
  *
  * @since 1.2.0
  *
@@ -656,6 +655,60 @@ function remove_all_actions($tag, $priority = false) {
        return remove_all_filters($tag, $priority);
 }
 
+/**
+ * Fires functions attached to a deprecated filter hook.
+ *
+ * When a filter hook is deprecated, the apply_filters() call is replaced with
+ * apply_filters_deprecated(), which triggers a deprecation notice and then fires
+ * the original filter hook.
+ *
+ * @since 4.6.0
+ *
+ * @see _deprecated_hook()
+ *
+ * @param string $tag         The name of the filter hook.
+ * @param array  $args        Array of additional function arguments to be passed to apply_filters().
+ * @param string $version     The version of WordPress that deprecated the hook.
+ * @param string $replacement Optional. The hook that should have been used. Default false.
+ * @param string $message     Optional. A message regarding the change. Default null.
+ */
+function apply_filters_deprecated( $tag, $args, $version, $replacement = false, $message = null ) {
+       if ( ! has_filter( $tag ) ) {
+               return $args[0];
+       }
+
+       _deprecated_hook( $tag, $version, $replacement, $message );
+
+       return apply_filters_ref_array( $tag, $args );
+}
+
+/**
+ * Fires functions attached to a deprecated action hook.
+ *
+ * When an action hook is deprecated, the do_action() call is replaced with
+ * do_action_deprecated(), which triggers a deprecation notice and then fires
+ * the original hook.
+ *
+ * @since 4.6.0
+ *
+ * @see _deprecated_hook()
+ *
+ * @param string $tag         The name of the action hook.
+ * @param array  $args        Array of additional function arguments to be passed to do_action().
+ * @param string $version     The version of WordPress that deprecated the hook.
+ * @param string $replacement Optional. The hook that should have been used.
+ * @param string $message     Optional. A message regarding the change.
+ */
+function do_action_deprecated( $tag, $args, $version, $replacement = false, $message = null ) {
+       if ( ! has_action( $tag ) ) {
+               return;
+       }
+
+       _deprecated_hook( $tag, $version, $replacement, $message );
+
+       do_action_ref_array( $tag, $args );
+}
+
 //
 // Functions for handling plugins.
 //
@@ -675,13 +728,16 @@ function remove_all_actions($tag, $priority = false) {
 function plugin_basename( $file ) {
        global $wp_plugin_paths;
 
+       // $wp_plugin_paths contains normalized paths.
+       $file = wp_normalize_path( $file );
+
+       arsort( $wp_plugin_paths );
        foreach ( $wp_plugin_paths as $dir => $realdir ) {
                if ( strpos( $file, $realdir ) === 0 ) {
                        $file = $dir . substr( $file, strlen( $realdir ) );
                }
        }
 
-       $file = wp_normalize_path( $file );
        $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
        $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
 
@@ -697,7 +753,7 @@ function plugin_basename( $file ) {
  *
  * @since 3.9.0
  *
- * @see plugin_basename()
+ * @see wp_normalize_path()
  *
  * @global array $wp_plugin_paths
  *
@@ -829,7 +885,7 @@ function register_deactivation_hook($file, $function) {
  */
 function register_uninstall_hook( $file, $callback ) {
        if ( is_array( $callback ) && is_object( $callback[0] ) ) {
-               _doing_it_wrong( __FUNCTION__, __( 'Only a static class method or function can be used in an uninstall hook.' ), '3.1' );
+               _doing_it_wrong( __FUNCTION__, __( 'Only a static class method or function can be used in an uninstall hook.' ), '3.1.0' );
                return;
        }