[wp-trac] [WordPress Trac] #16576: comment_form() fields being displayed only for non logged in users

WordPress Trac noreply at wordpress.org
Sun Oct 26 02:16:04 UTC 2014


#16576: comment_form() fields being displayed only for non logged in users
--------------------------+------------------------------
 Reporter:  maorb         |       Owner:
     Type:  enhancement   |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Comments      |     Version:  3.0.5
 Severity:  normal        |  Resolution:
 Keywords:  dev-feedback  |     Focuses:
--------------------------+------------------------------

Comment (by valendesigns):

 Hey Guys,

 I would love to work on this ticket as my first contribution to the core,
 but a group consensus should be reached about how to approach the subject
 before I start coding anything.

 How about adding an additional argument that if set to true (defaults to
 false) will loop over the `$args['fields']` in the logged in block.
 However, adding the loop again isn't very DRY and would still need to be
 distilled down to something that doesn't repeat the `$args['fields']` loop
 by creating a new function that looks something like this...

 {{{
 function comment_form_fields( $fields = array() ) {
   if ( ! is_array( $fields ) )
     return false;

   /**
    * Fires before the comment fields in the comment form.
    *
    * @since 3.0.0
    */
   do_action( 'comment_form_before_fields' );
   foreach ( (array) $fields as $name => $field ) {
     /**
      * Filter a comment form field for display.
      *
      * The dynamic portion of the filter hook, $name, refers to the name
      * of the comment form field. Such as 'author', 'email', or 'url'.
      *
      * @since 3.0.0
      *
      * @param string $field The HTML-formatted output of the comment form
 field.
     echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
   }
   /**
    * Fires after the comment fields in the comment form.
    *
    * @since 3.0.0
    */
   do_action( 'comment_form_after_fields' );
 }
 }}}

 Then it could be used in both if/else blocks without any repetition being
 added to the code. It's a simple solution. If anyone else has any
 suggestions or thinks this is bad idea please let me know. I'm eager to
 start contributing to the core and this looks like a quick and easy fix
 for me to get started with.

 Cheers,
 Derek

--
Ticket URL: <https://core.trac.wordpress.org/ticket/16576#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list