Last active
August 29, 2015 14:04
-
-
Save cfxd/2b2b8be1d4d57f7f59b6 to your computer and use it in GitHub Desktop.
Roots theme password protected post form function. Use the Bootstrap free markup with the Bootstrap LESS or use the Bootstrap markup version as standalone.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $post; | |
$label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID); | |
?> | |
<form action="<?php echo esc_url(site_url('wp-login.php?action=postpass', 'login_post')); ?>" class="post-password-form form-inline" method="post"> | |
<p><?php _e('This content is password protected. To view it please enter your password below:', 'roots'); ?></p> | |
<p><label for="<?php echo $label; ?>" class="sr-only"><?php _e('Password:', 'roots'); ?></label></p> | |
<div class="input-group"> | |
<input name="post_password" id="<?php echo $label; ?>" type="password" placeholder="<?php _e('Enter password', 'roots'); ?>" class="form-control" /> | |
<span class="input-group-btn"> | |
<button type="submit" class="post-password-submit btn btn-default"><?php _e('Submit', 'roots'); ?></button> | |
</span> | |
</div> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $post; | |
$label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID); | |
?> | |
<form action="<?php echo esc_url(site_url('wp-login.php?action=postpass', 'login_post')); ?>" class="post-password-form" method="post"> | |
<p><?php _e('This content is password protected. To view it please enter your password below:', 'roots'); ?></p> | |
<p><label for="<?php echo $label; ?>"><?php _e('Password:', 'roots'); ?></label></p> | |
<div> | |
<input name="post_password" id="<?php echo $label; ?>" type="password" placeholder="<?php _e('Enter password', 'roots'); ?>" /> | |
<span> | |
<button type="submit" class="post-password-submit"><?php _e('Submit', 'roots'); ?></button> | |
</span> | |
</div> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function roots_get_the_password_form($output) { | |
$output = ''; | |
locate_template('/templates/passwordform.php', true, false); | |
return $output; | |
} | |
add_filter('the_password_form', 'roots_get_the_password_form'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
article { | |
.post-password-form { | |
> p > label { | |
&:extend(.sr-only); | |
} | |
> div { | |
&:extend(.input-group all); | |
@media (min-width: @screen-sm-min) { | |
display: inline-table; | |
vertical-align: middle; | |
} | |
> span { | |
&:extend(.input-group-btn all); | |
@media (min-width: @screen-sm-min) { | |
width: auto; | |
} | |
} | |
} | |
input[type=password] { | |
&:extend(.form-control all, .input-group .form-control all); | |
@media (min-width: @screen-sm-min) { | |
width: 100%; | |
} | |
} | |
.post-password-submit { | |
&:extend(.btn all, .btn-default all, .input-group-btn:last-child > .btn, .input-group-btn > .btn all); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment