Press This: Set explicit user agent.

props kraftbj.
fixes #32864.
Built from https://develop.svn.wordpress.org/trunk@33061


git-svn-id: http://core.svn.wordpress.org/trunk@33032 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2015-07-03 11:17:24 +00:00
parent 12fba44414
commit fc8c36eb97
2 changed files with 22 additions and 1 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();

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-beta1-33060';
$wp_version = '4.3-beta1-33061';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.