Advertisement
studioart

show-hide-comments

May 17th, 2023 (edited)
762
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. function agwp_footerarea()
  2. {
  3. ?>
  4. <script type="text/javascript">
  5. jQuery(document).ready(function( $ ) {
  6. var commentsDiv = $('#comments');
  7. if (commentsDiv.length) {
  8. $(commentsDiv).hide();
  9. $('<button/>').attr('class', 'toggle-comments').attr('href', '#').html('Kommentare anzeigen <span class="icon_comment"></span>').insertBefore(commentsDiv);
  10. $('.toggle-comments').on('click', function(e) {
  11. e.preventDefault();
  12. $(commentsDiv).toggle('slow', function() {
  13. var anchor = $('.toggle-comments');
  14. var anchorText = anchor.html() == 'Kommentare anzeiten <span class="icon_comment"></span>' ? 'Kommentare verbergen <span class="icon_comment"></span>' : 'Kommentare anzeigen <span class="icon_comment"></span>';
  15. $(anchor).html(anchorText);
  16. });
  17. });
  18. }
  19. });
  20. </script>
  21. <?php
  22. }
  23. add_action('wp_footer', 'agwp_footerarea', 100);
Advertisement
Comments
  • LaFacturacion
    1 year
    # text 0.22 KB | 0 0
    1. I wanted to send you a quick message to convey my deep appreciation for introducing me to Pastebin. It has revolutionized the way I handle information and collaborate with others. Thank you for this amazing recommendation!
  • # text 0.07 KB | 0 0
    1. Can you give me an easy-to-understand guide on how to disable comments?!
Add Comment
Please, Sign In to add comment
Advertisement