From 1127a52138924d7eac04e75c0d710ababd8f4c44 Mon Sep 17 00:00:00 2001 From: Aneesh Devasthale Date: Wed, 20 Nov 2024 11:00:26 -0800 Subject: [PATCH 1/5] Add DIFM-specific functionality for WoA sites --- .../changelog/add-wpcom-difm-functions | 4 + .../src/class-jetpack-mu-wpcom.php | 1 + .../wpcom-difm/class-wpcom-difm-express.php | 177 ++++++++++++++++++ projects/packages/sync/src/class-defaults.php | 1 + 4 files changed, 183 insertions(+) create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/add-wpcom-difm-functions create mode 100644 projects/packages/jetpack-mu-wpcom/src/features/wpcom-difm/class-wpcom-difm-express.php diff --git a/projects/packages/jetpack-mu-wpcom/changelog/add-wpcom-difm-functions b/projects/packages/jetpack-mu-wpcom/changelog/add-wpcom-difm-functions new file mode 100644 index 0000000000000..82bc442049813 --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/add-wpcom-difm-functions @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Adds DIFM-specific functionality for WoA sites diff --git a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php index 2d90701c8e3f1..b02683face54c 100644 --- a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php +++ b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php @@ -110,6 +110,7 @@ public static function load_features() { require_once __DIR__ . '/features/wpcom-admin-dashboard/wpcom-admin-dashboard.php'; require_once __DIR__ . '/features/wpcom-block-editor/class-jetpack-wpcom-block-editor.php'; require_once __DIR__ . '/features/wpcom-block-editor/functions.editor-type.php'; + require_once __DIR__ . '/features/wpcom-difm/class-wpcom-difm-express.php'; require_once __DIR__ . '/features/wpcom-logout/wpcom-logout.php'; require_once __DIR__ . '/features/wpcom-themes/wpcom-theme-fixes.php'; diff --git a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-difm/class-wpcom-difm-express.php b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-difm/class-wpcom-difm-express.php new file mode 100644 index 0000000000000..86f4f1dd3e13d --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-difm/class-wpcom-difm-express.php @@ -0,0 +1,177 @@ + $submenu_items ) { + if ( $parent_slug === $wpcom_hosting_menu_slug ) { + foreach ( $submenu_items as $submenu_item ) { + if ( self::should_remove_submenu( $submenu_item[2] ) ) { + remove_submenu_page( $parent_slug, $submenu_item[2] ); + } + } + } + } + } + } + + /** + * Hide dashboard content if the DIFM sticker is active. + */ + public static function hide_dashboard_content() { + echo ''; + } + + /** + * Show an admin notice if the DIFM sticker is active. + */ + public static function show_difm_admin_notice() { + $domain = wp_parse_url( home_url(), PHP_URL_HOST ); + + $response = Client::wpcom_json_api_request_as_user( "sites/$domain/do-it-for-me/website-content" ); + if ( is_wp_error( $response ) ) { + return; + } + + $result = json_decode( wp_remote_retrieve_body( $response ) ); + + $is_website_content_submitted = isset( $result->is_website_content_submitted ) ? $result->is_website_content_submitted : null; + + if ( $is_website_content_submitted ) : ?> +
+ Site Build in Progress +

+

+ +

Contact Support if you have any questions.', 'jetpack-mu-wpcom' ), 'mailto:services+express@wordpress.com' ) ); ?>

+
+ +
+ Site Build in Progress +

+

+ +
+ + Contact Support if you have any questions.', 'jetpack-mu-wpcom' ), 'mailto:services+express@wordpress.com' ) ); ?> +

+

+ "> +

+
+ Date: Thu, 21 Nov 2024 20:31:46 -0800 Subject: [PATCH 2/5] changelog --- projects/packages/sync/changelog/add-wpcom-difm-functions | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/packages/sync/changelog/add-wpcom-difm-functions diff --git a/projects/packages/sync/changelog/add-wpcom-difm-functions b/projects/packages/sync/changelog/add-wpcom-difm-functions new file mode 100644 index 0000000000000..08c02d70427f9 --- /dev/null +++ b/projects/packages/sync/changelog/add-wpcom-difm-functions @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Adds difm_lite_site_options to the default_options_whitelist From 0151d9eebeac5df6404a74a2752c4fca545a9a47 Mon Sep 17 00:00:00 2001 From: Aneesh Devasthale Date: Fri, 22 Nov 2024 12:24:26 -0800 Subject: [PATCH 3/5] fix condition --- .../src/features/wpcom-difm/class-wpcom-difm-express.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-difm/class-wpcom-difm-express.php b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-difm/class-wpcom-difm-express.php index 86f4f1dd3e13d..b6ba18c594d25 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-difm/class-wpcom-difm-express.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-difm/class-wpcom-difm-express.php @@ -145,7 +145,7 @@ public static function show_difm_admin_notice() { $result = json_decode( wp_remote_retrieve_body( $response ) ); - $is_website_content_submitted = isset( $result->is_website_content_submitted ) ? $result->is_website_content_submitted : null; + $is_website_content_submitted = $result->is_website_content_submitted ?? false; if ( $is_website_content_submitted ) : ?>
From 96bb5f554cc0af91a97554cdfe17205eaa2282c2 Mon Sep 17 00:00:00 2001 From: Aneesh Devasthale Date: Fri, 22 Nov 2024 12:38:28 -0800 Subject: [PATCH 4/5] add option to test --- .../jetpack/tests/php/sync/test_class.jetpack-sync-options.php | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-options.php b/projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-options.php index 997fe53675e83..e2b36277df26c 100644 --- a/projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-options.php +++ b/projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-options.php @@ -279,6 +279,7 @@ public function test_sync_default_options() { 'jetpack_waf_share_data' => true, 'jetpack_waf_share_debug_data' => false, 'jetpack_waf_automatic_rules_last_updated_timestamp' => 0, + 'difm_lite_site_options' => array(), ); $theme_mod_key = 'theme_mods_' . get_option( 'stylesheet' ); From 7ecd013312e21419b54a5a6c9813ecb466557a50 Mon Sep 17 00:00:00 2001 From: Aneesh Devasthale Date: Fri, 22 Nov 2024 12:39:32 -0800 Subject: [PATCH 5/5] changelog --- projects/plugins/jetpack/changelog/add-wpcom-difm-functions | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/add-wpcom-difm-functions diff --git a/projects/plugins/jetpack/changelog/add-wpcom-difm-functions b/projects/plugins/jetpack/changelog/add-wpcom-difm-functions new file mode 100644 index 0000000000000..56b462dc86d95 --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-wpcom-difm-functions @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +Adds difm_lite_site_options to the default_options_whitelist