From 09a813e99225007e9b0bf2e5bce5766fd10eec4e Mon Sep 17 00:00:00 2001 From: Mark Biek Date: Mon, 22 Apr 2024 09:57:35 -0400 Subject: [PATCH] Site Migration: New setting for tracking the migration flow (#36974) * Add in_site_migration_flow site option * Changelog * Refactored so we're not casting multiple times * Refactored delete vs update check --- .../89401-update-in-site-migration-setting | 4 ++++ .../class.wpcom-json-api-site-settings-endpoint.php | 13 +++++++++++++ ...s.wpcom-json-api-site-settings-v1-4-endpoint.php | 1 + 3 files changed, 18 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/89401-update-in-site-migration-setting diff --git a/projects/plugins/jetpack/changelog/89401-update-in-site-migration-setting b/projects/plugins/jetpack/changelog/89401-update-in-site-migration-setting new file mode 100644 index 0000000000000..9aef2c3f43058 --- /dev/null +++ b/projects/plugins/jetpack/changelog/89401-update-in-site-migration-setting @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +Add in_site_migration_flow to the list of available site options to update and retrieve. This will be used as part of the Site Migration on-boarding flow. diff --git a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php index 207c1467ab61b..f278ef214abf7 100644 --- a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php @@ -45,6 +45,7 @@ ), 'request_format' => array( + 'in_site_migration_flow' => '(bool) Whether the site is currently in the Site Migration signup flow.', 'blogname' => '(string) Blog name', 'blogdescription' => '(string) Blog description', 'default_pingback_flag' => '(bool) Notify blogs linked from article?', @@ -468,6 +469,7 @@ function ( $newsletter_category ) { 'enable_blocks_comments' => (bool) get_option( 'enable_blocks_comments', true ), 'highlander_comment_form_prompt' => $this->get_highlander_comment_form_prompt_option(), 'jetpack_comment_form_color_scheme' => (string) get_option( 'jetpack_comment_form_color_scheme' ), + 'in_site_migration_flow' => (bool) get_option( 'in_site_migration_flow', 0 ), ); if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { @@ -1135,6 +1137,17 @@ function ( $category_id ) { break; + case 'in_site_migration_flow': + $canonical_value = (int) (bool) $value; + if ( 0 === $canonical_value ) { + delete_option( 'in_site_migration_flow' ); + } else { + update_option( 'in_site_migration_flow', $canonical_value ); + } + + $updated[ $key ] = $canonical_value; + break; + default: // allow future versions of this endpoint to support additional settings keys. if ( has_filter( 'site_settings_endpoint_update_' . $key ) ) { diff --git a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-v1-4-endpoint.php b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-v1-4-endpoint.php index 84cc8a6b3338d..e001da782ed1b 100644 --- a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-v1-4-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-v1-4-endpoint.php @@ -35,6 +35,7 @@ ), 'request_format' => array( + 'in_site_migration_flow' => '(bool) Whether the site is currently in the Site Migration signup flow.', 'blogname' => '(string) Blog name', 'blogdescription' => '(string) Blog description', 'default_pingback_flag' => '(bool) Notify blogs linked from article?',