# imagify/1.7/inc/3rd-party/hosting/siteground.php

Imagify Image Optimization: Optimize Images | Compress &amp; Convert to WebP/AVIF, version 1.7. 39 lines.

- Page: https://pluginprobe.com/plugins/imagify/1.7/code/inc/3rd-party/hosting/siteground.php
- Raw: https://pluginprobe.com/plugins/imagify/1.7/raw/inc/3rd-party/hosting/siteground.php
- Modified: 2018-03-13T14:15:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/imagify/1.7/code/inc/3rd-party/hosting/siteground.php#L10-L20`.

```php
<?php
defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );

add_filter( 'http_request_args', 'imagify_siteground_change_user_agent', 10, 2 );
/**
 * Filter the arguments used in a HTTP request to change the User Agent for requests "to self".
 * SiteGround blocks (error 403) HTTP requests with a User-Agent containing the site's domain.
 * The problem is that, for a given site at https://example.com, WordPress uses the UA `WordPress/4.8.2; https://example.com`.
 *
 * @since  1.6.13
 * @author Grégory Viguier
 *
 * @param  array  $r   An array of HTTP request arguments.
 * @param  string $url The request URL.
 * @return array
 */
function imagify_siteground_change_user_agent( $r, $url ) {
	static $user_agent;
	$site_url = site_url( '/' );

	if ( false === strpos( $url, $site_url ) ) {
		return $r;
	}

	$site_url = wp_parse_url( $site_url );

	if ( false === strpos( $r['user-agent'], $site_url['host'] ) ) {
		return $r;
	}

	if ( ! isset( $user_agent ) ) {
		$user_agent = wp_generate_password( 12, false );
	}

	$r['user-agent'] = $user_agent;

	return $r;
}

```
