* Squash bugs, reorganize, etc. * Use `get_body_class()` to apply filters on template data * Use `PHP_INT_MAX` as priority for `template_include` filter
This commit is contained in:
@@ -34,7 +34,7 @@ add_filter('excerpt_more', function () {
|
||||
array_map(function ($type) {
|
||||
add_filter("{$type}_template_hierarchy", function ($templates) {
|
||||
return call_user_func_array('array_merge', array_map(function ($template) {
|
||||
$normalizedTemplate = str_replace('.', '/', sage('blade')->normalizeViewPath($template));
|
||||
$normalizedTemplate = preg_replace('%(\.blade)?(\.php)?$%', '', $template);
|
||||
return ["{$normalizedTemplate}.blade.php", "{$normalizedTemplate}.php"];
|
||||
}, $templates));
|
||||
});
|
||||
@@ -47,11 +47,14 @@ array_map(function ($type) {
|
||||
* Render page using Blade
|
||||
*/
|
||||
add_filter('template_include', function ($template) {
|
||||
echo template($template, apply_filters('sage/template_data', []));
|
||||
$data = array_reduce(get_body_class(), function ($data, $class) {
|
||||
return apply_filters("sage/template/{$class}/data", $data);
|
||||
}, []);
|
||||
echo template($template, $data);
|
||||
|
||||
// Return a blank file to make WordPress happy
|
||||
return get_template_directory() . '/index.php';
|
||||
}, 1000);
|
||||
}, PHP_INT_MAX);
|
||||
|
||||
/**
|
||||
* Tell WordPress how to find the compiled path of comments.blade.php
|
||||
|
||||
Reference in New Issue
Block a user