Created
October 12, 2020 16:16
-
-
Save KaineLabs/ed512eaaa2283ce4dc785600d7690c56 to your computer and use it in GitHub Desktop.
Show / Hide Comments
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 | |
/** | |
* 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