AJAX Comment Preview
DOWNLOAD
Get the plugin from the Ajax Comment Preview page in the WordPress.org plugins directory.
COMPATIBILITY
The newest version of this plugin (version 2.1) is compatible with WordPress 2.6 and higher only. Users of WordPress 2.0.x should use the older version 1.0.1 (which is unsupported and probably broken).
INSTALLATION
For more information, see the Ajax Comment Preview FAQ in the WordPress.org plugins directory.
To use this plugin, all files from the zip file you download must be in your wp-content/plugins/
directory. If you choose to place them in a subdirectory, all files must be in the same directory.
Activate the plugin from your WordPress site’s Plugins admin page.
Edit the plugin’s options from your Options -> AJAX Comment Preview admin page in order to specify the formatting of the preview. This will depend on your particular theme. The default format works for WordPress’ default Kubrick theme.
Note: You may need to tweak your theme’s CSS to get the preview to look exactly like a normal comment.
Testing
I get a number of comments on this post testing the system. A little odd, since it seems to me people should be testing the preview functionality (which is new) not the comment posting functionality (which is the same old WordPress standard stuff). Anyway, that’s cool. Go ahead. But please do me a favor; don’t just thow up some lame “testing” comment. Try sending over a poem or maybe something from the Farmer’s Almanac. Tell me your favorite book/artist/music. Don’t suck; try to be creative.
The History
My original post.
2.1
- Fixes an JavaScript issue in Internet Explorer reported by Eric
2.0
- Full gravatar/avatar support
- Moved to jQuery
- WordPress 2.7 support
- Should have fixed any character endcoding issues
- Should now work on pages served as XML
1.2.1:
- Fully internationalized dates
1.2:
- Fixed some JS errors (Mark Jaquith)
- %email_hash% available for gravatars
- Readme file with configuration instructions
- Fix double offset in dates (Mark Jaquith)
Great plugin, thanks.
One suggestion: make the comment_form() text configurable.
Other than that, great!
Hey, I’ve had no success. Do I need to add the tag to the top with the .js ext ..or maybe the .php extension.
what exactly do I need to do with my theme template to get this rollin.
Thanks.
I’m afraid I don’t understand your question. I can offer the hints below but do not know if they apply to your situation. Can you be more clear?
Both files should be renamed such that their extensions are
.php
; the.txt
extension they currently have is just so they can be downloaded easily.You shouldn’t have to do anything special with your theme. I looked at your site’s HTML output and this plugin’s defaults should all work (though you’ll need to change the template code in this plugin’s options page to get the preview to look like one of your site’s actual comments).
The only thing required of your theme is that the line:
<?php do_action('comment_form', $post->ID); ?>
Should appear right before the comment form’s closing tag (
</form>
). But all themes should have this already. See the documentation for theme develepment.Yes, I have done all of this. When I activate the plugin, the “preview” button shows up on the comment form.
The problem lies in two areas. The “click the preview button to see a preview of your comment” doesn’t show. the second prob is if you go to the html output source of the page, it doesn’t show the dynamic js script line that should be added to the head tag area.
check it out. thanks.
Do you have
<?php wp_head(); ?>
in your theme’s header? (Again, see the link I gave in my previous comment.)
ahh…thank you. ok I’ll fix the styling later..but the wp_head function was not called. Thanks for that. :)
How bout this:
Richard P. Feynman
“Dear Mrs. Chown, Ignore your son’s attempts to teach you physics. Physics isn’t the most important thing. Love is. Best wishes, Richard Feynman.”
“Physics is to math what sex is to masturbation.”
“Physics is like sex: sure, it may give some practical results, but that’s not why we do it.”
“Mathematics is not real, but it feels real. Where is this place?”
“The same equations have the same solutions.” (Thus when you have solved a mathematical problem, you can re-use the solution in another physical situation. Feynman was skilled in transforming a problem into one that he could solve.)
“When you are solving a problem, don’t worry. Now, after you have solved the problem, then that’s the time to worry.”
“The wonderful thing about science is that it’s alive.”
“All fundamental processes are reversible.”
“What does it mean, to understand? … I don’t know.”
“What I cannot create, I do not understand.” (Taken from his chalkboard after his death.)
“Know how to solve every problem that has ever been solved.” (Taken from his chalkboard after his death.)
“But I don’t have to know an answer. I don’t feel frightened by not knowing things, by being lost in the mysterious universe without having any purpose—which is the way it really is, as far as I can tell, possibly. It doesn’t frighten me.”
“To those who do not know mathematics it is difficult to get across a real feeling as to the beauty, the deepest beauty, of nature … If you want to learn about nature, to appreciate nature, it is necessary to understand the language that she speaks in.”
“I cannot define the real problem, therefore I suspect there’s no real problem, but I’m not sure there’s no real problem.” (about Quantum Mechanics)
“I’d hate to die twice. It’s so boring”
“For a successful technology, reality must take precedence over public relations, for Nature cannot be fooled.”
Here is my poem:
“Clever remarks were no good,
Elizabeth realized. A sparrow was a sparrow,
and would never be a proper friend,
nor make up for the legions
of her childhood who’d abandoned her,
and left her to drift in this half-haze,
this country holiday without end.”
This is refreshing we don’t want this
Anonymous Tester,
It should refresh when you actually submit the comment. This is an AJAX comment previewer, not an AJAX submitter.
Just installed this plugin and I’m loving it. Great job!
Some features I’d like to be implemented (sorted by importance):
– Internationalization of %date% tag output. Should be quite easy to do;
– %gravatar% or at least %email% tag, so one could tweak the plugin to make it generate gravatars in previews;
– Allow HTML code in preview div default text.
Ok, I’m probably doing something stupid, but need your help. I couldn’t get this to work on my regular website, so set it up on a test bed loaded with fresh copy of WP 2.03.
I downloaded the two files. Renamed to ajax-comment-preview.js.php, and ajax-comment-preview.php. Put both in a directory in plugins called/commentpreview. Activated plugin. Checked the options are correct, ie. Author, url, comment id. Using wp 2.03, default theme. Loaded website, “preview” button comes up as expected. Press it, nothing happens. Press “submit”, comments posts as normal. No other plugins are activated. Tried in both Firefox and IE 6.
Any help would be greatly appreciated
Not
ajax-comment-preview.js.php
but ratherajax-comment-preview-js.php
(note the hyphen instead of the period).I’m echoing FD’s comment, I’m getting the same problem with the plugin! It isn’t working when I click the button, nor do I see any title text. I also tried using it on the Kubrick theme in my 2.0.3 installation just to be sure.
The Javascript console isn’t reporting any error, either…
SG, without pointing me to your site, I can’t offer much advice.
Lol.. to think of all the time I wasted trying to figure this out. Thank you!
SG: I bet you have the same problem I did.
Quite delightful, thank you. What I like about this is that it respects the blog author’s comment formatting settings, unlike some other plugins I’ve seen.
By the way, how hard would it be to make this into a “live preview”? I’d imagine it would only take a small amount of new code, which could be turned on and off by an option on the plugin options page.
But it’s great as is. Thank you so much!
Doing a live preview would not be too hard, but making one right (i.e. a live preview that respects your templates and filters) would be difficult to implement well.
At any rate, I find live previews to be incredibly annoying, so I won’t be looking into it
:)
You’re right, they are annoying, and if I had the option I’d probably keep it turned off. I was mostly curious about how difficult it would be.
ror,
Sorry. Akismet flagged your comment as Spam for some reason.
Good suggestions. They’re on the list.
> I get a number of comments on this post testing
> the system. A little odd, since it seems to me
> people should be testing the preview functionality
> (which is new) not the comment posting
> functionality (which is the same old WordPress
> standard stuff).
I almost hit submit — and the reason is the tab-order. The Preview button is displayed before the Submit button, so I assumed that tab + enter will hit Preview, but your tab-order is Submit first and Preview next.
If I were to hazard a guess, most folks might just be hitting tab and then realise that they have hit Submit, rather than Preview.
Just a thought.
C’mon guys! Let’s be more creative!
Jagged Little Pill by Alanis is the greatest album ever! Perfectly mixes angst and hope.
Works perfectly! The only comments preview plugin to do so with my setup.
Haven’t worked out how to get it to show gravatars yet. It will show Comvatars if the Comvatars plugin is activated, so why not gravatars too???
I have installed the plugin and get the preview button, but nothing happens when I press it? Any thoughts? Please See Here
Thank you
Alright, now much creative maybe but my favorite musical band is DMB. I even devoted a website to them which is the first and only DMB fan site in my language http://www.dmbturkiye.gen.tr
However I left the best part of my comment to the end; when I type ‘:)’ in the comment textbox I also see ‘:)’ is the preview. Is it possible to see the smiley icon instead of the text ‘:)’ in the preview?
:)
Michael Cohen, it looks like the javascript file isn’t there. Did you download both files and put them in the same place?
Halil, on your site, I’m sure the smilies would show up. I have disabled them on mine; that’s why you don’t see them here.
Hi thanks for the help, so now I can get it to start to work but as you will see I get the following error “Fatal error: Call to undefined function: get_currentuserinfo() in /home/.david/mgcohen/brandedart.net/blog/wp-content/plugins/ajax-comment-preview.php.php on line 58”
Thanks again for your help
Michael Cohen, I’m not sure what could be causing that.
ajax-comment-preview.php.php
should be renamed toajax-comment-preview.php
(only one.php
). Fix that, reactivate the plugin, refresh the page and see if that helps.“Surrender pronto, or we’ll level Toronto!”
nice plugin
It’s not working for me, the div box appears on my page but there is no data appearing inside.. I use wordpress 2.x
Whe this is a better plugin, I will grab it.
Some suggestions for the development:
the text of the preview button used in the comment_form() should be localizable
plugin displays non localized dates: for example it wrotes “17 december 2006” instead of “17 dicembre 2006” (using j F Y on italian blog)
Another strange problem with Apple Safari (no problems with Firefox or Opera): it seems to display characters with strange encoding
See image:
http://xs310.xs.to/xs310/06500/safari.png
Great piece of work, but i found the same problem on Apple Safari. I will check for a solution and post success message here.
Maybe I found a temporary solution: decode the commentPreview.response!
Add to ajax-comment-preview-js.php the function decode from this page (change declaration since this is a class method).
After that change, modify line 85 (see decode function at the end)
commentPreview.onCompletion = function() { outputElement.innerHTML = decode (commentPreview.response); };
Roses are red, violets are blue,
Ajax kicks ass and so do you!!
Great plugin cheers!
Any chance this badboy works with WordPress 2.1?
Thanks!
Hi,
I have upgraded my 2.0.6 test blog with version 1.0.1 of this plugin, and I have the problem where the Preview button exists, but pressing it has no effect.
My test blog has a URL of the following format: http://example.com/blogtesting/blog43/
I did some debugging, and found the reason was that the path to the js file was incorrect in the header.
It looked like this:
http://www.example.com/blogtesting/blog43/blogtesting/blog43/wp-content/plugins/AjaxCommentPreview1.0.1/ajax-comment-preview-js.php
Note the duplication of the subdirectories in the URL.
When I manually hacked the extra subdirectories out of the HTML, the preview function worked.
I suspect that this bug affects people who do not have their WordPress blog in the root directory of their web-site, and works fine for people who do.
More testing revealed that the call to wp_enqueue_script in wp_print_script seems to be adding “http://www.example.com/blogtesting/blog43” to the front of the parameter “/blog43/wp-content/plugins/AjaxCommentPreview1.0.1/ajax-comment-preview-js.php” (which is the result of htmldir).
I haven’t got a patch, because I don’t yet understand what wp_enqueue_script is supposed to do.
Nice detective work Julian!
Since I can’t figure out what “wp_enqueue_script” does either (and it does do a bunch of admin stuff) I just manually added a call to the proper location of ajax-comment-preview-js.php to the header and it works fine!
Having an extra call will not hurt as the one with the incorrect address is of course not being loaded.
Yup, the path to the javascript in the blog header is false (even on this blog:).
My temporary solution involves opening the file
ajax-comment-preview.php
and in line no. 31 replacing' . Ajax_Comment_Preview::htmldir( __FILE__ ) . '
with
wp-content/plugins
so that line 31 reads:
wp_enqueue_script( 'ajax_comment_preview', '/wp-content/plugins/ajax-comment-preview-js.php', array('sack'), Ajax_Comment_Preview::version() . $ver );
Works fine other than that. :)
^^ Oops, forgot to write my name down. :)
Hi – as far as I can tell, Ajax Comment Preview stopped working with the WP 2.1 update. Sadly, as it was by far the neatest preview option available.
Are you likely to be updating it for 2.1 or is it time to kiss it goodbye?
Thanks
Hmmmmm… I would love to put this plugin on my blog, but does it work with WP 2.1?
I’ve also noticed on my upgraded to 2.1 WP that the preview no longer works. I share Andy’s wish that you might wish to update it, as I’ve enjoyed having it on my blog.
This plugin is now compatible with WordPress 2.1.
Use the download link at the top of the post to get the most recent version (1.1).
Great news, many thanks! :)
wew, i still don’t get it
why it doesn’t work in opera 7.4
In the room women come and go / NOT talking of Michelangelo.
Thanks for the plugin!