Created
April 30, 2020 09:24
-
-
Save Digiover/11ed749a96124281cfba50abb2d14511 to your computer and use it in GitHub Desktop.
Forces HTTP/1.1 for outgoing connections in WordPress instead of HTTP 1.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Use HTTP/1.1 in WordPress | |
* Plugin URI: https://www.saotn.org/ | |
* Donate URI: https://www.paypal.me/jreilink | |
* Description: MU Plugin. Forces HTTP/1.1 for outgoing connections in WordPress instead of HTTP 1.0 | |
* Network: True | |
* Version: 1.0 | |
* Author: Jan Reilink | |
* Author URI: https://www.saotn.org | |
* License: GPLv2 | |
*/ | |
// see https://www.itfaq.nl/forceer-http-1-1-voor-uitgaande-verbindingen-in-wordpress/ for a Dutch article | |
// | |
add_filter('http_request_args', 'saotn_http_request_args', 10, 3); | |
function saotn_http_request_args($r) { | |
$r['httpversion'] = 1.1; | |
return $r; | |
} | |
add_action('http_api_curl', 'saotn_http_api_curl', 10, 3); | |
function saotn_http_api_curl($handle) { | |
curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); | |
} | |
add_filter( 'plugin_row_meta', 'saotn_http11_plugin_row_meta', 10, 2 ); | |
function saotn_http11_plugin_row_meta( $links, $file ) { | |
if ( !preg_match('/use-http11-in-wordpress.php$/', $file ) ) { | |
return $links; | |
} | |
$links[] = sprintf( | |
'<a target="_blank" href="https://paypal.me/jreilink" title="Donate to Jan Reilink / Sysadmins of the North">%s</a>', | |
__( 'Donate' ) | |
); | |
return $links; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment