Make WordPress Core

Ticket #34731: 34731.4.patch

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

     
    20372037 *     @type string $comment_field        The comment textarea field HTML.
    20382038 *     @type string $must_log_in          HTML element for a 'must be logged in to comment' message.
    20392039 *     @type string $logged_in_as         HTML element for a 'logged in as [user]' message.
    2040  *     @type string $comment_notes_before HTML element for a message displayed before the comment form.
     2040 *     @type string $comment_notes_before HTML element for a message displayed before the comment fields
     2041 *                                        if the user is not logged in.
    20412042 *                                        Default 'Your email address will not be published.'.
    2042  *     @type string $comment_notes_after  HTML element for a message displayed after the comment form.
     2043 *     @type string $comment_notes_after  HTML element for a message displayed after the 'Comment' field.
    20432044 *     @type string $id_form              The comment form element id attribute. Default 'commentform'.
    20442045 *     @type string $id_submit            The comment submit element id attribute. Default 'submit'.
    20452046 *     @type string $class_form           The comment form element class attribute. Default 'comment-form'.
     
    22142215
    22152216                                        endif;
    22162217
     2218                                        $comment_fields = array( 'comment' => $args['comment_field'] ) + (array) $args['fields'];
     2219
    22172220                                        /**
    2218                                          * Filter the content of the comment textarea field for display.
     2221                                         * Filter the comment form fields.
    22192222                                         *
    2220                                          * @since 3.0.0
     2223                                         * @since 4.4.0
    22212224                                         *
    2222                                          * @param string $args_comment_field The content of the comment textarea field.
     2225                                         * @param array $comment_fields The comment fields.
    22232226                                         */
    2224                                         echo apply_filters( 'comment_form_field_comment', $args['comment_field'] );
     2227                                        $comment_fields = apply_filters( 'comment_form_fields', $comment_fields );
    22252228
    2226                                         echo $args['comment_notes_after'];
     2229                                        $comment_field_keys = array_diff( array_keys( $comment_fields ), array( 'comment' ) );
    22272230
    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 ) {
     2231                                        $first_field = reset( $comment_field_keys );
     2232                                        $last_field  = end( $comment_field_keys );
     2233
     2234                                        foreach ( $comment_fields as $name => $field ) {
     2235
     2236                                                if ( 'comment' === $name ) {
     2237
    22362238                                                        /**
     2239                                                         * Filter the content of the comment textarea field for display.
     2240                                                         *
     2241                                                         * @since 3.0.0
     2242                                                         *
     2243                                                         * @param string $args_comment_field The content of the comment textarea field.
     2244                                                         */
     2245                                                        echo apply_filters( 'comment_form_field_comment', $field );
     2246
     2247                                                        echo $args['comment_notes_after'];
     2248
     2249                                                } elseif ( ! is_user_logged_in() ) {
     2250
     2251                                                        if ( $first_field === $name ) {
     2252                                                                /**
     2253                                                                 * Fires before the comment fields in the comment form (excluding 'Comment').
     2254                                                                 *
     2255                                                                 * @since 3.0.0
     2256                                                                 */
     2257                                                                do_action( 'comment_form_before_fields' );
     2258                                                        }
     2259
     2260                                                        /**
    22372261                                                         * Filter a comment form field for display.
    22382262                                                         *
    22392263                                                         * The dynamic portion of the filter hook, `$name`, refers to the name
     
    22442268                                                         * @param string $field The HTML-formatted output of the comment form field.
    22452269                                                         */
    22462270                                                        echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
     2271
     2272                                                        if ( $last_field === $name ) {
     2273                                                                /**
     2274                                                                 * Fires after the comment fields in the comment form (excluding 'Comment').
     2275                                                                 *
     2276                                                                 * @since 3.0.0
     2277                                                                 */
     2278                                                                do_action( 'comment_form_after_fields' );
     2279                                                        }
    22472280                                                }
    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' );
     2281                                        }
    22542282
    2255                                         endif;
    2256 
    22572283                                        $submit_button = sprintf(
    22582284                                                $args['submit_button'],
    22592285                                                esc_attr( $args['name_submit'] ),