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: TikTok.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 TikTok 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 TikTok extends ProviderAdapter implements ProviderInterface
[20] Fix | Delete
{
[21] Fix | Delete
/** inline {@inheritdoc} */
[22] Fix | Delete
protected static $hosts = ["tiktok.com"];
[23] Fix | Delete
/**
[24] Fix | Delete
* Method that verifies if the embed URL belongs to TikTok.
[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
// TikTok URL pattern
[34] Fix | Delete
$pattern = "/^https:\/\/www\.tiktok\.com\/@[\w.-]+\/video\/[\w.-]+$/i";
[35] Fix | Delete
// Check if the URL matches the pattern
[36] Fix | Delete
return (bool) preg_match($pattern, (string) $url);
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
public function validateTikTok($url)
[40] Fix | Delete
{
[41] Fix | Delete
// TikTok URL pattern
[42] Fix | Delete
$pattern = "/^https:\/\/www\.tiktok\.com\/@[\w.-]+\/video\/[\w.-]+$/i";
[43] Fix | Delete
// Check if the URL matches the pattern
[44] Fix | Delete
return (bool) preg_match($pattern, (string) $url);
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
public function getTiktokVideoId($url)
[48] Fix | Delete
{
[49] Fix | Delete
// TikTok URL pattern
[50] Fix | Delete
$pattern = "/^https:\/\/www\.tiktok\.com\/@[\w.-]+\/video\/([\w.-]+)$/i";
[51] Fix | Delete
[52] Fix | Delete
// Check if the URL matches the pattern
[53] Fix | Delete
if (preg_match($pattern, (string) $url, $matches)) {
[54] Fix | Delete
// Extracted video ID
[55] Fix | Delete
return $matches[1];
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
return null;
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* This method fakes an Oembed response.
[64] Fix | Delete
*
[65] Fix | Delete
* @since 1.0.0
[66] Fix | Delete
*
[67] Fix | Delete
* @return array
[68] Fix | Delete
*/
[69] Fix | Delete
public function fakeResponse()
[70] Fix | Delete
{
[71] Fix | Delete
$src_url = urldecode($this->url);
[72] Fix | Delete
[73] Fix | Delete
[74] Fix | Delete
// Check if the url is already converted to the embed format
[75] Fix | Delete
if ($this->validateTikTok($src_url)) {
[76] Fix | Delete
$iframeSrc = 'https://tiktok.com/embed/' . $this->getTiktokVideoId($this->url);
[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'] : 350;
[84] Fix | Delete
[85] Fix | Delete
return [
[86] Fix | Delete
'type' => 'rich',
[87] Fix | Delete
'provider_name' => 'TikTok',
[88] Fix | Delete
'provider_url' => 'https://tiktok.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) . '" ></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
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function