From 8089e7041783bbbf44cbfb06e60504f7b767de56 Mon Sep 17 00:00:00 2001 From: tfrommen Date: Tue, 11 Jul 2017 13:50:48 +0200 Subject: [PATCH] Make menu cache lookup run quite early, props @Biont. --- index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 3b56b0e..225bed8 100644 --- a/index.php +++ b/index.php @@ -36,7 +36,8 @@ function bootstrap() { $cache = new MenuCache(); - add_filter( 'pre_wp_nav_menu', [ $cache, 'get_menu' ], 10, 2 ); + // Cache lookup should happen quite early as potential other code hooked here will somehow conflict with it anyway. + add_filter( 'pre_wp_nav_menu', [ $cache, 'get_menu' ], -1, 2 ); // Unfortunately, there is no appropriate action, so we have to (mis)use a filter here. Almost as late as possible. add_filter( 'wp_nav_menu', [ $cache, 'cache_menu' ], PHP_INT_MAX - 1, 2 );