Skip to content

[Alternate] Podcast Episode block: post-bound (single source of truth)#48546

Open
robertbpugh wants to merge 14 commits intotrunkfrom
add/podcast-episode-block-postbound
Open

[Alternate] Podcast Episode block: post-bound (single source of truth)#48546
robertbpugh wants to merge 14 commits intotrunkfrom
add/podcast-episode-block-postbound

Conversation

@robertbpugh
Copy link
Copy Markdown
Contributor

@robertbpugh robertbpugh commented May 5, 2026

Draft alternate to #48375. The block does the same job, but episode title, author, and date come from the post instead of from block attributes. Walkthrough is in p1778019506270959-slack-podcast-tools, where Tony also raised a third option: a post-level setting (like Jetpack's paid-content gate) that manages podcast metadata at the post level rather than on the block.

Why

Tony's branch stores title, summary, description, author, imageId, imageUrl, and publishDate on the block. Every podcast post already has those fields (post_title, post author, post date). When an author edits one copy and forgets the other, Reader, RSS, the player, and the post page can show different versions of the same episode.

Substack avoids this by treating the post as the episode: the post title is the episode title, and the show notes go in the post body.

Cover art is the exception, since reusing the featured image renders the same picture twice on a post page (theme banner plus player square). This branch keeps coverArt as a block attribute and falls back to the show-level cover from Settings → Writing → Podcasting when nothing is set, matching how Apple Podcasts and Spotify resolve cover art.

What changes

  • block.json: drops title, summary, description, author, imageId, imageUrl, publishDate, guid. Adds coverArt ({ id, url }) and usesContext: [ "postId", "postType", "queryId" ]. Audio metadata, episode metadata, and Podcasting 2.0 fields are unchanged.
  • edit.js: reads post title, author, and date via useEntityProp with block context, following core's post-title and post-author-name blocks. Cover art picker falls back to window.jetpackPodcastEpisodeData.showCoverUrl for editor preview parity. Sidebar collapses to Episode / Audio / Podcasting 2.0.
  • podcast-episode.php: render callback uses get_the_title(), get_the_author_meta(), get_the_date(), get_permalink(). Cover art falls through episode → podcasting_image option → none. Show notes come from post content, so the callback no longer touches post_excerpt. enqueue_block_editor_assets exposes the show-level URL via wp_add_inline_script.

Comparison

#48375 This branch
Title Block attribute Post title
Cover art Block attribute Block attribute, falls back to show cover
Summary Block attribute Post content (show notes)
Author Block attribute Post author
Date Block attribute Post date
GUID Block attribute Post permalink (RSS layer derives)
Sidebar panels Episode details, Cover art, Podcasting 2.0 Episode, Audio, Podcasting 2.0
Works in Query Loop / site editor No Yes (block context)
Block outside a post Renders with stored attributes Inert with placeholder

Test plan

  • Install Jetpack Beta on a test site and switch to this branch.
  • Create a podcast post, insert the block, confirm the sidebar shows Episode, Audio, and Podcasting 2.0 panels only. No Title, Summary, Author, Publish Date, or GUID fields.
  • Type a post title and watch the player card update without saving.
  • With no episode cover art set, confirm the player falls back to the show cover from Settings → Writing → Podcasting.
  • Set an episode cover, confirm it overrides the show cover. Click "Use show cover art" to clear, confirm the show cover returns.
  • Add show notes in the post body, confirm they render below the player on the published page and not on the card.
  • Publish, fetch the category feed, verify <enclosure>, itunes: tags, and Podcasting 2.0 elements land in RSS.
  • Drop the block into a Query Loop on a podcast archive template, confirm each post renders its own title and cover.
  • Drop the block into a Site Editor sidebar template area outside a post, confirm the placeholder fires instead of crashing.

cc @arcangelini, treat this as input to the design conversation. Fold whichever pieces work into your branch, or keep the full model if post-bound is the long-term direction.

arcangelini and others added 4 commits May 4, 2026 19:54
…cover/excerpt)

Alternate model that drops the duplicating attributes (title, summary,
description, author, imageId, imageUrl, publishDate) and reads them from
the surrounding post instead.

- block.json: remove title/summary/description/author/imageId/imageUrl/
  publishDate attributes. Block keeps only audio + episode + Podcasting 2.0
  metadata.
- edit.js: useSelect from core/editor reads post title, excerpt, featured
  image, author. Sidebar collapses to three panels (Episode, Audio,
  Podcasting 2.0). Placeholder when block lives outside a post/page.
