Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not check config too early #18

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/php/Asset/AssetInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

interface AssetInterface
{
public function shouldEnqueue(): bool;
public function getHook(): string;
public function getHandle(): string;
public function getFilename(): string;
Expand Down
4 changes: 4 additions & 0 deletions source/php/Asset/AssetRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ public function register(): void

public function enqueue(): void
{
if($this->isEnabled() === false) {
return;
}

$filename = $this->getFilename();

if ($this->getType($filename) === 'css') {
Expand Down
5 changes: 5 additions & 0 deletions source/php/Asset/ContextDetection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

class ContextDetection extends AssetRegistry implements AssetInterface
{
public function shouldEnqueue(): bool
{
return $this->config->isContextCheckEnabled();
}

public function getHook(): string
{
return 'wp_enqueue_scripts';
Expand Down
5 changes: 5 additions & 0 deletions source/php/Asset/EditorHighlight.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

class EditorHighlight extends AssetRegistry implements AssetInterface
{
public function shouldEnqueue(): bool
{
return true;
}

public function getHook(): string
{
return 'mce_external_plugins';
Expand Down
5 changes: 5 additions & 0 deletions source/php/Asset/FrontendStyles.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

class FrontendStyles extends AssetRegistry implements AssetInterface
{
public function shouldEnqueue(): bool
{
return true;
}

public function getHook(): string
{
return 'wp_enqueue_scripts';
Expand Down
Loading