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: GoogleDocs.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 GoogleDocs 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 GoogleDocs extends ProviderAdapter implements ProviderInterface
[20] Fix | Delete
{
[21] Fix | Delete
/**
[22] Fix | Delete
* Method that verifies if the embed URL belongs to GoogleDocs.
[23] Fix | Delete
*
[24] Fix | Delete
* @param Url $url
[25] Fix | Delete
* @return boolean
[26] Fix | Delete
* @since 1.0.0
[27] Fix | Delete
*
[28] Fix | Delete
*/
[29] Fix | Delete
public function validateUrl(Url $url)
[30] Fix | Delete
{
[31] Fix | Delete
return (bool) preg_match('~http[s]?:\/\/((?:www\.)?docs\.google\.com\/(?:.*/)?(?:document|presentation|spreadsheets|forms|drawings)\/[a-z0-9\/\?=_\-\.\,&%\$#\@\!\+]*)~i',
[32] Fix | Delete
$url);
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* This method fakes an Oembed response.
[37] Fix | Delete
*
[38] Fix | Delete
* @since 1.0.0
[39] Fix | Delete
*
[40] Fix | Delete
* @return array
[41] Fix | Delete
*/
[42] Fix | Delete
public function fakeResponse()
[43] Fix | Delete
{
[44] Fix | Delete
$iframeSrc = html_entity_decode($this->url);
[45] Fix | Delete
[46] Fix | Delete
// Check the type of document
[47] Fix | Delete
preg_match('~google\.com/(?:.+/)?(document|presentation|spreadsheets|forms|drawings)/~i', $iframeSrc, $matches);
[48] Fix | Delete
$type = $matches[1];
[49] Fix | Delete
[50] Fix | Delete
switch ($type) {
[51] Fix | Delete
case 'document':
[52] Fix | Delete
// Check if the url still doesn't have the embedded param, and add if needed
[53] Fix | Delete
if ( ! preg_match('~([?&])embedded=true~i', $iframeSrc, $matches)) {
[54] Fix | Delete
if (substr_count($iframeSrc, '?')) {
[55] Fix | Delete
$iframeSrc .= '&embedded=true';
[56] Fix | Delete
} else {
[57] Fix | Delete
$iframeSrc .= '?embedded=true';
[58] Fix | Delete
}
[59] Fix | Delete
}
[60] Fix | Delete
break;
[61] Fix | Delete
[62] Fix | Delete
case 'presentation':
[63] Fix | Delete
// Convert the /pub to /embed if needed
[64] Fix | Delete
if (preg_match('~/pub\?~i', $iframeSrc)) {
[65] Fix | Delete
$iframeSrc = str_replace('/pub?', '/embed?', $iframeSrc);
[66] Fix | Delete
}
[67] Fix | Delete
break;
[68] Fix | Delete
[69] Fix | Delete
case 'spreadsheets':
[70] Fix | Delete
if (substr_count($iframeSrc, '?')) {
[71] Fix | Delete
$query = explode('?', $iframeSrc);
[72] Fix | Delete
$query = $query[1];
[73] Fix | Delete
$query = explode('&', $query);
[74] Fix | Delete
[75] Fix | Delete
if ( ! empty($query)) {
[76] Fix | Delete
$hasWidgetParam = false;
[77] Fix | Delete
$hasHeadersParam = false;
[78] Fix | Delete
[79] Fix | Delete
foreach ($query as $param) {
[80] Fix | Delete
if (substr_count($param, 'widget=')) {
[81] Fix | Delete
$hasWidgetParam = true;
[82] Fix | Delete
} elseif (substr_count($param, 'headers=')) {
[83] Fix | Delete
$hasHeadersParam = true;
[84] Fix | Delete
}
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
if ( ! $hasWidgetParam) {
[88] Fix | Delete
$iframeSrc .= '&widget=true';
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
if ( ! $hasHeadersParam) {
[92] Fix | Delete
$iframeSrc .= '&headers=false';
[93] Fix | Delete
}
[94] Fix | Delete
}
[95] Fix | Delete
} else {
[96] Fix | Delete
$iframeSrc .= '?widget=true&headers=false';
[97] Fix | Delete
}
[98] Fix | Delete
break;
[99] Fix | Delete
[100] Fix | Delete
case 'forms':
[101] Fix | Delete
case 'drawings':
[102] Fix | Delete
break;
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
[106] Fix | Delete
$width = isset( $this->config['maxwidth']) ? $this->config['maxwidth']: 600;
[107] Fix | Delete
$height = isset( $this->config['maxheight']) ? $this->config['maxheight']: 450;
[108] Fix | Delete
if ($type !== 'drawings') {
[109] Fix | Delete
$html = '<iframe src="' . esc_url($iframeSrc) . '" frameborder="0" width="'.$width.'" height="'.$height.'" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe>';
[110] Fix | Delete
} else {
[111] Fix | Delete
$width = isset( $this->config['maxwidth']) ? $this->config['maxwidth']: 960;
[112] Fix | Delete
$height = isset( $this->config['maxheight']) ? $this->config['maxheight']: 720;
[113] Fix | Delete
$html = '<img src="' . esc_url($iframeSrc) . '" width="'.esc_attr($width).'" height="'.esc_attr($height).'" />';
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
return [
[117] Fix | Delete
'type' => 'rich',
[118] Fix | Delete
'provider_name' => 'Google Docs',
[119] Fix | Delete
'provider_url' => 'https://docs.google.com',
[120] Fix | Delete
'title' => 'Unknown title',
[121] Fix | Delete
'html' => $html,
[122] Fix | Delete
'wrapper_class' => 'ose-google-docs-' . $type,
[123] Fix | Delete
];
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
/** inline @inheritDoc */
[127] Fix | Delete
public function modifyResponse( array $response = [])
[128] Fix | Delete
{
[129] Fix | Delete
return $this->fakeResponse();
[130] Fix | Delete
}
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function