Skip to content

Commit

Permalink
Merge pull request #884 from helsingborg-stad/fix/content-types-crash…
Browse files Browse the repository at this point in the history
…ing-404

fix: resolve issue where a 404 missing a content type created a fatal…
  • Loading branch information
Anna committed Mar 8, 2024
2 parents 3b4ca15 + bd67e2a commit faf77a1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions library/Helper/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,16 @@ protected static function processContentTypeFile(string $filename, bool $include
*/
public static function getContentType(string $type = '')
{
if (!$type) {
$type = self::getCurrentType();
if (!$type && !$type = self::getCurrentType()) {
return false;
}

$contentTypeInstance = false;
$contentTypeKey = get_option("options_contentType_{$type}", false);

if ($contentTypeKey) {
$contentTypeInstance = self::getContentTypeInstance($contentTypeKey);
return self::getContentTypeInstance($contentTypeKey);
}

return $contentTypeInstance;
return false;
}

/**
Expand Down Expand Up @@ -212,7 +210,7 @@ public static function hasAnyContentType(string $type = ''): bool
return false;
}

public static function getCurrentType(): string
public static function getCurrentType(): ?string
{
return \Municipio\Helper\WP::getCurrentPostType();
}
Expand Down

0 comments on commit faf77a1

Please sign in to comment.