[wp-trac] [WordPress Trac] #10910: Standardize comment form

WordPress Trac wp-trac at lists.automattic.com
Wed Oct 7 16:35:51 UTC 2009


#10910: Standardize comment form
-------------------------+--------------------------------------------------
 Reporter:  Otto42       |       Owner:                
     Type:  enhancement  |      Status:  new           
 Priority:  normal       |   Milestone:  Future Release
Component:  Comments     |     Version:  2.9           
 Severity:  normal       |    Keywords:                
-------------------------+--------------------------------------------------

Comment(by Otto42):

 Replying to [comment:2 alexdunae]:
 > In the past I've added multiple fields to comment forms (marketing opt-
 in, hometown, etc...), removed the URL field, and reduced the comment
 textarea to input[type=text]. I also frequently re-write the HTML to put
 the labels above the fields.  To accomplish all that, I'd have to
 'complain' to get a lot of hooks added.

 Nope. One filter hook can let you add labels, fields, whatever you like.
 Or remove existing ones, if done properly.

 Consider every "field" to be in an array that looks like this:

 array(
 'name'=>'<label for="author">Name</label><input type="text"..blah blah..',
 'email'=>'<label for="email">Email address</label><input type="text"..blah
 blah..',
 .. blah blah...
 )

 Now, you run a filter on that array. Adding a new field is as simple as
 inserting a new element into the array. Delete an element from it and it
 disappears from the form. Want to redefine one? Just change the HTML in
 that one. Heck, you can even reorder the array if you like. One filter
 hook.

 After the filter runs, a simple loop outputs the HTML code.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10910#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list