Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/embedpre.../EmbedPre.../Provider...
File: GoogleMaps.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace EmbedPress\Providers;
[2] Fix | Delete
[3] Fix | Delete
use Embera\Provider\ProviderAdapter;
[4] Fix | Delete
use Embera\Provider\ProviderInterface;
[5] Fix | Delete
use Embera\Url;
[6] Fix | Delete
[7] Fix | Delete
(defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Entity responsible to support GoogleMaps embeds.
[11] Fix | Delete
*
[12] Fix | Delete
* @package EmbedPress
[13] Fix | Delete
* @subpackage EmbedPress/Providers
[14] Fix | Delete
* @author EmbedPress <help@embedpress.com>
[15] Fix | Delete
* @copyright Copyright (C) 2023 WPDeveloper. All rights reserved.
[16] Fix | Delete
* @license GPLv3 or later
[17] Fix | Delete
* @since 1.0.0
[18] Fix | Delete
*/
[19] Fix | Delete
class GoogleMaps extends ProviderAdapter implements ProviderInterface
[20] Fix | Delete
{
[21] Fix | Delete
/** inline {@inheritdoc} */
[22] Fix | Delete
protected static $hosts = ["google.com", "google.com.*", "maps.google.com", "goo.gl", "google.co.*"];
[23] Fix | Delete
/**
[24] Fix | Delete
* Method that verifies if the embed URL belongs to GoogleMaps.
[25] Fix | Delete
*
[26] Fix | Delete
* @param Url $url
[27] Fix | Delete
* @return boolean
[28] Fix | Delete
* @since 1.0.0
[29] Fix | Delete
*
[30] Fix | Delete
*/
[31] Fix | Delete
public function validateUrl(Url $url)
[32] Fix | Delete
{
[33] Fix | Delete
return (bool) preg_match('~http[s]?:\/\/(?:(?:(?:www\.|maps\.)?(?:google\.com?))|(?:goo\.gl))(?:\.[a-z]{2})?\/(?:maps\/)?(?:place\/)?(?:[a-z0-9\/%+\-_]*)?([a-z0-9\/%,+\-_=!:@\.&*\$#?\']*)~i',
[34] Fix | Delete
(string) $url);
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
public function validateGoogleMapUrl($url)
[38] Fix | Delete
{
[39] Fix | Delete
return (bool) preg_match('~http[s]?:\/\/(?:(?:(?:www\.|maps\.)?(?:google\.com?))|(?:goo\.gl))(?:\.[a-z]{2})?\/(?:maps\/)?(?:place\/)?(?:[a-z0-9\/%+\-_]*)?([a-z0-9\/%,+\-_=!:@\.&*\$#?\']*)~i',
[40] Fix | Delete
(string) $url);
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* This method fakes an Oembed response.
[45] Fix | Delete
*
[46] Fix | Delete
* @since 1.0.0
[47] Fix | Delete
*
[48] Fix | Delete
* @return array
[49] Fix | Delete
*/
[50] Fix | Delete
public function fakeResponse()
[51] Fix | Delete
{
[52] Fix | Delete
$src_url = urldecode($this->url);
[53] Fix | Delete
[54] Fix | Delete
preg_match('/(?<=mid=).*$/', $src_url, $matches);
[55] Fix | Delete
[56] Fix | Delete
$iframeSrc = '';
[57] Fix | Delete
$mid = '';
[58] Fix | Delete
[59] Fix | Delete
if (!empty($matches)) {
[60] Fix | Delete
$mid = $matches[0].'&ehbc=2E312F';
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
// Check if the url is already converted to the embed format
[64] Fix | Delete
if (preg_match('~(maps/embed|output=embed)~i', $src_url)) {
[65] Fix | Delete
$iframeSrc = $src_url;
[66] Fix | Delete
}
[67] Fix | Delete
else {
[68] Fix | Delete
// Extract coordinates and zoom from the url
[69] Fix | Delete
if (preg_match('~(?:maps\/(?:place|(?:dir\/.+?))\/(.+)\/)?@(-?[0-9\.]+,-?[0-9\.]+).+,([0-9\.]+[a-z])~i', $src_url, $matches)) {
[70] Fix | Delete
$place_name = str_replace("+"," ",$matches[1]);
[71] Fix | Delete
$z = floatval( $matches[3]);
[72] Fix | Delete
$iframeSrc = 'https://maps.google.com/maps?hl=en&ie=UTF8&ll=' . $matches[2] . '&spn=' . $matches[2] . '&q='.$place_name.'&t=m&z=' . round($z) . '&output=embed&iwloc';
[73] Fix | Delete
}
[74] Fix | Delete
else if ($this->validateGoogleMapUrl($src_url)){
[75] Fix | Delete
$iframeSrc = 'https://www.google.com/maps/d/embed?mid='.$mid;
[76] Fix | Delete
}
[77] Fix | Delete
else {
[78] Fix | Delete
return [];
[79] Fix | Delete
}
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
$width = isset( $this->config['maxwidth']) ? $this->config['maxwidth']: 600;
[83] Fix | Delete
$height = isset( $this->config['maxheight']) ? $this->config['maxheight']: 450;
[84] Fix | Delete
[85] Fix | Delete
return [
[86] Fix | Delete
'type' => 'rich',
[87] Fix | Delete
'provider_name' => 'Google Maps',
[88] Fix | Delete
'provider_url' => 'https://maps.google.com',
[89] Fix | Delete
'title' => 'Unknown title',
[90] Fix | Delete
'html' => '<iframe title="" width="'.esc_attr($width).'" height="'.esc_attr($height).'" src="'.esc_url($iframeSrc).'" frameborder="0"></iframe>',
[91] Fix | Delete
];
[92] Fix | Delete
}
[93] Fix | Delete
/** inline @inheritDoc */
[94] Fix | Delete
public function modifyResponse( array $response = [])
[95] Fix | Delete
{
[96] Fix | Delete
return $this->fakeResponse();
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function