Make WordPress Core


Ignore:
Timestamp:
11/18/2016 04:21:27 PM (9 years ago)
Author:
rachelbaker
Message:

REST API: On comment create, fallback to the user_agent header value.

If a user-agent is not explicitly provided in the author_user_agent parameter, fallback to the user_agent value in the request header.

Props dd32, jnylen0, rachelbaker.
Fixes #38817.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    r39278 r39287  
    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
Note: See TracChangeset for help on using the changeset viewer.