$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']; } if (isset($r['limit_response_size'])) { $options['max_bytes'] = $r['limit_response_size']; } if ( ! empty($r['cookies'])) { $options['cookies'] = WP_Http::normalize_cookies($r['cookies']); } if ( ! $r['sslverify']) { $options['verify'] = false; $options['verifyname'] = false; } else { $options['verify'] = $r['sslcertificates']; } if ('HEAD' !== $type && 'GET' !== $type) { $options['data_format'] = 'body'; } $options['verify'] = apply_filters('https_ssl_verify', $options['verify'], $url); $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(); } } mbstring_binary_safe_encoding(); try { $requests_response = Requests::request($url, $headers, $data, $type, $options); $http_response = new WP_HTTP_Requests_Response($requests_response, $r['filename']); $response = $http_response->to_array(); $response['http_response'] = $http_response; } catch (Requests_Exception $e) { $response = new WP_Error('http_request_failed', $e->getMessage()); } reset_mbstring_encoding(); 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, ); } 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[] = '发布地址'; $links[] = 'GitHub'; } return $links; } public static function action_links($links, $file) { if ($file != plugin_basename(WP_CHINA_YES_BASE_FILE)) { return $links; } $settings_link = '设置'; array_unshift($links, $settings_link); return $links; } public static function admin_menu() { add_options_page( 'WP-China-Yes', 'WP-China-Yes', 'manage_options', 'wp_china_yes', array(__CLASS__, 'settings') ); } public static function settings() { $iframe_str = << EOT; $plugin_root_url = plugin_url(); str_replace('/wp-content/plugins', $plugin_root_url, $iframe_str); echo $iframe_str; } }