Merge pull request #2123 from kimhf/hook-run-sequence
Hook run sequence fix
This commit is contained in:
@@ -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);
|
||||
$output = ob_get_clean();
|
||||
remove_all_actions($tag);
|
||||
add_action($tag, function () use ($output) {
|
||||
echo $output;
|
||||
});
|
||||
});
|
||||
$data = collect(get_body_class())->reduce(function ($data, $class) use ($template) {
|
||||
return apply_filters("sage/template/{$class}/data", $data, $template);
|
||||
}, []);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user