From a2066517e654deee48649fa53039c673baad3e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Thu, 19 Sep 2024 11:30:26 +0200 Subject: [PATCH 1/2] updating bug for theme options --- CHANGELOG.md | 6 ++++++ src/ThemeOptions/ThemeOptionsExample.php | 27 ++---------------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d63b2a5..04f9ce71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/). +## [9.1.4] + +### Fixed +- Theme options settings are now saved as string and not as object. + ## [9.1.3] ### Fixed @@ -648,6 +653,7 @@ Init setup [Unreleased]: https://github.com/infinum/eightshift-libs/compare/main...HEAD +[9.1.4]: https://github.com/infinum/eightshift-libs/compare/9.1.3...9.1.4 [9.1.3]: https://github.com/infinum/eightshift-libs/compare/9.1.2...9.1.3 [9.1.2]: https://github.com/infinum/eightshift-libs/compare/9.1.1...9.1.2 [9.1.1]: https://github.com/infinum/eightshift-libs/compare/9.1.0...9.1.1 diff --git a/src/ThemeOptions/ThemeOptionsExample.php b/src/ThemeOptions/ThemeOptionsExample.php index 5a5b06d5..2f8a69a1 100644 --- a/src/ThemeOptions/ThemeOptionsExample.php +++ b/src/ThemeOptions/ThemeOptionsExample.php @@ -43,35 +43,12 @@ public function register(): void */ public function addRbHfSettings(): void { - $default = [ - 'header' => null, - 'footer' => null, - ]; - - $schema = [ - 'type' => 'object', - 'properties' => [ - 'header' => [ - 'type' => 'string', - ], - 'footer' => [ - 'type' => 'string', - ], - 'fourOhFour' => [ - 'type' => 'string', - ], - ], - ]; - \register_setting( 'options', self::OPTION_NAME, [ - 'type' => 'object', - 'default' => $default, - 'show_in_rest' => [ - 'schema' => $schema, - ], + 'type' => 'string', + 'show_in_rest' => true, ] ); } From f182f75604d02e1e843d34b26134128f424a3ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ru=C5=BEevi=C4=87?= Date: Thu, 19 Sep 2024 11:34:58 +0200 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Goran Alković <77000136+goranalkovic-infinum@users.noreply.github.com> --- src/ThemeOptions/ThemeOptionsExample.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ThemeOptions/ThemeOptionsExample.php b/src/ThemeOptions/ThemeOptionsExample.php index 2f8a69a1..dd087225 100644 --- a/src/ThemeOptions/ThemeOptionsExample.php +++ b/src/ThemeOptions/ThemeOptionsExample.php @@ -49,6 +49,7 @@ public function addRbHfSettings(): void [ 'type' => 'string', 'show_in_rest' => true, + 'default' => '{}', ] ); }