Closed bobbingwide closed 4 years ago
Silly me. WP_Hooks
provides the current_priority
method that I need! It also means that WordPress TRAC 33886 can be marked as complete
, rather than invalid
.
Closing this now that I've written a test for it.
Since WordPress 4.7.0 filters and hooks are now stored in the global
$wp_filter
as instances of classWP_hook
. The logic used to determine the current priority when tracing filter results no longer works.Expected output
when filter results to trace contains
we trace the results of the
the_content
filter at priority 1, 8, 9 and 9999 (default when value not set) This priority should be shown in the trace record that precedes the results.Actual output
It shows
callbacks
, which is the name of the first field in the object.Proposed solution
WP_hook is implemented as a final class. The current_priority is a protected field. We can get the value of a protected field by using Reflection functions.
We need to change
bw_trace_inspect_current()
to obtain the value of the current hookscurrent_priority
field, which is an array,It would have been easier to have a method to allow this inspection or just make the field public.
The solution does not need to check the WordPress version, as it's documented that it requires WordPress 4.9