Skip to content

Commit d9ecfb8

Browse files
Merge pull request #18 from helsingborg-stad/fix/do-not-check-config-before-hooks
fix: do not check config too early
2 parents 83742c3 + 788681f commit d9ecfb8

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

source/php/Asset/AssetInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
interface AssetInterface
1212
{
13+
public function shouldEnqueue(): bool;
1314
public function getHook(): string;
1415
public function getHandle(): string;
1516
public function getFilename(): string;

source/php/Asset/AssetRegistry.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ public function register(): void
104104

105105
public function enqueue(): void
106106
{
107+
if($this->isEnabled() === false) {
108+
return;
109+
}
110+
107111
$filename = $this->getFilename();
108112

109113
if ($this->getType($filename) === 'css') {

source/php/Asset/ContextDetection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
class ContextDetection extends AssetRegistry implements AssetInterface
88
{
9+
public function shouldEnqueue(): bool
10+
{
11+
return $this->config->isContextCheckEnabled();
12+
}
13+
914
public function getHook(): string
1015
{
1116
return 'wp_enqueue_scripts';

source/php/Asset/EditorHighlight.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
class EditorHighlight extends AssetRegistry implements AssetInterface
88
{
9+
public function shouldEnqueue(): bool
10+
{
11+
return true;
12+
}
13+
914
public function getHook(): string
1015
{
1116
return 'mce_external_plugins';

source/php/Asset/FrontendStyles.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
class FrontendStyles extends AssetRegistry implements AssetInterface
88
{
9+
public function shouldEnqueue(): bool
10+
{
11+
return true;
12+
}
13+
914
public function getHook(): string
1015
{
1116
return 'wp_enqueue_scripts';

0 commit comments

Comments
 (0)