Make WordPress Core

Changeset 33061


Ignore:
Timestamp:
07/03/2015 11:16:08 AM (11 years ago)
Author:
SergeyBiryukov
Message:

Press This: Set explicit user agent.

props kraftbj.
fixes #32864.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-press-this.php

    r33052 r33061  
    11691169
    11701170        /**
     1171         * Sets the user agent used for Press This HTTP requests.
     1172         *
     1173         * @since 4.3.0
     1174         * @access public
     1175         *
     1176         * @global string $wp_version
     1177         *
     1178         * @return string User agent.
     1179         */
     1180        public function ua_string() {
     1181                global $wp_version;
     1182
     1183                $user_agent = 'Press This (WordPress/' . $wp_version . '); ' . get_bloginfo( 'url' );
     1184
     1185                return $user_agent;
     1186        }
     1187
     1188        /**
    11711189         * Serves the app's base HTML, which in turns calls the load script.
    11721190         *
    … …  
    11801198        public function html() {
    11811199                global $wp_locale, $wp_version;
     1200
     1201                // Set explicit user-agent for the $data outbound HTTP requests.
     1202                add_filter( 'http_headers_useragent', array( $this, 'ua_string' ) );
    11821203
    11831204                // Get data, new (POST) and old (GET).
Note: See TracChangeset for help on using the changeset viewer.