使用带有Bedrock / Sage9的Brain / Cortex路由器

时间:2016-07-28 17:54:31

标签: wordpress routing roots-sage

我很难让Cortex路由器与Sage9 WordPress主题配合使用。

由于template_include过滤器,模板继承似乎已被破坏。 Cortex删除了所有不允许Sage使用它的模板包装的template_include过滤器。

包含Cortex模板

https://github.com/Brain-WP/Cortex/blob/refactoring-fastroute/src/Cortex/Router/ResultHandler.php#L139-L143

add_filter('template_include', function () use ($template) {
    remove_all_filters('template_include');
    return $template;
}, -1);

Sage 9模板包含

https://github.com/roots/sage/blob/sage-9/src/filters.php#L48-L53

add_filter('template_include', function ($main) {
    if (!is_string($main) && !(is_object($main) && method_exists($main, '__toString'))) {
        return $main;
    }
    return ((new Template(new Wrapper($main)))->layout());
}, 109);

1 个答案:

答案 0 :(得分:0)

信用与优惠感谢Giuseppe Mazzapica

https://github.com/Brain-WP/Cortex/issues/15