-
Notifications
You must be signed in to change notification settings - Fork 83
Add Extra Fields block for ActivityPub profiles #2439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
Introduces a new 'Fediverse Profile Fields' block to display extra profile fields from ActivityPub user profiles. Includes block registration, editor and server-side rendering logic, styles for default, compact, and cards layouts, and integration into the block registration process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new "Fediverse Profile Fields" block that displays extra profile fields from ActivityPub user profiles. The block provides three style variants (default, compact, and cards) with extensive customization options including colors, borders, typography, and field limits.
Key Changes:
- New block implementation with server-side rendering for displaying ActivityPub profile fields
- Three visual style variations: default (vertical list), compact (table-like), and cards (individual styled cards)
- User selection dropdown with support for blog user, specific users, and dynamic/inherit mode
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/extra-fields/block.json |
Block metadata defining attributes, styles, and supported features |
src/extra-fields/edit.js |
Editor component with API fetch logic and preview rendering |
src/extra-fields/save.js |
Save function returning null (uses server-side rendering) |
src/extra-fields/render.php |
Server-side rendering template with field filtering and styling |
src/extra-fields/style.scss |
Styles for all three block variations with responsive layouts |
src/extra-fields/index.js |
Block registration entry point |
includes/class-blocks.php |
Registers the new block in the plugin's block registration process |
build/extra-fields/* |
Compiled production files (CSS, JS, PHP) from source files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Introduces a PHP docblock for the render callback in src/extra-fields/render.php, clarifying the types and purpose of the $attributes and $block variables for improved code readability and maintainability.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Introduces comprehensive Jest tests for the Extra Fields block edit component. Refines card and compact styles to use CSS variables for colors and removes unnecessary width properties. Updates PHP render logic to pass block context for user resolution and improves key usage in React field rendering.
Simplifies the Extra Fields block render callback by removing the unused $block->context argument from Blocks::get_user_id. This change clarifies the function call and eliminates unnecessary code.
Introduces unit tests for the Activitypub Extra Fields block, covering rendering for blog and user contexts, maxFields attribute, empty fields, cards style, background color, and HTML content preservation. Enhances test coverage for block functionality and edge cases.
Enhanced the logic for detecting the post author in the Extra Fields block, including support for Query Loop context. Inspector controls are now always rendered, even when no author is present in inherit mode, improving recovery and usability. Added tests for context-based author detection and updated PHP render logic to skip output for ActivityPub requests and feeds.
Updated SCSS and built CSS files to style <p> elements within .activitypub-extra-field dd, ensuring proper spacing and removing bottom margin from the last paragraph. This improves readability and consistency for extra field content.
|
@pfefferle Is this meant for 7.6.0? |
|
@obenland no, I don't think so! |
Updated block title, description, and UI labels from 'Fediverse Profile Fields' to 'Fediverse Extra Fields' for clarity. CSS class names and references in JS were also changed to match the new naming convention.
Changed the default block style from 'default' to 'compact', renamed the previous 'compact' style to 'stacked', and updated related CSS/SCSS to support the new naming and layout. This improves clarity and consistency in style options for the Fediverse Extra Fields block.
|
@obenland "Compact" is now the default and the former default is now called "Stacked".
|
| setError( null ); | ||
|
|
||
| apiFetch( { | ||
| path: `/activitypub/1.0/actors/${ userId }`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use useOptions() to get the namespace here
| <div { ...blockProps }> | ||
| <Placeholder label={ __( 'Fediverse Extra Fields', 'activitypub' ) } icon="list-view"> | ||
| <p> | ||
| { __( 'Error loading extra fields:', 'activitypub' ) } { error } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use a placeholder here for better internationalization
| { settingsPanel } | ||
| <div { ...blockProps }> | ||
| <Placeholder label={ __( 'Fediverse Extra Fields', 'activitypub' ) } icon="list-view"> | ||
| <p>{ __( 'No extra fields found. Add fields in your profile settings.', 'activitypub' ) }</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we link to the profile settings here? Or directly to the editor to add an extra field?
| * Compact Style | ||
| * Displays fields in a table-like format with aligned labels and values. | ||
| */ | ||
| .is-style-compact { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might have to remove this?
When I insert the block it's being displayed as stacked, not as compact.
| import save from './save'; | ||
| import metadata from './block.json'; | ||
| import './style.scss'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| import save from './save'; | |
| import metadata from './block.json'; | |
| import './style.scss'; | |
| import metadata from './block.json'; | |
| import './style.scss'; | |
| const save = () => null; |
Let's keep it local for as long as we don't need it.

Introduces a new 'Fediverse Profile Fields' block to display extra profile fields from ActivityPub user profiles. Includes block registration, editor and server-side rendering logic, styles for default, compact, and cards layouts, and integration into the block registration process.
Styles:
Settings:
Proposed changes:
Other information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Added a new Fediverse Profile Fields block to display ActivityPub profile details, featuring default, compact, and card layouts with flexible user selection options.