[wp-hackers] Comments and Google Maps

Austin Matzko if.website at gmail.com
Mon Nov 14 17:20:53 GMT 2005

On 11/14/05, Brian Lalor <blalor at bravo5.org> wrote:
> I don't think
> it's going to be simply a drop-in thing, however.  There's only one
> extension point for the comments form, and that puts additional
> fields *after* the submit button (and not very neatly, at that).
> This will probably mean that the user will have to modify or create a
> Page template (if they choose to limit this functionality to just
> Pages) to make the comments form look prettier.

Brian, a hack I used to add a "preview" button for my comments preview
plugin, without requiring the user to modify templates, might help

There's a line in the wp-includes/comment-functions.php file that
applies the 'comments_template' filter to the file name of the
$include = apply_filters('comments_template', TEMPLATEPATH . $file );

It's meant to allow you to change the file name of the comments
template.  What I did was change it to the path of my plugin file (so
that it would return true but do nothing), but I read the original
comments template file into a variable, used regular expressions to
make my changes, and then evaluated it to mimic the include action of
the core file.  Here's a stripped-down version:

function replace_comments_file ($comments_filepath) {
$comments_template = file_get_contents($comments_filepath);
$comments_template = preg_replace( * whatever *);
eval('?>' . $comments_template );
return __FILE__;

add_filter('comments_template', 'replace_comments_file');

More information about the wp-hackers mailing list