Skip to content

Commit

Permalink
Fixing optional layout functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyworrell committed Aug 17, 2016
1 parent 804e56c commit 28711e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
22 changes: 13 additions & 9 deletions src/Template/Layout.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,23 @@ public function __construct($themePath)
{
$this->themePath = $themePath;

add_filter('template_include', function ($template) {
$this->template = $template;
add_action('after_setup_theme', function () {
if (apply_filters('fire/use-layout', true)) {
add_filter('template_include', function ($template) {
$this->template = $template;

$name = str_replace($this->themePath, '', $template);
$name = str_replace($this->themePath, '', $template);

$layouts = ['layout.php'];
$layouts = ['layout.php'];

if (isset($this->layouts[$name])) {
array_unshift($layouts, $this->layouts[$name]);
}
if (isset($this->layouts[$name])) {
array_unshift($layouts, $this->layouts[$name]);
}

return locate_template($layouts);
}, 1000);
return locate_template($layouts);
}, 1000);
}
});
}

/**
Expand Down
8 changes: 2 additions & 6 deletions src/Template/services.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@
return new FileTemplateFinder($fire['filesystem'], [$fire['path.fire'].'templates']);
});

$fire->instance('template.layout', new Layout($fire['path.theme']));

$fire->singleton('template', function ($fire) {
return new Template($fire['template.finder']);
});
});

add_action('fire/ignite', function ($fire) {
if (apply_filters('fire/use-layout', true)) {
$fire->instance('template.layout', new Layout($fire['path.theme']));
}
});

0 comments on commit 28711e5

Please sign in to comment.