Skip to content

Commit

Permalink
Merge pull request #2 from drowe/patch-1
Browse files Browse the repository at this point in the history
Allow views to be overridden in a template.
  • Loading branch information
Emerson committed May 9, 2013
2 parents 98f5bdc + 487b650 commit e873127
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions framework/sanity.php
Expand Up @@ -176,8 +176,19 @@ function is_valid_save($post_id) {
* $this->render('subfolder/example);
*
*/
function render($view) {
$template_path = $this->plugin_dir.'/views/'.$view.'.php';
function render($view, $from_template = false) {
$template_path = $this->plugin_dir.'/views/'.$view.'.php';

if($from_template) {
// Look for the view in the template/child-template directories.
$theme_template_path = locate_template($view.'.php');

// If not found, fall back to the plugin directory.
if(!empty($theme_template_path)) {
$template_path = $theme_template_path;
}
}

ob_start();
include($template_path);
$output = ob_get_clean();
Expand All @@ -194,4 +205,4 @@ function sanity_nonce() {
}

}
?>
?>

0 comments on commit e873127

Please sign in to comment.