Make WordPress Core

Ticket #38817: 38817.diff

File 38817.diff, 1.6 KB (added by dd32, 9 years ago)
  • src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    class WP_REST_Comments_Controller extend 
    10291029                        $prepared_comment['comment_author'] = $request['author_name'];
    10301030                }
    10311031
    10321032                if ( isset( $request['author_email'] ) ) {
    10331033                        $prepared_comment['comment_author_email'] = $request['author_email'];
    10341034                }
    10351035
    10361036                if ( isset( $request['author_url'] ) ) {
    10371037                        $prepared_comment['comment_author_url'] = $request['author_url'];
    10381038                }
    10391039
    10401040                if ( isset( $request['author_ip'] ) ) {
    10411041                        $prepared_comment['comment_author_IP'] = $request['author_ip'];
    10421042                }
    10431043
    1044                 if ( isset( $request['author_user_agent'] ) ) {
     1044                if ( !empty( $request['author_user_agent'] ) ) {
    10451045                        $prepared_comment['comment_agent'] = $request['author_user_agent'];
     1046                } elseif ( $request->get_header( 'user_agent' ) ) {
     1047                        $prepared_comment['comment_agent'] = $request->get_header( 'user_agent' );
    10461048                }
    10471049
    10481050                if ( isset( $request['type'] ) ) {
    10491051                        // Comment type "comment" needs to be created as an empty string.
    10501052                        $prepared_comment['comment_type'] = 'comment' === $request['type'] ? '' : $request['type'];
    10511053                }
    10521054
    10531055                if ( isset( $request['karma'] ) ) {
    10541056                        $prepared_comment['comment_karma'] = $request['karma'] ;
    10551057                }
    10561058
    10571059                if ( ! empty( $request['date'] ) ) {
    10581060                        $date_data = rest_get_date_with_gmt( $request['date'] );
    10591061
    10601062                        if ( ! empty( $date_data ) ) {