Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Created October 12, 2020 16:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/ed512eaaa2283ce4dc785600d7690c56 to your computer and use it in GitHub Desktop.
Save KaineLabs/ed512eaaa2283ce4dc785600d7690c56 to your computer and use it in GitHub Desktop.
Show / Hide Comments
<?php
/**
* Show / Hide Comments
*/
function add_comment_hide_show() {
?>
<style>
.single-group .activity-comments ul{display: none;}
</style>
<script type="text/javascript">
jQuery(function($) {
setInterval(function() {
$('.activity-meta').each(function() {
if( !$(this).find('.show-comments').length ){
var html = '<a href="#" class="button bp-primary-action show-comments">Show/Hide Comments</a>';
$(this).find('.button.acomment-reply').after(html);
}
});
}, 500);
$('body').on('click', '.show-comments', function(e) {
e.preventDefault();
var obj = $(this).closest('.activity-content').next('.activity-comments').find('ul');
obj.slideToggle();
return false;
});
});
</script>
<?php
}
add_action( 'wp_footer', 'add_comment_hide_show' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment