From bcf054cdcd3da7fa1ac77515bf0678ded5404f5c Mon Sep 17 00:00:00 2001 From: Tony Li Date: Tue, 8 Sep 2026 12:21:39 +1200 Subject: [PATCH] Hide the Application Passwords menu item on Simple sites WordPress.com Simple sites have no site-level REST API, so the site menu item always led to an unsupported message. Gate the row on a new `applicationPasswords` blog feature, true for self-hosted and Atomic sites, and reword the shared gate view's fallback message to say why application passwords aren't available on WordPress.com sites. --- .../WordPressData/Swift/Blog+Features.swift | 4 ++ .../Tests/WordPressDataTests/BlogTests.swift | 40 +++++++++++++++++++ RELEASE-NOTES.txt | 1 + .../ApplicationPasswordRequiredView.swift | 5 ++- .../BlogDetailsTableViewModel.swift | 4 +- 5 files changed, 51 insertions(+), 3 deletions(-) diff --git a/Modules/Sources/WordPressData/Swift/Blog+Features.swift b/Modules/Sources/WordPressData/Swift/Blog+Features.swift index 26ae02539bd5..d0a09cb556cc 100644 --- a/Modules/Sources/WordPressData/Swift/Blog+Features.swift +++ b/Modules/Sources/WordPressData/Swift/Blog+Features.swift @@ -54,6 +54,7 @@ import Foundation case publicize case shareButtons case jetpackNewsletter + case applicationPasswords } extension Blog { @@ -137,6 +138,9 @@ extension Blog { return supportsShareButtons case .jetpackNewsletter: return supportsJetpackNewsletter + case .applicationPasswords: + // Simple sites have no site-level REST API; the app reaches them through the WordPress.com account. + return !isHostedAtWPcom || isAtomic } } diff --git a/Modules/Tests/WordPressDataTests/BlogTests.swift b/Modules/Tests/WordPressDataTests/BlogTests.swift index a26436edf6a9..34e5e030d720 100644 --- a/Modules/Tests/WordPressDataTests/BlogTests.swift +++ b/Modules/Tests/WordPressDataTests/BlogTests.swift @@ -347,6 +347,46 @@ struct BlogTests { #expect(!blog.supports(.shareButtons)) } + // MARK: - Blog Feature: Application Passwords + + @Test func applicationPasswordsNotSupportedForSimpleSites() { + let blog = BlogBuilder(mainContext) + .isHostedAtWPcom() + .with(atomic: false) + .build() + + #expect(!blog.supports(.applicationPasswords)) + } + + @Test func applicationPasswordsSupportedForAtomicSites() { + let blog = BlogBuilder(mainContext) + .isHostedAtWPcom() + .with(atomic: true) + .build() + + #expect(blog.supports(.applicationPasswords)) + } + + @Test func applicationPasswordsSupportedForJetpackSites() { + let blog = BlogBuilder(mainContext) + .withAccount() + .withJetpack(version: "5.6", username: "test_user", email: "user@example.com") + .with(isHostedAtWPCom: false) + .build() + + #expect(blog.supports(.applicationPasswords)) + } + + @Test func applicationPasswordsSupportedForSelfHostedSites() { + let blog = BlogBuilder(mainContext) + .isNotHostedAtWPcom() + .with(username: "test_username") + .with(password: "test_password") + .build() + + #expect(blog.supports(.applicationPasswords)) + } + // MARK: - Blog Feature: Domains @Test func blogSupportsDomainsHostedAtWPcom() { diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 7ac8d3ff916b..fa2950268e3b 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -5,6 +5,7 @@ * [*] [internal] Stop donating screen activities as Siri predictions now that App Shortcuts cover them [#25757] * [*] Fix an issue where the Reader tab and Me tab show incorrect state after logging out [#25952] * [*] Stats: Open the latest post when tapping the Latest Post Summary card in the Insights tab [#25896] +* [*] Site menu: Hide Application Passwords for WordPress.com sites that don't support them 27.2 ----- diff --git a/WordPress/Classes/Login/ApplicationPasswordRequiredView.swift b/WordPress/Classes/Login/ApplicationPasswordRequiredView.swift index 0ac0d6870097..67243b1966f2 100644 --- a/WordPress/Classes/Login/ApplicationPasswordRequiredView.swift +++ b/WordPress/Classes/Login/ApplicationPasswordRequiredView.swift @@ -165,8 +165,9 @@ struct ApplicationPasswordRequiredView: View { static var unsupported: String { NSLocalizedString( "applicationPasswordMigration.error.unsupported", - value: "This site does not support Application Passwords.", - comment: "Error message shown when the site doesn't support Application Passwords feature" + value: + "WordPress.com sites are managed through your WordPress.com account, so application passwords aren't available.", + comment: "Message shown when a WordPress.com site can't use Application Passwords" ) } } diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsTableViewModel.swift b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsTableViewModel.swift index 514c22165e9b..7cb34cd3dffb 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsTableViewModel.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsTableViewModel.swift @@ -849,7 +849,9 @@ private extension BlogDetailsTableViewModel { secondSectionRows.append(Row.domains(viewController: viewController)) } - secondSectionRows.append(Row.applicationPasswords(viewController: viewController)) + if blog.supports(.applicationPasswords) { + secondSectionRows.append(Row.applicationPasswords(viewController: viewController)) + } // Site Settings (always included) secondSectionRows.append(Row.siteSettings(viewController: viewController))