Created
October 11, 2024 12:16
-
-
Save RobjS/febb76f68dbeda1c6b0d3284aa3c281b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Dxw\GovukTheme\Posts; | |
class Article | |
{ | |
public function hasBannerAsFirstBlock(): bool | |
{ | |
$firstBlockName = $this->getFirstBlockName(); | |
$result = true; | |
if (!$this->hasBannerImage() && $firstBlockName !== 'acf/hero') { | |
$result = false; | |
} | |
return apply_filters('gdsc_article_has_banner_as_first_block', $result); | |
} | |
public function hasBannerImage(): bool | |
{ | |
$firstBlock = $this->getFirstBlock(); | |
$firstBlockName = $this->getFirstBlockName(); | |
$firstBlockAlignment = $firstBlock['attrs']['align'] ?? null; | |
$result = true; | |
if ($firstBlockName !== 'core/image') { | |
$result = false; | |
} | |
if (!$firstBlockAlignment) { | |
$result = false; | |
} | |
if (!in_array($firstBlockAlignment, ['full', 'wide'])) { | |
$result = false; | |
} | |
return apply_filters('gdsc_article_has_banner_image', $result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment