Skip to content

Instantly share code, notes, and snippets.

@patrickposner
Created February 5, 2020 20:21
Show Gist options
  • Select an option

  • Save patrickposner/659519b816c9848cb65293d19e77832b to your computer and use it in GitHub Desktop.

Select an option

Save patrickposner/659519b816c9848cb65293d19e77832b to your computer and use it in GitHub Desktop.
Passster scroll down with conditional function
<?php
/* add additional content to passster */
add_filter( 'passster_content', 'passster_scroller_element', 10, 1 );
function passster_scroller_element( $content ) {
$content .= '<span id="passster-scroll"></span>';
return $content;
}
/* add a auto scroller when content successfully unlocked */
add_action( 'wp_footer', 'passster_scroll' );
function passster_scroll() {
if ( true === passster\PS_Conditional::is_password_valid( 'password' ) ): ?>
<script>
jQuery(document).ready(function( $ ) {
$('html, body').animate({
scrollTop: $('#passster-scroll').offset().top
}, 'slow');
});
</script>
<?php endif; ?>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment