Skip to content

Commit

Permalink
Add template function
Browse files Browse the repository at this point in the history
  • Loading branch information
nbejansen committed Mar 31, 2022
1 parent 8209f17 commit e276ae3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion framework/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public function is_theme(): bool
{
$themes_dir = dirname(get_template_directory());

return strpos($this->base_path, $themes_dir) === true;
return strpos($this->base_path, $themes_dir) !== false;
}

/**
Expand Down Expand Up @@ -378,4 +378,22 @@ public function filter(string $hook, $value)
{
return apply_filters($this->namespace($hook), $value);
}

/**
* Get the contents of a template.
*/
public function template(string $template, string $name = null, array $args = array()): string
{
if ($this->is_theme()) {
ob_start();
get_template_part($template, $name, array_merge(['app' => $this], $args));
$template = ob_get_contents();
ob_end_clean();

return $template;
} else {
#toDo
return '';
}
}
}

0 comments on commit e276ae3

Please sign in to comment.