- podcast-episode.php: render_callback uses get_the_title(),
  get_the_excerpt(), get_the_post_thumbnail_url(), get_the_author(),
  get_the_date(). Guarded by is_singular() so the block stays inert in
  sidebars and template parts.
- save.js: drop title fallback in the noscript link.

Why: previously the block stored its own copy of the post title, featured
image, and excerpt. Authors edit the post, the block goes stale; or they
edit the block, the post stays out of date. RSS, Reader, the block, and
the post page can each show different copy of the same episode.
Substack and every episode-centric platform avoids this by treating the
post as the episode.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…estore poster size

- Read post title/excerpt/featured image/author/date via useEntityProp
  with usesContext: ['postId', 'postType', 'queryId']. Same pattern as
  core's post-title/post-excerpt/post-featured-image blocks. Block now
  works inside Query Loops and site-editor singular templates, not just
  the post editor.
- Replace local formatSeconds() with convertSecondsToTimeCode from
  extensions/shared/components/media-player-control/utils.
- Render publish date in editor preview to match the frontend.
- Use medium_large (768px) for the poster image instead of large (1024px);
  the cover renders at 256-512px CSS.
- Hoist person-row inline style to a module const.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@robertbpugh robertbpugh self-assigned this May 5, 2026
@robertbpugh robertbpugh requested a review from arcangelini May 5, 2026 23:06
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the add/podcast-episode-block-postbound branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/podcast-episode-block-postbound

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Block] Podcast Episode [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress labels May 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • 🔴 Add testing instructions.
  • 🔴 Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


🔴 Action required: Please include detailed testing steps, explaining how to test your change, like so:

## Testing instructions:

* Go to '..'
*

🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so:

## Does this pull request change what data or activity we track or use?

My PR adds *x* and *y*.

Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label May 5, 2026
@jp-launch-control
Copy link
Copy Markdown

jp-launch-control Bot commented May 5, 2026

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/extensions/shared/components/media-player-control/utils.js 0/28 (0.00%) 0.00% 26 💔

6 files are newly checked for coverage. Only the first 5 are listed here.

File Coverage
projects/plugins/jetpack/extensions/blocks/podcast-episode/edit.js 0/76 (0.00%) 💔
projects/plugins/jetpack/extensions/blocks/podcast-episode/editor.js 0/1 (0.00%) 💔
projects/plugins/jetpack/extensions/blocks/podcast-episode/save.js 0/5 (0.00%) 💔
projects/plugins/jetpack/extensions/blocks/podcast-episode/podcast-episode.php 84/196 (42.86%) ❤️‍🩹
projects/plugins/jetpack/extensions/blocks/podcast-episode/icons/index.js 0/0 (—%) 🤷

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

robertbpugh and others added 2 commits May 5, 2026 19:26
…ten i18n + a11y

- render_block() now accepts \WP_Block and resolves the backing post from
  block context, falling back to the global loop. Drops the is_singular()
  guard so the block works inside Query Loops and feeds, and switches all
  template tags to post-aware variants (get_the_title($post), etc.) so the
  rendered episode matches the loop item, not whatever the global page
  query points at.
- utils.js (extensions/shared/components/media-player-control): wrap the
  mejs.Utils helpers in arrow functions so the lookup happens at call time.
  Reading them at module-evaluation time would throw ReferenceError if the
  importing block evaluates before mediaelement loads on the page.
- Editor: switch concatenated Season/Episode strings to
  sprintf( __( 'Season %d' ) ) so locales that reorder noun/number can
  translate cleanly. Drop `alt={ postTitle }` on the cover-art preview
  (the title is rendered immediately after as h3), use BaseControl
  .VisualLabel for the People section so the label does not point at a
  non-existent input id, gate the placeholder on both postId AND postType,
  and drop the redundant useBlockProps className argument.
- Cover-art alt also dropped on the frontend for the same a11y reason.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Cover art now falls back show -> episode override (Apple/Spotify hierarchy).
Featured image is no longer reused, so themes don't render the same image
twice. Show notes hint replaces the excerpt summary on the player card so
authors write notes once, in post content. GUID UI dropped - RSS layer
derives it from the permalink.
@robertbpugh robertbpugh marked this pull request as ready for review May 6, 2026 14:12
Copilot AI review requested due to automatic review settings May 6, 2026 14:12
Copy link
Copy Markdown
Contributor

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

This PR introduces an alternate implementation of the Jetpack Podcast Episode block that treats the post as the single source of truth for episode title/author/date, while keeping per-episode cover art as a block attribute with a show-level fallback.

Changes:

  • Adds a new jetpack/podcast-episode block with a post-bound data model (usesContext) and a streamlined inspector (Episode / Audio / Podcasting 2.0).
  • Implements server-side rendering that pulls title/author/date from the resolved post context and applies a cover art fallback chain (episode override → show setting).
  • Reworks the shared media timecode helpers to defer mejs lookup until call time.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
projects/plugins/jetpack/extensions/shared/components/media-player-control/utils.js Changes timecode helpers to look up mejs.Utils at call time instead of import time.
projects/plugins/jetpack/extensions/index.json Registers the podcast-episode extension.
projects/plugins/jetpack/extensions/blocks/podcast-episode/style.scss Adds shared editor/front-end styling for the episode card layout.
projects/plugins/jetpack/extensions/blocks/podcast-episode/save.js Adds a direct-link fallback saved markup for non-frontend contexts (feeds/email/exports).
projects/plugins/jetpack/extensions/blocks/podcast-episode/podcast-episode.php Registers and renders the block; injects editor data for show cover fallback.
projects/plugins/jetpack/extensions/blocks/podcast-episode/icons/microphone.js Adds the block icon SVG.
projects/plugins/jetpack/extensions/blocks/podcast-episode/icons/index.js Exports the icon(s).
projects/plugins/jetpack/extensions/blocks/podcast-episode/editor.scss Adds editor-only styles for controls (people editor, cover picker, hint text).
projects/plugins/jetpack/extensions/blocks/podcast-episode/editor.js Registers the block from metadata and wires edit/save.
projects/plugins/jetpack/extensions/blocks/podcast-episode/edit.js Implements the editor UI, media selection, and post-bound display fields.
projects/plugins/jetpack/extensions/blocks/podcast-episode/block.json Defines the block metadata/attributes, including coverArt and usesContext.
projects/plugins/jetpack/changelog/add-podcast-episode-block Adds a changelog entry for the new block.

Comment thread projects/plugins/jetpack/extensions/blocks/podcast-episode/podcast-episode.php Outdated
Comment thread projects/plugins/jetpack/extensions/blocks/podcast-episode/edit.js Outdated
Comment thread projects/plugins/jetpack/changelog/add-podcast-episode-block Outdated
robertbpugh and others added 4 commits May 6, 2026 10:27
- Prettier: collapse multi-line help, VisualLabel children, ternary args.
- i18n: move translator comments inside sprintf so the rule reads them.
- i18n: split __() ternary so the extractor sees literal msgids.
- PHPCS: pass JSON encoding flags to wp_json_encode.
- Phan: cast post_author to int for get_the_author_meta.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@robertbpugh
Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

…18n, PHPUnit tests

Agent-Logs-Url: https://github.com/Automattic/jetpack/sessions/fb9995d0-fe14-48cb-9045-c12c05d7b263

Co-authored-by: robertbpugh <52668747+robertbpugh@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

@copilot apply changes based on the comments in this thread

Applied all unresolved review changes in commit 246b6cf:

  • coverArt array guard (podcast-episode.php:130): Added isset( $attributes['coverArt'] ) && is_array( $attributes['coverArt'] ) before accessing ['url'], preventing PHP warnings/errors when the attribute is a string or missing.
  • TRANSCRIPT_TYPE_OPTIONS localization (edit.js:39-43): Wrapped all four format labels with __( ..., 'jetpack' ) so they are translatable.
  • PHPUnit tests (Podcast_Episode_Block_Test.php): Added 7 tests covering non-frontend $content passthrough, empty/invalid mediaUrl early returns, missing post context, episode cover art taking precedence over show cover, show-level cover fallback when no episode art is set, and graceful handling of a malformed (string) coverArt attribute.

get_block_wrapper_attributes() depends on WP_Block_Supports::$block_to_render
state that is null when render_block is invoked directly from PHPUnit, so the
three coverArt-fallback tests crashed with "Trying to access array offset on
value of type null". Switch back to a plain class attribute escaped through
esc_attr(); production output is identical and the PHPCS escaper rule is
satisfied without an ignore comment.

Also fix PHPCS MultipleStatementAlignment warnings on the $original_post /
$GLOBALS['post'] pair in test_no_post_context_returns_empty_string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Podcast Episode [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants