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.
Built from https://develop.svn.wordpress.org/trunk@39287


git-svn-id: http://core.svn.wordpress.org/trunk@39227 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Rachel Baker 2016-11-18 16:22:33 +00:00
parent 000cd0c68d
commit 10bddfac39
2 changed files with 4 additions and 2 deletions

View File

@ -1041,8 +1041,10 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
$prepared_comment['comment_author_IP'] = $request['author_ip'];
}
if ( isset( $request['author_user_agent'] ) ) {
if ( ! empty( $request['author_user_agent'] ) ) {
$prepared_comment['comment_agent'] = $request['author_user_agent'];
} elseif ( $request->get_header( 'user_agent' ) ) {
$prepared_comment['comment_agent'] = $request->get_header( 'user_agent' );
}
if ( isset( $request['type'] ) ) {

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-beta4-39286';
$wp_version = '4.7-beta4-39287';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.