From 3491c6b7dc287ab194fe66bbd5c2acb0d136872c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alba=20Rinc=C3=B3n?= Date: Wed, 14 Aug 2024 14:37:30 +0200 Subject: [PATCH] Fix `store-title` endpoint - Pass default value to `get_option` (#50673) * Pass default value to get_option * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions --- plugins/woocommerce/changelog/50673-fix-store-title-error | 4 ++++ plugins/woocommerce/src/Admin/API/AI/StoreTitle.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 plugins/woocommerce/changelog/50673-fix-store-title-error diff --git a/plugins/woocommerce/changelog/50673-fix-store-title-error b/plugins/woocommerce/changelog/50673-fix-store-title-error new file mode 100644 index 00000000000..e9808147440 --- /dev/null +++ b/plugins/woocommerce/changelog/50673-fix-store-title-error @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +Fix `store-title` endpoint - Pass default value to `get_option`. \ No newline at end of file diff --git a/plugins/woocommerce/src/Admin/API/AI/StoreTitle.php b/plugins/woocommerce/src/Admin/API/AI/StoreTitle.php index 523b89558e1..fd4447bb899 100644 --- a/plugins/woocommerce/src/Admin/API/AI/StoreTitle.php +++ b/plugins/woocommerce/src/Admin/API/AI/StoreTitle.php @@ -86,8 +86,8 @@ class StoreTitle extends AIEndpoint { ); } - $store_title = html_entity_decode( get_option( self::STORE_TITLE_OPTION_NAME ) ); - $previous_ai_generated_title = html_entity_decode( get_option( self::AI_STORE_TITLE_OPTION_NAME ) ); + $store_title = html_entity_decode( get_option( self::STORE_TITLE_OPTION_NAME, '' ) ); + $previous_ai_generated_title = html_entity_decode( get_option( self::AI_STORE_TITLE_OPTION_NAME, '' ) ); if ( strtolower( trim( self::DEFAULT_TITLE ) ) === strtolower( trim( $store_title ) ) || ( ! empty( $store_title ) && $previous_ai_generated_title !== $store_title ) ) { return rest_ensure_response( array( 'ai_content_generated' => false ) );