Skip to content

Custom Posts: Add Set as Homepage / Posts Page actions#25575

Open
crazytonyli wants to merge 9 commits into
trunkfrom
task/1981-page-specific-actions
Open

Custom Posts: Add Set as Homepage / Posts Page actions#25575
crazytonyli wants to merge 9 commits into
trunkfrom
task/1981-page-specific-actions

Conversation

@crazytonyli

Copy link
Copy Markdown
Contributor

Note

I recommend reviewing by commits. The first commit is code-format changes and can be ignored.

Description

Fix https://linear.app/a8c/issue/CMM-1981

Mirror the existing Pages: showing "Page Attributes" menus on published Pages.

Consolidate homepage and posts page tracking into a single PageRole
enum. Update HomepageSetting to track both homepage and posts page IDs
from site settings.
Add view model methods that update site settings via the WordPress core
REST API with optimistic local state updates and rollback on failure.
Show Set as Homepage, Set as Posts Page, and Set as Regular Page actions
in a Page Attributes submenu for published pages. Add a "Posts page"
badge alongside the existing "Homepage" badge using the consolidated
pageRole property.
Add currentUserCan(_:) to WordPressClient for checking user capabilities
via the cached current user data. Only show the Page Attributes submenu
when the user has the manage_options capability.
WordPressClient.fetchSiteSettings now takes a forceRefresh flag that
bypasses the loadSiteSettingsTask cache and re-runs the network fetch.
CustomPostListViewModel passes forceRefresh through from
pullToRefresh, so the Pages list picks up homepage and posts-page
assignments changed outside the app without requiring an app
relaunch.
The mark-page-roles guard checked for .custom("any"), a legacy form
that predates the .any case wordpress-rs now exposes. The All tab
uses .any, so the predicate never matched and the Homepage / Posts
page badges never rendered there.
@crazytonyli crazytonyli added this to the 27.0 milestone May 21, 2026
@crazytonyli crazytonyli requested a review from jkmassel May 21, 2026 08:42
@wpmobilebot

wpmobilebot commented May 21, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number32504
VersionPR #25575
Bundle IDorg.wordpress.alpha
Commitc09db1b
Installation URL2n9vf8k45e6h8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented May 21, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number32504
VersionPR #25575
Bundle IDcom.jetpack.alpha
Commitc09db1b
Installation URL79d6un86q89f0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@@ -0,0 +1,63 @@
import Testing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't seem to be executed by anything – it doesn't show up in Buildkite and Claude is indicating it's not wired up by the Xcode project file

/// Pass `forceRefresh: true` to bypass the cache and refetch from the server —
/// callers should do this when they know the server-side settings may have changed
/// outside this client (e.g. on pull-to-refresh).
public func fetchSiteSettings(forceRefresh: Bool = false) async throws -> SiteSettingsWithEditContext {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do this, I think we need to invalidate (or reassign) loadSiteSettingsTask (or make an async accessor?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't quite understand the issue. Do you mean explicty cancel the task like:

if forceRefresh {
  self.loadSiteSettingsTask?.cancel()
  self.loadSiteSettingsTask = ...
  ...
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would work, though it's probably better to just let the original finish and await the result?

The idea is that if the user pulls to refresh more than once, do we want multiple in-flight network requests?

value: "Settings",
comment: "Menu action to open post settings"
)
static let setHomepageSuccess = NSLocalizedString(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need three copies of this?

@crazytonyli crazytonyli requested a review from jkmassel June 10, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants