Skip to content

Commit 5240c9d

Browse files
committed
Compatible PHP8.x
1 parent d4c39a0 commit 5240c9d

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

Helper/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getConfigModule($cfg='', $value=null)
4040
{
4141
$values = $this->configModule;
4242
if( !$cfg ) return $values;
43-
$config = explode('/', $cfg);
43+
$config = explode('/', (string) $cfg);
4444
$end = count($config) - 1;
4545
foreach ($config as $key => $vl) {
4646
if( isset($values[$vl]) ){

Plugin/LazyResponse.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public function beforeSendResponse(Http $response)
7272
$exclude = $this->helper->getConfigModule('general/exclude_img');
7373
// $exclude = 'product-image-photo';
7474
if($exclude){
75-
$exclude = str_replace(' ', '', $exclude);
76-
$this->exclude = explode(',', $exclude);
75+
$exclude = str_replace(' ', '', (string) $exclude);
76+
$this->exclude = explode(',', (string) $exclude);
7777
}
7878

7979
$placeholder = $this->helper->getConfigModule('general/placeholder');
@@ -109,9 +109,9 @@ public function addBodyClass( $content, $class )
109109
'/<body([\s\S]*?)(?:class="(.*?)")([\s\S]*?)?([^>]*)>/',
110110
function($match) use ($class) {
111111
if($match[2]){
112-
return $lazy = str_replace('class="', 'class="' . $class . ' ', $match[0]);
112+
return $lazy = str_replace('class="', 'class="' . $class . ' ', (string) $match[0]);
113113
}else {
114-
return str_replace('<body ', '<body class="' . $class . '" ', $match[0]);
114+
return str_replace('<body ', '<body class="' . $class . '" ', (string) $match[0]);
115115
}
116116
},
117117
$content
@@ -169,7 +169,7 @@ public function addLazyloadPlaceholder( $content, $addJs=false )
169169

170170
public function isExclude($class)
171171
{
172-
if(is_string($class)) $class = explode(' ', $class);
172+
if(is_string($class)) $class = explode(' ', (string) $class);
173173
$excludeExist = array_intersect($this->exclude, $class);
174174
return !empty($excludeExist);
175175
}
@@ -221,15 +221,15 @@ function($match) use ($placeholder) {
221221

222222
if(stripos($match[0], ' class="') !== false){
223223
if( $this->isExclude($match[1]) ) return $match[0];
224-
$lazy = str_replace(' class="', ' class="lazyload ', $match[0]);
224+
$lazy = str_replace(' class="', ' class="lazyload ', (string) $match[0]);
225225
}else {
226-
$lazy = str_replace('<img ', '<img class="lazyload" ', $match[0]);
226+
$lazy = str_replace('<img ', '<img class="lazyload" ', (string) $match[0]);
227227
}
228228

229229
/* break if exist data-src */
230230
// if(strpos($lazy, ' data-src="')) return $lazy;
231231

232-
return str_replace(' src="', ' src="' .$placeholder. '" data-src="', $lazy);
232+
return str_replace(' src="', ' src="' .$placeholder. '" data-src="', (string) $lazy);
233233
},
234234
$content
235235
);
@@ -246,15 +246,15 @@ function($match) use ($placeholder) {
246246

247247
if(stripos($match[0], ' class="') !== false){
248248
if( $this->isExclude($match[1]) ) return $match[0];
249-
$lazy = str_replace(' class=\"', ' class=\"lazyload ', $match[0]);
249+
$lazy = str_replace(' class=\"', ' class=\"lazyload ', (string) $match[0]);
250250
}else {
251-
$lazy = str_replace('<img ', '<img class=\"lazyload\" ', $match[0]);
251+
$lazy = str_replace('<img ', '<img class=\"lazyload\" ', (string) $match[0]);
252252
}
253253

254254
/* break if exist data-src */
255255
// if(strpos($lazy, ' data-src=\"')) return $lazy;
256256

257-
return str_replace(' src=\"', ' src=\"' . $placeholder . '\" data-src=\"', $lazy);
257+
return str_replace(' src=\"', ' src=\"' . $placeholder . '\" data-src=\"', (string) $lazy);
258258
},
259259
$content
260260
);
@@ -263,7 +263,7 @@ function($match) use ($placeholder) {
263263
/* Not Placeholder so can't keep layout original while loading */
264264
public function addLazyloadAll( $content, $addJs=false )
265265
{
266-
$placeholder = str_replace(['$width', '$height'], [1, 1], $this->placeholder);
266+
$placeholder = str_replace(['$width', '$height'], [1, 1], (string) $this->placeholder);
267267

268268
$content = $this->addLazyloadImage($content, $placeholder);
269269

0 commit comments

Comments
 (0)