Skip to content

Commit 5b5a185

Browse files
committed
fix: add script namespace attribute back
1 parent 30fa50a commit 5b5a185

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/AdminNotices.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,20 @@ public static function setUpNotices(): void
202202
public static function enqueueScripts(): void
203203
{
204204
$namespace = self::$namespace;
205-
$handle = "$namespace-admin-notices";
205+
$handle = "stellarwp-$namespace-admin-notices";
206206
$version = filemtime(__DIR__ . '/resources/admin-notices.js');
207207

208+
// Add the namespace to the script tag
209+
add_filter('script_loader_tag', static function ($tag, $tagHandle) use ($handle, $namespace) {
210+
if ($handle !== $tagHandle) {
211+
return $tag;
212+
}
213+
214+
$replacement = "<script data-stellarwp-namespace='$namespace'";
215+
216+
return str_replace('<script', $replacement, $tag);
217+
}, 10, 2);
218+
208219
wp_enqueue_script(
209220
$handle,
210221
self::$packageUrl . '/src/resources/admin-notices.js',

0 commit comments

Comments
 (0)