We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f5875b6 commit 852c688Copy full SHA for 852c688
1 file changed
Plugin/AddCmsBlockIdentifierToMarkup.php
@@ -36,12 +36,15 @@ public function beforeSave(
36
BlockRepositoryInterface $subject,
37
BlockInterface $block
38
): array {
39
- if ($this->moduleConfig->isBlockIdentifierMarkupEnabled() && $block->getIdentifier()) {
+ if ($this->moduleConfig->isBlockIdentifierMarkupEnabled()
40
+ && ($identifier = $block->getIdentifier())
41
+ && ($content = $block->getContent())
42
+ ) {
43
$block->setContent(
44
substr_replace(
- $block->getContent(),
- " data-{$this->moduleConfig->getBlockIdentifierDataAttributeName()}=\"{$block->getIdentifier()}\"",
- strpos($block->getContent(), ' '),
45
+ $content,
46
+ ' data-' . $this->moduleConfig->getBlockIdentifierDataAttributeName() . '="' . $identifier . '"',
47
+ strpos($content, '<div') + 4,
48
0
49
)
50
);
0 commit comments