$r['timeout'], 'useragent' => $r['user-agent'], 'blocking' => $r['blocking'], 'hooks' => new WP_HTTP_Requests_Hooks($url, $r), ); if ($r['stream']) { $options['filename'] = $r['filename']; } if (empty($r['redirection'])) { $options['follow_redirects'] = false; } else { $options['redirects'] = $r['redirection']; } // Use byte limit, if we can if (isset($r['limit_response_size'])) { $options['max_bytes'] = $r['limit_response_size']; } // If we've got cookies, use and convert them to Requests_Cookie. if ( ! empty($r['cookies'])) { $options['cookies'] = WP_Http::normalize_cookies($r['cookies']); } // SSL certificate handling if ( ! $r['sslverify']) { $options['verify'] = false; $options['verifyname'] = false; } else { $options['verify'] = $r['sslcertificates']; } // All non-GET/HEAD requests should put the arguments in the form body. if ('HEAD' !== $type && 'GET' !== $type) { $options['data_format'] = 'body'; } /** * Filters whether SSL should be verified for non-local requests. * * @param bool $ssl_verify Whether to verify the SSL connection. Default true. * @param string $url The request URL. * * @since 2.8.0 * @since 5.1.0 The `$url` parameter was added. * */ $options['verify'] = apply_filters('https_ssl_verify', $options['verify'], $url); // Check for proxies. $proxy = new WP_HTTP_Proxy(); if ($proxy->is_enabled() && $proxy->send_through_proxy($url)) { $options['proxy'] = new Requests_Proxy_HTTP($proxy->host() . ':' . $proxy->port()); if ($proxy->use_authentication()) { $options['proxy']->use_authentication = true; $options['proxy']->user = $proxy->username(); $options['proxy']->pass = $proxy->password(); } } // Avoid issues where mbstring.func_overload is enabled mbstring_binary_safe_encoding(); try { $requests_response = Requests::request($url, $headers, $data, $type, $options); // Convert the response into an array $http_response = new WP_HTTP_Requests_Response($requests_response, $r['filename']); $response = $http_response->to_array(); // Add the original object to the array. $response['http_response'] = $http_response; } catch (Requests_Exception $e) { $response = new WP_Error('http_request_failed', $e->getMessage()); } reset_mbstring_encoding(); /** * Fires after an HTTP API response is received and before the response is returned. * * @param array|WP_Error $response HTTP response or WP_Error object. * @param string $context Context under which the hook is fired. * @param string $class HTTP transport used. * @param array $r HTTP request arguments. * @param string $url The request URL. * * @since 2.8.0 * */ do_action('http_api_debug', $response, 'response', 'Requests', $r, $url); if (is_wp_error($response)) { return $response; } if ( ! $r['blocking']) { return array( 'headers' => array(), 'body' => '', 'response' => array( 'code' => false, 'message' => false, ), 'cookies' => array(), 'http_response' => null, ); } /** * Filters the HTTP API response immediately before the response is returned. * * @param array $response HTTP response. * @param array $r HTTP request arguments. * @param string $url The request URL. * * @since 2.9.0 * */ return apply_filters('http_response', $response, $r, $url); } public static function plugin_row_meta($links, $file) { $base = plugin_basename(WP_CHINA_YES_BASE_FILE); if ($file == $base) { $links[] = '插件发布页'; } return $links; } }