Skip to content

Add Posts and Replies block for author archives#3035

Closed
pfefferle wants to merge 14 commits intotrunkfrom
add/posts-and-replies-block
Closed

Add Posts and Replies block for author archives#3035
pfefferle wants to merge 14 commits intotrunkfrom
add/posts-and-replies-block

Conversation

@pfefferle
Copy link
Copy Markdown
Member

Fixes #1213

Proposed changes:

  • Add a new activitypub/posts-and-replies block that renders a tabbed interface on author archive pages, similar to Mastodon's profile view.
  • The "Posts" tab excludes replies (posts containing the activitypub/reply block) while "Posts & Replies" shows all posts.
  • Uses the Interactivity API for instant client-side tab switching with both tab contents pre-rendered server-side.
  • Updates the Fediverse author archive template to use the new block instead of core/query.

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Start wp-env with npm run env-start.
  • Go to the Site Editor and verify the "Author Archive (Fediverse)" template now includes the Posts and Replies block.
  • Visit an author archive page (e.g., /author/admin/).
  • Verify two tabs render: "Posts" and "Posts & Replies".
  • Click between tabs — switching should be instant (no page reload).
  • Create a post that starts with the activitypub/reply block (Federated Reply).
  • Verify the "Posts" tab excludes that reply post, while "Posts & Replies" shows it.
  • Verify pagination works correctly with pretty permalinks.
  • Verify screen reader announces tab selection changes (aria-selected updates dynamically).

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Add a "Posts and Replies" block for author archives that shows tabs to filter between posts and replies, similar to Mastodon's profile view.

Introduce a new `activitypub/posts-and-replies` block that renders a
tabbed interface on author archive pages, similar to Mastodon's profile
view. The "Posts" tab excludes replies (posts containing the
`activitypub/reply` block) while "Posts & Replies" shows all posts.

Uses the Interactivity API for client-side tab switching with both
tab contents pre-rendered server-side. Includes ARIA tablist/tab/tabpanel
roles with dynamic aria-selected for accessibility.

Closes #1213
Copilot AI review requested due to automatic review settings March 14, 2026 11:33
@pfefferle pfefferle added the Enhancement New feature or request label Mar 14, 2026
@pfefferle pfefferle self-assigned this Mar 14, 2026
@pfefferle pfefferle added the Enhancement New feature or request label Mar 14, 2026
@pfefferle pfefferle requested a review from a team March 14, 2026 11:33
@github-actions github-actions Bot added the [Focus] Editor Changes to the ActivityPub experience in the block editor label Mar 14, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new activitypub/posts-and-replies block for author archives that provides a Mastodon-like tabbed “Posts” vs “Posts & Replies” view, and updates the Fediverse author archive template to use it.

Changes:

  • Introduces a dynamic (PHP-rendered) Posts & Replies block with Interactivity API-powered tab switching.
  • Adds editor UI (posts-per-page control) and front-end styles for the new block.
  • Registers the new block and swaps the author archive template from core/query to the new block.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/posts-and-replies/view.js Interactivity store and click handler for switching tabs.
src/posts-and-replies/style.scss Styles for tabs, post list, and pagination.
src/posts-and-replies/render.php Server-side rendering + WP_Query logic for both tab contents.
src/posts-and-replies/index.js Block registration entrypoint.
src/posts-and-replies/edit.js Editor inspector control + placeholder UI.
src/posts-and-replies/block.json Block metadata, attributes, interactivity support, assets, render file.
includes/class-blocks.php Registers the block and updates the Fediverse author archive template to use it.
build/posts-and-replies/view.js Built view script module.
build/posts-and-replies/view.asset.php Built asset metadata for view script.
build/posts-and-replies/style-index.css Built front-end CSS.
build/posts-and-replies/style-index-rtl.css Built RTL front-end CSS.
build/posts-and-replies/render.php Built render template (copy of src render).
build/posts-and-replies/index.js Built editor script bundle.
build/posts-and-replies/index.asset.php Built asset metadata for editor script.
build/posts-and-replies/block.json Built block metadata.
.github/changelog/3035-from-description Changelog entry for the new feature.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/posts-and-replies/view.js
Comment thread src/posts-and-replies/render.php Outdated
Comment thread src/posts-and-replies/render.php Outdated
Comment thread src/posts-and-replies/render.php Outdated
Comment thread src/posts-and-replies/render.php
Comment thread src/posts-and-replies/render.php
Comment thread src/posts-and-replies/render.php
Comment thread src/posts-and-replies/render.php
Comment thread src/posts-and-replies/render.php Outdated
Comment thread src/posts-and-replies/style.scss Outdated
pfefferle and others added 8 commits March 14, 2026 15:46
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Replace hardcoded post list markup with the core/post-template
inner blocks pattern. Users can now customize which elements
appear per post (title, date, excerpt, featured image, etc.)
by adding or removing blocks in the editor.

- Editor shows InnerBlocks with a default template of post-title
  (linked), post-date, and post-excerpt
- Server-side rendering loops through query results and renders
  inner blocks per post, injecting postId/postType context
- Falls back to default template when no inner blocks are saved
- Removes custom BEM styles in favor of core block stylesheets
- Keeps only tab UI styles which are unique to this block
Add phpcs:ignore comments for VariableAnalysis.UndefinedVariable
since $block is provided by WordPress to block render.php files.
- Add server-side initial state: is-active class, hidden attribute,
  and correct aria-selected on tabs so the block works without JS.
- Persist active tab in pagination URLs via ap_tab query parameter
  so navigating pages keeps the selected tab.
- Add ARIA keyboard navigation: ArrowLeft/Right cycles tabs,
  Home/End jump to first/last, with roving tabindex.
@pfefferle pfefferle requested a review from jeherve March 17, 2026 08:27
Comment thread src/posts-and-replies/render.php Outdated
Comment thread src/posts-and-replies/render.php Outdated
…chive restriction

Move query manipulation (reply exclusion filter, base args, pagination) from
render.php into a dedicated Posts_And_Replies class for testability. The block
no longer bails on non-author-archive pages, making it usable on any page
(e.g. a static home page).
@pfefferle pfefferle closed this Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request [Focus] Editor Changes to the ActivityPub experience in the block editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Posts and replies block

4 participants