Skip to content

Commit

Permalink
Merge pull request #437 from infinum/fix/featching-theme-options-ids-…
Browse files Browse the repository at this point in the history
…for-templates

Fix fetching of ids for partials of provided templates
  • Loading branch information
piqusy authored Nov 21, 2024
2 parents c7c54bd + 9ccf913 commit 7a6425e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/InitSetup/tailwind/theme/404.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
get_header();

// Header reusable block.
$partialId = get_option(ThemeOptions::OPTION_NAME)['fourOhFour'] ?? '';
ThemeOptions::renderPartial($partialId);
ThemeOptions::renderPartial(ThemeOptions::getOption('fourOhFour'));

get_footer();
3 changes: 1 addition & 2 deletions src/InitSetup/tailwind/theme/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
<footer class="layout-base">
<?php
// Footer reusable block.
$footerPartialId = get_option(ThemeOptions::OPTION_NAME)['footer'] ?? '';
ThemeOptions::renderPartial($footerPartialId);
ThemeOptions::renderPartial(ThemeOptions::getOption('footer'));
?>
</footer>

Expand Down
3 changes: 1 addition & 2 deletions src/InitSetup/tailwind/theme/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@

<?php
// Header reusable block.
$headerPartialId = get_option(ThemeOptions::OPTION_NAME)['header'] ?? '';
ThemeOptions::renderPartial($headerPartialId);
ThemeOptions::renderPartial(ThemeOptions::getOption('header'));
?>

<main class="main-content layout-base" id="main-content">
20 changes: 20 additions & 0 deletions src/ThemeOptions/ThemeOptionsExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ static function ($block) {
echo Helpers::ensureString($blocksToRenderRendered); // phpcs:ignore
}

/**
* Get theme option.
*
* @param string $item Item to get.
*
* @return string
*/
public static function getOption(string $item): string
{
$options = \get_option(ThemeOptions::OPTION_NAME);

if (!Helpers::isJson($options)) {
return '';
}

$options = \json_decode($options, true);

return $options[$item] ?? '';
}

/**
* Get reusable blocks patterns.
*
Expand Down

0 comments on commit 7a6425e

Please sign in to comment.