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: Giphy.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 Giphy 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.5.0
[18] Fix | Delete
*/
[19] Fix | Delete
class Giphy extends ProviderAdapter implements ProviderInterface
[20] Fix | Delete
{
[21] Fix | Delete
/**
[22] Fix | Delete
* The regex which identifies Giphy URLs.
[23] Fix | Delete
*
[24] Fix | Delete
* @since 1.5.0
[25] Fix | Delete
* @access private
[26] Fix | Delete
*
[27] Fix | Delete
* @var string
[28] Fix | Delete
*/
[29] Fix | Delete
private $urlRegexPattern = '~http[s]?:\/\/(?:www\.)?giphy\.com\/(?:gifs|clips)\/(?:[a-zA-Z0-9\-]+\-)?([a-zA-Z0-9]+)(?:[^\w\-]|$)|i.giphy\.com\/([a-zA-Z0-9]+)(\.gif)~';
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* Method that verifies if the embed URL belongs to Giphy.
[33] Fix | Delete
*
[34] Fix | Delete
* @param Url $url
[35] Fix | Delete
* @return boolean
[36] Fix | Delete
* @since 1.5.0
[37] Fix | Delete
*
[38] Fix | Delete
*/
[39] Fix | Delete
[40] Fix | Delete
public function validateUrl(Url $url)
[41] Fix | Delete
{
[42] Fix | Delete
$urlString = (string) $url;
[43] Fix | Delete
[44] Fix | Delete
if (preg_match($this->urlRegexPattern, $urlString, $matches)) {
[45] Fix | Delete
// Check which group matched and extract the GIF ID
[46] Fix | Delete
$gifId = isset($matches[1]) && !empty($matches[1]) ? $matches[1] : (isset($matches[2]) ? $matches[2] : null);
[47] Fix | Delete
return $gifId;
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
return false;
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
/**
[54] Fix | Delete
* This method fakes an Oembed response.
[55] Fix | Delete
*
[56] Fix | Delete
* @since 1.5.0
[57] Fix | Delete
*
[58] Fix | Delete
* @return array
[59] Fix | Delete
*/
[60] Fix | Delete
public function fakeResponse()
[61] Fix | Delete
{
[62] Fix | Delete
$url = $this->getUrl();
[63] Fix | Delete
[64] Fix | Delete
if (preg_match($this->urlRegexPattern, $url, $matches)) {
[65] Fix | Delete
$gifId = count($matches) > 3 && strtolower($matches[3]) === ".gif" ? $matches[2] : $matches[1];
[66] Fix | Delete
$width = isset($this->config['maxwidth']) ? $this->config['maxwidth'] : 400;
[67] Fix | Delete
$height = isset($this->config['maxheight']) ? $this->config['maxheight'] : 400;
[68] Fix | Delete
$html = '<a href="https://giphy.com/gifs/' . $gifId . '">' .
[69] Fix | Delete
'<img src="https://media.giphy.com/media/' . $gifId . '/giphy.gif" alt="" width="' . esc_attr($width) . '" height="' . esc_attr($height) . '">' .
[70] Fix | Delete
'</a>';
[71] Fix | Delete
[72] Fix | Delete
$response = [
[73] Fix | Delete
'type' => 'image',
[74] Fix | Delete
'provider_name' => 'Giphy',
[75] Fix | Delete
'provider_url' => 'https://giphy.com',
[76] Fix | Delete
'url' => $url,
[77] Fix | Delete
'html' => $html,
[78] Fix | Delete
];
[79] Fix | Delete
} else {
[80] Fix | Delete
$response = [];
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
return $response;
[84] Fix | Delete
}
[85] Fix | Delete
/** inline @inheritDoc */
[86] Fix | Delete
public function modifyResponse(array $response = [])
[87] Fix | Delete
{
[88] Fix | Delete
return $this->fakeResponse();
[89] Fix | Delete
}
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function