Press This: Set explicit user agent.

props kraftbj.
fixes #32864.

git-svn-id: https://develop.svn.wordpress.org/trunk@33061 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2015-07-03 11:16:08 +00:00
parent 220121249a
commit 9cfb72615c
1 changed files with 21 additions and 0 deletions

View File

@ -1167,6 +1167,24 @@ class WP_Press_This {
return $content;
}
/**
* Sets the user agent used for Press This HTTP requests.
*
* @since 4.3.0
* @access public
*
* @global string $wp_version
*
* @return string User agent.
*/
public function ua_string() {
global $wp_version;
$user_agent = 'Press This (WordPress/' . $wp_version . '); ' . get_bloginfo( 'url' );
return $user_agent;
}
/**
* Serves the app's base HTML, which in turns calls the load script.
*
@ -1180,6 +1198,9 @@ class WP_Press_This {
public function html() {
global $wp_locale, $wp_version;
// Set explicit user-agent for the $data outbound HTTP requests.
add_filter( 'http_headers_useragent', array( $this, 'ua_string' ) );
// Get data, new (POST) and old (GET).
$data = $this->merge_or_fetch_data();