Skip to content

Commit

Permalink
Add filter to allow changing the password protect template
Browse files Browse the repository at this point in the history
  • Loading branch information
joelambert committed Mar 20, 2024
1 parent ffd67d8 commit 807da4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Http/Middleware/PasswordProtected.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ protected function handlePasswordProtected(): ?ResponseInterface
$context = Timber::context();
$context['post'] = new Post();

$html = Timber::compile('single-password.twig', $context);
$html = Timber::compile(
apply_filters('lumberjack/password_protect_template', 'single-password.twig'),
$context
);

if (!$html) {
return null;
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Http/Middleware/PasswordProtectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Mockery;
use Timber\Timber;
use Brain\Monkey\Functions;
use Laminas\Diactoros\Response\HtmlResponse;
use Brain\Monkey\Filters;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down Expand Up @@ -110,5 +110,6 @@ public function it_renders_the_password_template_when_needed()
$middleware = new PasswordProtected;

$this->assertSame('testing123', $middleware->process($request, $handler)->getBody()->getContents());
$this->assertTrue(Filters\applied('lumberjack/password_protect_template') > 0);
}
}

0 comments on commit 807da4b

Please sign in to comment.