Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add password support to pages #118

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion page.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@

$timber_post = new Timber\Post();
$context['post'] = $timber_post;
Timber::render( array( 'page-' . $timber_post->post_name . '.twig', 'page.twig' ), $context );
if (post_password_required($timber_post->ID)) {
Timber::render("single-password.twig", $context);
} else {
Timber::render( array( 'page-' . $timber_post->post_name . '.twig', 'page.twig' ), $context );
}
Comment on lines +28 to +32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (post_password_required($timber_post->ID)) {
Timber::render("single-password.twig", $context);
} else {
Timber::render( array( 'page-' . $timber_post->post_name . '.twig', 'page.twig' ), $context );
}
Timber::render(
post_password_required( $timber_post->ID )
? 'single-password.twig'
: array( 'page-' . $timber_post->post_name . '.twig', 'page.twig' ),
$context
);

How about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally, I prefer the more verbose conditional vs. the ternary one... but maybe that's just me. 🤷‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the big sack in a small sack, you like the small sack in the big one :)