@dgamoni Please accept my best wishes for you and your family as you’re traveling right now. No one should be in the position that you’ve been put in and I genuinely hope the best for you as you work out how to handle that situation.
As far as this particular forum topic problem, perhaps I can help some. The underlying problem really just stems from core use of PHP file I/O for URLs that the site actually has direct access to. The user agent issue is really just a symptom of the problem rather than the problem itself. In simple terms, it’s a bit of a logical code problem to fetch an asset (like an image) that the server has direct access to by using the URL to that image instead. By using the URL, the server has to go outside of itself through the internet only to loop right back to itself to get that asset. You could say that it is the long way around like if you needed to get the cup across the room and decided to leave the building, walk around it, and then come back in to get the cup from a different side of the room. It’s just more cumbersome than walking a few feet or meters across the room to the cup.
The solution is just to fix that. In an effort to try to help Andrew, we took the liberty to try one solution. There are several ways that you could fix this but the one below is working for him.
The problem is in this file:
wp-content/plugins/locateandfilter_pro/public/class-locate-and-filter-public.php
In it, you’ll find the following code to retrieve a custom map marker URL:
$custom_marker = sanitize_key($customIconURL) ;
list($width, $height, $type, $attr) = getimagesize($customIconURL);
The code in this particular branch in your plugin appears to be limited to custom map marker images that are inside of the WordPress media library (not other URLs that aren’t in the media library). So a small modification to this code to the following seems to fix the problem.
$custom_marker = sanitize_key($customIconURL) ;
$customIconPath = str_replace(WP_CONTENT_URL, '', $customIconURL);
list($width, $height, $type, $attr) = getimagesize(WP_CONTENT_DIR . $customIconPath);
That that code does is just find the file path to the image in the customIconURL variable so that you don’t have to use PHP’s URL functions for I/O at all. Assuming that you wanted to continue using PHP’s native URL-supported functions for things like getimagesize, you could also just set a user agent via:
ini_set(‘user_agent’, ‘whatever user agent you want to use’);
Since ini_set is global to all other things in the site too, I don’t really recommend that route as it might have side effects. The code that I provided above is more of a direct approach to solving this problem and since we did test it for Andrew on his server and verified that it’s working for him, it might be a simple copy and paste solution for you to upgrade that part of your plugin to support more secure defaults on security-minded hosts.
Hopefully that helps. Happy to explain further if that’s of any help to you.