diff --git a/src/ThemeOptions/ThemeOptionsExample.php b/src/ThemeOptions/ThemeOptionsExample.php index dd087225..be299c3c 100644 --- a/src/ThemeOptions/ThemeOptionsExample.php +++ b/src/ThemeOptions/ThemeOptionsExample.php @@ -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. *