The MU forums have moved to WordPress.org

AJAX Comments Plugin (16 posts)

  1. lunabyte
    Member
    Posted 17 years ago #

    I checked out the ajax comment plugin from Mike Smullin, recommended in another thread, and I'm having a few issues with it.

    I'd "prefer" to run it as an mu-plugin, but something is preventing it's use in that capacity.

    It works just fine sitting in the plugins directory, as a note.

    Here's where I got with this.

    First I looked through the code of the plugin. No biggie. It has an easy way of modifying the location, so I did that. Plugged it in, and it wasn't responding.

    Note, the original file path as defined in the plugin was 'wp-content/plugins/ajax-comments/', which I changed to 'wp-content/mu-plugins/'.

    OK, so I checked it in the standard plugins directory. It was fine.

    OK, so I went through and hardcoded the paths instead of using the defined vars from the top. I went 1 by 1. (This is working with the plugins directory)

    First the loading image. I stuck it in wp-includes/images/, and it was fine.

    Next, I hardcoded the path to scriptaculous (at the bottom), which was just fine as well.

    The final paths were the ones that directly reference the plugin file.

    So now, I edit those, turn off the plugin for the account I was testing with (and moved the ajax-comment directory out of plugins to another temp location), and added the modified plugin file into mu-plugins.

    It partially worked. The plugin adds a tiny script tag right after the comment form, which was there.

    Problem being, that's all it did.

    Double check, triple check the paths to the file. (check)

    Load the file directly, and see if there's a parse error. (check, with none)

    File permissions? (check, 755)

    Dir permissions? (check, 755)

    So by this point, everything "seems" translated properly, yet it still isn't working.

    It includes itself (to add some functions) as a script through a hook for wp_head, which it is included up there. So on submission of the form, it should execute one of the functions from this inclusion. It does not, and acts like js is disabled and processes through the normal comment path.

    So, has anyone got this to work as an mu-plugin vice standard plugin?

    Maybe I've overlooked something?

  2. lunabyte
    Member
    Posted 17 years ago #

    As a note, it's with a subdomain set-up. username.domain.tld

  3. suleiman
    Member
    Posted 17 years ago #

    luna, how are you using this plugin with SK2?

    From Smullin's website:

    UPDATE: Unfortunately, Spam Karma does not play well with this plugin. For those seeking an alternative, I recommend AuthImage. *crossing-fingers* I have never been spammed with it—ever.

  4. lunabyte
    Member
    Posted 17 years ago #

    Works fine for me, but I've heavily modified it to fit my needs.

    Come to think of it, I don't think I'm even using this one. Maybe it was, I dunno. I have ajax comments, and they initially came from somewhere. lol

  5. suleiman
    Member
    Posted 17 years ago #

    well double check if it does in fact work fine.

    On my own wpmu site the comment does in fact "post" appropriately, but the initial posting appears to be from someone else.

    e.g., if I fill in "Suleiman" in the name field and type in my comment, then the comment that appears via the AJAX interface will show up with another name and another comment (or even a blank comment). If you refresh the page then you see the correct name and comment data was in fact posted, but you wouldn't be able to tell from Smullin's plugin.

    It wasn't until after some digging that I realized the plugin was pulling bad comments from SK2 and displaying them in place of the actual comments.

  6. suleiman
    Member
    Posted 17 years ago #

    From the plugin author's comments page, and for anyone else who was getting flustered by this:

    1. Change line 177 of ajax-comments.php from

    wp_new_comment(array(

    to

    $new_comment_ID = wp_new_comment(array(

    2. Change line 199 of ajax-comments.php from

    $comment = $wpdb->get_row("SELECT * FROM {$wpdb->comments} WHERE comment_ID = {$wpdb->insert_id} LIMIT 1;");

    to

    $comment = $wpdb->get_row("SELECT * FROM {$wpdb->comments} WHERE comment_ID = {$new_comment_ID};");

    Works like a gem :)

  7. lunabyte
    Member
    Posted 17 years ago #

    I must have started with something else. I don't have a plugin file at all. I'd have to dig and see what I started with, but time's a little short at the moment.

  8. jshare
    Member
    Posted 17 years ago #

    Suleiman, if this means Ajax Comments works with SK2 on WPMU, congratulations! And thanks! I was using it for awhile but that was the main reason I turned it off, SK2 was too important to get in place. I'm sure that many other people will appreciate this.

  9. Ovidiu
    Member
    Posted 17 years ago #

    the original page: http://www.mikesmullin.com/2006/06/05/ajax-comments-20/ is greeting me with an 500 server error for the last 2 days, can someone mail me this plugin so I can modify it like suleiman suggested? ovizii at zice dot ro

  10. suleiman
    Member
    Posted 17 years ago #

    Ovidiu, I'll send you across my modded plugin buddy :)

  11. Ovidiu
    Member
    Posted 17 years ago #

    thx but it did not work for me.
    I found the error: prototype is loaded twice... another plugin loading it...

    any idea what the most elegant way would be to solve this?
    maybe finding the place where each of these plugins loads the prototype file and make it an "if exists", don't load? but how to check if it is already loaded?

    I am open for suggestions...

    you can check it out here: http://sibiu.zice.ro
    I checked the site with a firefox plugin, it shows me prototype is loaded twice. it even shows me who is loading it, its ajax comments and addicted to live search...

  12. Ovidiu
    Member
    Posted 17 years ago #

    can someone give me some advice how to prevent 2 plugins from loading the same file, aka prototype? I have never touched such things :-(

  13. lunabyte
    Member
    Posted 17 years ago #

    Depends on how it's set up.

    For me, all my themes use Ajax and paged comments. In the case above, if live search and ajax comments are both "forced" for use, live search would be on every page so you could just remove the call to add prototype in the second plugin.

    If it's something that can be selected, and one may or may not be selected, you can wrap the call to insert the link to prototype in the head in a function_exists check. This of course checking to see if the function that loads prototype in the "other" plugin exists. Then load it if it doesn't.

  14. Ovidiu
    Member
    Posted 17 years ago #

    thx, I tried this:

    <?php if ( function_exists('live_search_init')) : else : ?>
    <script type="text/javascript" src="<?=get_settings('siteurl').PLUGIN_AJAXCOMMENTS_PATH?>scriptaculous/prototype.js"></script>
    <?php endif; ?>
    

    inside the ajax-comments.php file. If I check the site I am testign it: http://sibiu.zice.ro/2007/03/25/coyote-party-liquid/ it shows that prototype was only loaded once. still if you comment, the comment is successfully saved but the page does not display it, aka it does not refresh...

    any more ideas? you can go ahead and spam-comment that article, I'll delete the comments in a day or two.

  15. Ovidiu
    Member
    Posted 17 years ago #

    [SOLVED]
    for my part at least.

    Sorry for bothering you, I just noticed I had replaced the non-working plugin with another one based on jquery from here:
    http://jowra.com/journal/2007/01/wordpress-plugin-jquery-ajax-comments/

    so basically it was my fault, I had two Ajax-comments plugins active,...

    [ANOTHER RELATED PROBLEM]
    I just noticed one of my bloggers has loaded prototype 3 times!!!

    1. his theme (blue-moon) loads it as it seems to be needed
    2. addicted to livesearch (plugin) loads it
    3. lightbox plugin loads it
    4. kaccordion plugin loads a prototype_light version

    so how can I generally deal with these problems?

    I mean I can't seriously go ahead and edit all of these themes/plugins and ad if function_exists statements to all of them checking for all others??? Isn't there a way to check if a certain file is loaded, instead of checking for the existence of all other functions?

    what about this idea: http://www.silpstream.com/blog/wp-scriptaculous/ thats a plugin that loads scriptaculous and sets an option that scriptaculous is installed. any plugin using scriptaculous could check if this option is set and if yes doesn't need to load its own scriptaculous files.... could't something similar be achieved/made for prototype?

    Please suggest a way to prevent things like I describe (aka prototype loading 3x on a blog).

  16. lunabyte
    Member
    Posted 17 years ago #

    Dig in, and edit.

About this Topic

  • Started 17 years ago by lunabyte
  • Latest reply from lunabyte