X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/4feeb71a9d812a9ae371c28a3d8b442a4394ded7..607b7e02d77e7326161e8ec15639052d2040f745:/wp-includes/plugin.php diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php index 7f6217de..ca4985f1 100644 --- a/wp-includes/plugin.php +++ b/wp-includes/plugin.php @@ -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; }