PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.7
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.7
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / inc / 3rd-party / hosting / siteground.php

siteground.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.7, at inc/3rd-party/hosting/siteground.php

39 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
3
4 add_filter( 'http_request_args', 'imagify_siteground_change_user_agent', 10, 2 );
5 /**
6 * Filter the arguments used in a HTTP request to change the User Agent for requests "to self".
7 * SiteGround blocks (error 403) HTTP requests with a User-Agent containing the site's domain.
8 * The problem is that, for a given site at https://example.com, WordPress uses the UA `WordPress/4.8.2; https://example.com`.
9 *
10 * @since 1.6.13
11 * @author Grégory Viguier
12 *
13 * @param array $r An array of HTTP request arguments.
14 * @param string $url The request URL.
15 * @return array
16 */
17 function imagify_siteground_change_user_agent( $r, $url ) {
18 static $user_agent;
19 $site_url = site_url( '/' );
20
21 if ( false === strpos( $url, $site_url ) ) {
22 return $r;
23 }
24
25 $site_url = wp_parse_url( $site_url );
26
27 if ( false === strpos( $r['user-agent'], $site_url['host'] ) ) {
28 return $r;
29 }
30
31 if ( ! isset( $user_agent ) ) {
32 $user_agent = wp_generate_password( 12, false );
33 }
34
35 $r['user-agent'] = $user_agent;
36
37 return $r;
38 }
39