From e1e32057990e8404f588d48ad9432ef35e9014cc Mon Sep 17 00:00:00 2001 From: qzya <48480392+qzya@users.noreply.github.com> Date: Mon, 24 Jun 2024 23:16:00 +0300 Subject: [PATCH 1/2] fix wp cover block filtering --- classes/Tools/Storage/StorageContentHooks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Tools/Storage/StorageContentHooks.php b/classes/Tools/Storage/StorageContentHooks.php index 0ae729f7..87d4c4fe 100644 --- a/classes/Tools/Storage/StorageContentHooks.php +++ b/classes/Tools/Storage/StorageContentHooks.php @@ -195,7 +195,7 @@ private function processCoverBlock($id, $block_content) { continue; } - $block_content = str_replace($class[1], "{$class[1]} mcloud-attachment-{$id}", $block_content); + $block_content = preg_replace("/[\s'\"]" . $class[1] . "[\s'\"]/m", "{$class[1]} mcloud-attachment-{$id}", $block_content); } } @@ -1223,4 +1223,4 @@ public function calculateSrcSet($sources, $size_array, $image_src, $image_meta, return $newSources; } //endregion -} \ No newline at end of file +} From 3af4975f84986a85790c7d2c3d23c238f6ed2593 Mon Sep 17 00:00:00 2001 From: qzya <48480392+qzya@users.noreply.github.com> Date: Tue, 25 Jun 2024 18:56:07 +0300 Subject: [PATCH 2/2] fix WP Cover Block class filtering --- classes/Tools/Storage/StorageContentHooks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Tools/Storage/StorageContentHooks.php b/classes/Tools/Storage/StorageContentHooks.php index 87d4c4fe..e7819e82 100644 --- a/classes/Tools/Storage/StorageContentHooks.php +++ b/classes/Tools/Storage/StorageContentHooks.php @@ -191,11 +191,11 @@ private function processCoverBlock($id, $block_content) { continue; } - if (strpos($class[1], 'wp-block-cover') === false) { + if ( !preg_match("/wp-block-cover(\s|$)/ui", $class[1]) ) { continue; } - $block_content = preg_replace("/[\s'\"]" . $class[1] . "[\s'\"]/m", "{$class[1]} mcloud-attachment-{$id}", $block_content); + $block_content = preg_replace("/([\s'\"])({$class[1]})([\s'\"])/ui", "$1$2 mcloud-attachment-{$id} $3", $block_content); } }