Skip to content

Add subscription folders - #599

Merged
akirk merged 8 commits into
mainfrom
subscription-folders
Mar 24, 2026
Merged

Add subscription folders#599
akirk merged 8 commits into
mainfrom
subscription-folders

Conversation

@akirk

@akirk akirk commented Mar 22, 2026

Copy link
Copy Markdown
Owner

This uses the existing friends-virtual-user taxonomy hierarchy to let you organize subscriptions into folders. Folders are parent terms, subscriptions are moved by changing their parent — no new tables, no slow meta queries.

On the author page there's now a dropdown to move a subscription into a folder or create a new one. The friends-list block has a new "Grouped by Folder" mode that renders folders as collapsible sections. Starred subscriptions are still shown separately as a quick-access list.

The folder queries filter the already-cached all_subscriptions() result in PHP, so there's no extra database hit. A lightweight User_Query_Result container avoids the WP_User_Query pitfall where creating a new instance loads all WordPress users.

Changes:

  • Make friends-virtual-user taxonomy hierarchical
  • Subscription: get_folder(), move_to_folder(), create_folder(), get_folders(), is_folder()
  • User_Query: subscriptions_in_folder(), unfoldered_subscriptions() using in-memory filtering
  • User_Query_Result container class for filtered results
  • Folder selector dropdown on author header chips
  • "Grouped by Folder" mode for friends-list block with collapsible <details> sections
  • Folder chip shown in author header
  • AJAX handlers for move-to-folder and create-folder
  • Exclude folder terms from subscription queries
  • Unit tests for all folder operations
@github-actions

Copy link
Copy Markdown
Contributor

Test this PR in WordPress Playground

You can test this pull request directly in WordPress Playground:

Launch WordPress Playground

This will install and activate the plugin with the changes from this PR.

Base automatically changed from add-block-theme to main March 23, 2026 15:12
akirk added 6 commits March 23, 2026 16:40
Subscriptions can now be organized into folders using the existing
friends-virtual-user taxonomy hierarchy. Folders are parent terms
with an is_folder meta flag, and subscriptions are moved by setting
their parent term ID.

Changes:
- Make friends-virtual-user taxonomy hierarchical
- Add Subscription methods: get_folder(), move_to_folder(),
  create_folder(), get_folders(), is_folder()
- Add User_Query methods: subscriptions_in_folder(),
  unfoldered_subscriptions() — both filter the cached
  all_subscriptions() result in PHP, no extra DB queries
- Add folder attribute to friends-list block with editor dropdown
- Add AJAX handlers for move-to-folder and create-folder
- Show folder chip in author-header chips
- Localize folder data for the block editor
- Folder selector dropdown on author header to move subscriptions
  into folders or create new ones via JS prompt
- "Grouped by Folder" mode for friends-list block renders folders
  as collapsible <details> sections with subscription counts
- Unfoldered subscriptions shown under "Uncategorized" section
- Starred subscriptions kept as separate quick-access list
- Exclude folder terms from subscription queries
- Fix nonce mismatch for create-folder AJAX
Tests cover:
- Creating folders and subfolders
- Moving subscriptions to folders and back to root
- Querying subscriptions by folder
- Querying unfoldered subscriptions
- Folders excluded from subscription lists
- get_folders returns only folder terms
- Subscription terms are not folders
- Taxonomy is hierarchical
- Friends-list block renders folder view
- Friends-list block filters by specific folder
User_Query extends WP_User_Query, so creating a new instance always
loads all WordPress users. The folder filter methods were adding
filtered subscriptions on top of that.

Fix by using a lightweight User_Query_Result container for
subscriptions_in_folder() and unfoldered_subscriptions() that only
holds the filtered results without triggering WP_User_Query.
- Widget_Friends_List shows folders as collapsible accordion sections
  with unfoldered subscriptions in a separate section below
- Author header template shows folder selector dropdown for
  subscriptions (same UI as block theme)
- Remove WP_User_Query type hint from list_friends() to accept
  User_Query_Result from folder queries
@akirk
akirk force-pushed the subscription-folders branch from 7e5b127 to a96f477 Compare March 23, 2026 15:44
akirk added 2 commits March 23, 2026 16:48
ActivityPub 7.6.0 deprecated Followers::count_followers() in favour of
Followers::count(). Add a single compatibility shim in the ActivityPub
feed parser and route both call sites through it.
- Add form(), update(), defaults() to Widget_Friends_List with the same
  Display (subscriptions/starred/folders) and Folder filter options the
  block has; also saves/restores the widget title
- Skip folder terms in get_list_items() so they never render as list items
- Fall back to user_login when display_name is empty (block and widget)
@akirk
akirk merged commit 99045a1 into main Mar 24, 2026
25 checks passed
@akirk
akirk deleted the subscription-folders branch March 24, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant