tokkonopapa / WP-Super-Preload

This plugin helps to keep whole pages of your site always being cached in the fresh based on the sitemap.xml and your own settings.
7 stars 1 forks source link

Added a filter to modify the used curl options #4

Open carstingaxion opened 2 years ago

carstingaxion commented 2 years ago

Ola @tokkonopapa.

Wether it is some days old, I love your plugin. Thanks for your effort!

I was looking for a way to receive gzipped- and webp-prepared content and was not able to achieve this by using different user-agent-strings.

So I introduced a filter to set all curl options, your default ones and maybe some new. Hopefully this helps others too.

Now, you can do:

add_filter( 'wp-super-preload\curl_setopt', 'new_curl_setopt' );
public function new_curl_setopt( Array $curl_opts ) : Array
{
    $curl_opts[ CURLOPT_ENCODING ]   = 'gzip';
    $curl_opts[ CURLOPT_HTTPHEADER ] = [ 'Accept: image/webp' ];

    return $curl_opts;
}