From 7fd70d6fc860caed7b5d5d118519d739e6b436d2 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 1/3] 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 fde2e2c6..efdf3888 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); }, []); From c488744119aa47a81030a708722a8ddbcd82134e Mon Sep 17 00:00:00 2001 From: Kim Helge Frimanslund <1223194+kimhf@users.noreply.github.com> Date: Sat, 27 Oct 2018 11:54:30 +0200 Subject: [PATCH 2/3] Remove no longer needed script enqueue fix --- app/helpers.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/helpers.php b/app/helpers.php index f2ab4a93..2a6c284a 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -52,10 +52,6 @@ function config($key = null, $default = null) */ function template($file, $data = []) { - if (!is_admin() && remove_action('wp_head', 'wp_enqueue_scripts', 1)) { - wp_enqueue_scripts(); - } - return sage('blade')->render($file, $data); } From 70647fb28424c8cf51cb5a826cb94e4a997d6b35 Mon Sep 17 00:00:00 2001 From: Kim Helge Frimanslund <1223194+kimhf@users.noreply.github.com> Date: Sun, 28 Oct 2018 23:37:54 +0100 Subject: [PATCH 3/3] More descriptive variable name --- app/filters.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/filters.php b/app/filters.php index efdf3888..9eccb85d 100644 --- a/app/filters.php +++ b/app/filters.php @@ -50,10 +50,10 @@ add_filter('template_include', function ($template) { collect(['get_header', 'wp_head'])->each(function ($tag) { ob_start(); do_action($tag); - $c = ob_get_clean(); + $output = ob_get_clean(); remove_all_actions($tag); - add_action($tag, function () use ($c) { - echo $c; + add_action($tag, function () use ($output) { + echo $output; }); }); $data = collect(get_body_class())->reduce(function ($data, $class) use ($template) {