From 9cfb72615cce1db861ccda171cfbc29951b488f8 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 3 Jul 2015 11:16:08 +0000 Subject: [PATCH] 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 --- src/wp-admin/includes/class-wp-press-this.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/wp-admin/includes/class-wp-press-this.php b/src/wp-admin/includes/class-wp-press-this.php index 4a2bde8922..9313f71f9c 100644 --- a/src/wp-admin/includes/class-wp-press-this.php +++ b/src/wp-admin/includes/class-wp-press-this.php @@ -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();