From d1b2a55b44fb716a948c371dc01a3a749b27a177 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 2 Dec 2016 07:10:43 +0000 Subject: [PATCH] Plugins: Add a `current_priority()` method to `WP_Hook`. This allows plugins to determine the currently running priority of a filter. Fixes #39007. Built from https://develop.svn.wordpress.org/trunk@39430 git-svn-id: http://core.svn.wordpress.org/trunk@39370 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-hook.php | 16 ++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-hook.php b/wp-includes/class-wp-hook.php index 823b4b5e58..80b93ef1e6 100644 --- a/wp-includes/class-wp-hook.php +++ b/wp-includes/class-wp-hook.php @@ -351,6 +351,22 @@ final class WP_Hook implements Iterator, ArrayAccess { $this->nesting_level--; } + /** + * Return the current priority level of the currently running iteration of the hook. + * + * @since 4.7.0 + * @access public + * + * @return int|false If the hook is running, return the current priority level. If it isn't running, return false. + */ + public function current_priority() { + if ( false === current( $this->iterations ) ) { + return false; + } + + return current( current( $this->iterations ) ); + } + /** * Normalizes filters set up before WordPress has initialized to WP_Hook objects. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 676670b433..269b024a30 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-39428'; +$wp_version = '4.8-alpha-39430'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.