From ede699368e65c59c60d106c20e20565e2c0fe1c6 Mon Sep 17 00:00:00 2001 From: Kim Helge Frimanslund <1223194+kimhf@users.noreply.github.com> Date: Sat, 27 Oct 2018 11:53:52 +0200 Subject: [PATCH] Bring hook run sequence in line with expected WordPress behaviour --- app/filters.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/filters.php b/app/filters.php index fde2e2c..efdf388 100644 --- a/app/filters.php +++ b/app/filters.php @@ -47,6 +47,15 @@ collect([ * Render page using Blade */ add_filter('template_include', function ($template) { + collect(['get_header', 'wp_head'])->each(function ($tag) { + ob_start(); + do_action($tag); + $c = ob_get_clean(); + remove_all_actions($tag); + add_action($tag, function () use ($c) { + echo $c; + }); + }); $data = collect(get_body_class())->reduce(function ($data, $class) use ($template) { return apply_filters("sage/template/{$class}/data", $data, $template); }, []);