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.../vendor/wpdevelo.../embera/src/Embera/Html
File: ResponsiveEmbeds.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* ResponsiveEmbeds.php
[2] Fix | Delete
*
[3] Fix | Delete
* @package Embera
[4] Fix | Delete
* @author Michael Pratt <yo@michael-pratt.com>
[5] Fix | Delete
* @link http://www.michael-pratt.com/
[6] Fix | Delete
*
[7] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[8] Fix | Delete
* file that was distributed with this source code.
[9] Fix | Delete
*/
[10] Fix | Delete
[11] Fix | Delete
namespace Embera\Html;
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Class Responsable of converting html into responsive html.
[15] Fix | Delete
*/
[16] Fix | Delete
class ResponsiveEmbeds
[17] Fix | Delete
{
[18] Fix | Delete
/**
[19] Fix | Delete
* Attempts to transform the html key of the response
[20] Fix | Delete
* with a responsive alternative.
[21] Fix | Delete
*
[22] Fix | Delete
* @param array $response
[23] Fix | Delete
* @return array
[24] Fix | Delete
*/
[25] Fix | Delete
public function transform(array $response)
[26] Fix | Delete
{
[27] Fix | Delete
if (!empty($response['html']) && isset($response['embera_provider_name'], $response['type'])) {
[28] Fix | Delete
$response['html_pre_responsive'] = $response['html'];
[29] Fix | Delete
$response['html'] = $this->removeWidthHeightAttributes($response['html']);
[30] Fix | Delete
$response['html'] = $this->removeWidthHeightStyles($response['html']);
[31] Fix | Delete
$response['html'] = $this->addClasses($response['html'], strtolower($response['type']));
[32] Fix | Delete
$response['html'] = $this->wrapInsideDiv($response['html'], strtolower($response['type']), $response['embera_provider_name']);
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
return $response;
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Removes the Width and Height attributes from a tag
[40] Fix | Delete
*
[41] Fix | Delete
* @param string $text
[42] Fix | Delete
* @return string
[43] Fix | Delete
*
[44] Fix | Delete
*/
[45] Fix | Delete
protected function removeWidthHeightAttributes($text)
[46] Fix | Delete
{
[47] Fix | Delete
return preg_replace('~(width|height)="\d*"\s~i', '', $text);
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* Removes the Width/Height from inline styles
[52] Fix | Delete
*
[53] Fix | Delete
* @param string $text
[54] Fix | Delete
* @return string
[55] Fix | Delete
*/
[56] Fix | Delete
protected function removeWidthHeightStyles($text)
[57] Fix | Delete
{
[58] Fix | Delete
return preg_replace('~(width|height|max-width|max-height):[0-9 ]+[a-z]{2};?~i', '',$text);
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Adds item classes to an html tag
[63] Fix | Delete
*
[64] Fix | Delete
* @param string $text
[65] Fix | Delete
* @param string $type
[66] Fix | Delete
* @return string
[67] Fix | Delete
*/
[68] Fix | Delete
protected function addClasses($text, $type)
[69] Fix | Delete
{
[70] Fix | Delete
$class= 'embera-embed-responsive-item embera-embed-responsive-item-' . $type;
[71] Fix | Delete
if (preg_match('~class="(.+?)"~i', $text)) {
[72] Fix | Delete
return preg_replace('~class="(.+?)"~i', 'class="$1 ' . $class . '"', $text);
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
foreach (['iframe', 'img'] as $tag) {
[76] Fix | Delete
if (preg_match('~<' . $tag . '~i', $text)) {
[77] Fix | Delete
return str_ireplace('<' . $tag, '<' . $tag . ' class="' . $class . '"', $text);
[78] Fix | Delete
}
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
return $text;
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Wraps the whole html inside a new div with custom attributes.
[86] Fix | Delete
*
[87] Fix | Delete
* @param string $text
[88] Fix | Delete
* @param string $type
[89] Fix | Delete
* @param string $providerName
[90] Fix | Delete
* @return string
[91] Fix | Delete
*/
[92] Fix | Delete
protected function wrapInsideDiv($text, $type, $providerName)
[93] Fix | Delete
{
[94] Fix | Delete
$providerName = strtolower($providerName);
[95] Fix | Delete
return '<div class="embera-embed-responsive embera-embed-responsive-' . $type . ' embera-embed-responsive-provider-' . $providerName . '">' . $text . '</div>';
[96] Fix | Delete
}
[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