Skip to content

Commit

Permalink
Fixes error with casting template name as array to string
Browse files Browse the repository at this point in the history
  • Loading branch information
jedrzejchalubek committed Apr 11, 2017
1 parent 2ad2950 commit 358c4ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Gin/Template/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public function doActions()
return;
}

// Use first template name, if template
// file is an array, but is not named.
if (is_array($this->file) && isset($this->file[0])) {
return do_action("get_template_part_{$this->file[0]}", $this->file[0], null);
}

do_action("get_template_part_{$this->file}", $this->file, null);
}

Expand Down Expand Up @@ -125,7 +131,7 @@ public function getFilename($extension = '.php')

// Use first template name, if template
// file is an array, but is not named.
if (is_array($this->file)) {
if (is_array($this->file) && isset($this->file[0])) {
return "{$this->file[0]}{$extension}";
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Gin/Template/TemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use Brain\Monkey\Functions;
use Brain\Monkey\WP\Actions;
use Tonik\Gin\Foundation\Config;
use Tonik\Gin\Foundation\Exception\FileNotFoundException;
use Tonik\Gin\Template\Template;
use Tonik\Gin\Foundation\Exception\FileNotFoundException;

class TemplateTest extends TestCase
{
Expand Down

0 comments on commit 358c4ba

Please sign in to comment.