settings; $sections = array_map(static function (BlockModel $block): array { if ($block->name !== 'givewp/section' || !$block->innerBlocks) { return [$block->name]; } return array_map(static function (BlockModel $innerBlock): string { return $innerBlock->name; }, $block->innerBlocks->getBlocks()); }, $donationForm->blocks->getBlocks()); return [ 'design' => (string)$settings->designId, 'header' => (bool)$settings->showHeader, 'goal' => (bool)$settings->enableDonationGoal, 'image' => $this->imageTakesSpace($settings->designSettingsImageUrl, $settings->designSettingsImageStyle), 'sections' => array_values($sections), 'gateways' => count(give(DonationFormRepository::class)->getEnabledPaymentGateways($donationForm->id)), ]; } /** * Only the "above" and "center" image styles put an image element in the header flow. The * background and cover styles paint behind the text and add no height. * * @since 4.17.0 * * @param DesignSettingsImageStyle|string|null $style */ private function imageTakesSpace(?string $url, $style): bool { if (!$url || !$style instanceof DesignSettingsImageStyle) { return false; } return $style->isAbove() || $style->isCenter(); } }