WordPress.org

Ready to get started?Download WordPress

Forums

PTM AJAX Comments
[resolved] threaded comment not getting the correct css class (depth) (26 posts)

  1. fusse
    Member
    Posted 2 years ago #

    The plugin is working almost as it should...or it probably is but something wrong with my conf. I'm using callback function which is pretty much the same as the example in the twentyten theme functions.php.

    But for some reason when replying to a comment the reply doesn't get the proper classes (depth-2 etc.) and therefore renders as it was the depth-1 comment (gets those classes). After page refresh it does render correctly as depth-2.

    If I disable the callback, then the class is set properly so my guess is that this has something to do with the callback function and how it's set up but I can't figure it out... Or could it be something else?

    http://wordpress.org/extend/plugins/ptm-ajax-comments/

  2. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

    Hi fusse, could you post the source of both comments.php & your callback function to either Pastebin or Gist and add the links here so I can have a look?

  3. fusse
    Member
    Posted 2 years ago #

  4. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

    Changed line 7 in functions.php: https://gist.github.com/2299483

  5. fusse
    Member
    Posted 2 years ago #

    Yea I had it like that before and forgot to change it back. (I tried that to see if it had any effect but it didn't work).

    So anyway, the change you made doesn't affect the outcome at all. I can't figure it out but the problem is that the reply is not getting the correct class. Don't know why though...

  6. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

    Strange, let me dig into this, maybe I'll see something.

  7. fusse
    Member
    Posted 2 years ago #

    Thanks! Like I said in the beginning, if I disable the callback from the plugin options and make it use the wordpress default list comments (also disable the callback in comments.php), it will set the correct class and the reply message will be indented but then it of course looks wrong otherwise as it has different html layout.

  8. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

    Edited: https://gist.github.com/2299483#file_functions.php

    • removed select/case/break statements
    • removed $GLOBALS['comment_depth'] = $depth;
  9. fusse
    Member
    Posted 2 years ago #

    Tried. No change.

  10. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

    Does the comment get added at the correct position?

  11. fusse
    Member
    Posted 2 years ago #

    Yes. Everything else is as it should apart from the class issue (not getting the depth-2 but depth-1). And page reload fixes this: so the data put to database is correct.

  12. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

    Found it. It's a bug in the plugin. Do not expect a fix today. :)

    (The added comment gets processed by the Walker_Comment class. Since its the only comment in the comments array, the $depth returned is always 1)

  13. fusse
    Member
    Posted 2 years ago #

    Okay nice! Thanks. I didn't take too much time to look into the plugin itself. I guess, since the official fix ain't coming soon, I will take a look myself and try to fix it.

  14. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

    Try this:

    1. get https://gist.github.com/2300355 and replace the file ptm-ajax-comments.dev.js in the plugins js directory
    2. go to the plugin options page -> Support -> Developer JS -> check = on
  15. fusse
    Member
    Posted 2 years ago #

    I managed to fix my issue with replacing the depth-1 with depth-2 in the tmpComment - kinda what you did in your example but I did it here:
    if(jQuery('#'+css_respond).parent().children('.children').length) {
    // There are replies, add comment to the end of the list
    tmpComment = data.replace( 'depth-1', 'depth-2' );

    and here:

    tmpComment = data.replace( 'depth-1', 'depth-2' );
    tmpComment = '<ul class="children">'+tmpComment+'';

    I only use depth-2 and no deeper so it works for me. Now I just need to replace/strip away the Reply link from tmpComment depth-2 comment as that doesn't apply to my site.

    I tried your fix though and noticed that it doesn't quite work still: when replying to first level comment, if there are replies that are depth-2 already, the reply gets depth-3 instead of depth-2 which it should be getting as it was a reply to the original depth-1 comment.

  16. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

    Now I just need to replace/strip away the Reply link from tmpComment depth-2 comment as that doesn't apply to my site.

    Settings -> Discussion -> Enable threaded (nested) comments X levels deep | set X to 2 and the reply links will be gone.

    Glad you found your own solution to the bug. I will work on mine and add it to the next update.

    Thanks for pointing it out! :)

  17. fusse
    Member
    Posted 2 years ago #

    I already have that setting enabled in Discussion... :)

  18. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

    Ah man, another bug as the reply link only gets added to the new comment. *sigh* :)

  19. fusse
    Member
    Posted 2 years ago #

    Anyways, this is still a stellar plugin even with them little hiccups :) Keep up the good work!

  20. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

    Thank you :)

  21. fusse
    Member
    Posted 2 years ago #

    tmpComment = tmpComment.replace( /<p class="reply">(.*?)<\/p>/, '' );
    this after the depth-1 replace. don't know how "good" this is but no errors and works and that's fine with me in this case.

  22. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

    Nice, regex was never my strength. I did it with tmpComment = tmpComment.replace( '<div class="reply">', '<div class="reply" style="display:none;">' );

    ;)

  23. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

  24. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

    Fork here https://github.com/pmichael/ptm-ajax-comments if you have more changes.

    If everything works then please mark this topic as resolved.

  25. fusse
    Member
    Posted 2 years ago #

    Now that was fast ;) I grabbed your updated version, installed and tested in my environment. Works like a charm so far.

    Job well done sir! :)

    So therefore: resolved!

  26. Peter Michael
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks a lot as well. :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic