Make WordPress Core

Ticket #34731: 34731.2.patch

File 34731.2.patch, 2.9 KB (added by SergeyBiryukov, 9 years ago)
  • src/wp-includes/comment-template.php

     
    22142214
    22152215                                        endif;
    22162216
     2217                                        $comment_fields = array( 'comment' => $args['comment_field'] ) + (array) $args['fields'];
     2218
    22172219                                        /**
    2218                                          * Filter the content of the comment textarea field for display.
     2220                                         * Filter the comment form fields.
    22192221                                         *
    2220                                          * @since 3.0.0
     2222                                         * @since 4.4.0
    22212223                                         *
    2222                                          * @param string $args_comment_field The content of the comment textarea field.
     2224                                         * @param array $comment_fields The comment fields.
    22232225                                         */
    2224                                         echo apply_filters( 'comment_form_field_comment', $args['comment_field'] );
     2226                                        $comment_fields = apply_filters( 'comment_form_fields', $comment_fields );
    22252227
    2226                                         echo $args['comment_notes_after'];
     2228                                        $comment_field_keys = array_diff( array_keys( $comment_fields ), array( 'comment' ) );
    22272229
    2228                                         if ( ! is_user_logged_in() ) :
    2229                                                 /**
    2230                                                  * Fires before the comment fields in the comment form.
    2231                                                  *
    2232                                                  * @since 3.0.0
    2233                                                  */
    2234                                                 do_action( 'comment_form_before_fields' );
    2235                                                 foreach ( (array) $args['fields'] as $name => $field ) {
     2230                                        $first_field = reset( $comment_field_keys );
     2231                                        $last_field  = end( $comment_field_keys );
     2232
     2233                                        foreach ( $comment_fields as $name => $field ) {
     2234
     2235                                                if ( 'comment' === $name ) {
     2236
    22362237                                                        /**
     2238                                                         * Filter the content of the comment textarea field for display.
     2239                                                         *
     2240                                                         * @since 3.0.0
     2241                                                         *
     2242                                                         * @param string $args_comment_field The content of the comment textarea field.
     2243                                                         */
     2244                                                        echo apply_filters( 'comment_form_field_comment', $field );
     2245
     2246                                                } elseif ( ! is_user_logged_in() ) {
     2247
     2248                                                        if ( $first_field === $name ) {
     2249                                                                /**
     2250                                                                 * Fires before the comment fields in the comment form.
     2251                                                                 *
     2252                                                                 * @since 3.0.0
     2253                                                                 */
     2254                                                                do_action( 'comment_form_before_fields' );
     2255                                                        }
     2256
     2257                                                        /**
    22372258                                                         * Filter a comment form field for display.
    22382259                                                         *
    22392260                                                         * The dynamic portion of the filter hook, `$name`, refers to the name
     
    22442265                                                         * @param string $field The HTML-formatted output of the comment form field.
    22452266                                                         */
    22462267                                                        echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
     2268
     2269                                                        if ( $last_field === $name ) {
     2270                                                                /**
     2271                                                                 * Fires after the comment fields in the comment form.
     2272                                                                 *
     2273                                                                 * @since 3.0.0
     2274                                                                 */
     2275                                                                do_action( 'comment_form_after_fields' );
     2276                                                        }
     2277
    22472278                                                }
    2248                                                 /**
    2249                                                  * Fires after the comment fields in the comment form.
    2250                                                  *
    2251                                                  * @since 3.0.0
    2252                                                  */
    2253                                                 do_action( 'comment_form_after_fields' );
    22542279
    2255                                         endif;
     2280                                        }
    22562281
     2282                                        echo $args['comment_notes_after'];
     2283
    22572284                                        $submit_button = sprintf(
    22582285                                                $args['submit_button'],
    22592286                                                esc_attr( $args['name_submit'] ),