Skip to content

VideoPress: add a Latest Videos Playlist block - #52665

Merged
heydemoura merged 4 commits into
trunkfrom
change/videopress-dynamic-playlist
Sep 23, 2026
Merged

heydemoura merged 4 commits into
trunkfrom
change/videopress-dynamic-playlist

Conversation

@heydemoura

@heydemoura heydemoura commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

  • Add a Latest Videos Playlist block (videopress/latest-videos-playlist). It renders exactly like the Video Playlist block, but there is no way to add videos by hand: it plays the site's newest VideoPress videos, and a Number of videos control in the block settings sidebar picks how many (1–20, default 5). New uploads show up on the front end without editing the post.
  • The block's canvas is a locked videopress/playlist inner block. The parent owns every setting (number of videos, Playback, Show on each entry, Styles) and hands the inner block the videos and its options through block context (videopress/latestVideosPlaylist), so the post stores only <!-- wp:videopress/playlist /--> inside the parent and nothing about the videos. The inner block runs in the disabled editing mode, so clicking the canvas selects the parent. On the front end the parent's render callback skips the inner block (skip_inner_blocks) and renders the newest videos fresh through the playlist renderer, so a stale snapshot can never reach the page.
  • The Playback / Show-on-each-entry / Styles inspector panels, the canvas preview and the live-metadata hook were extracted out of the playlist's edit.tsx into inspector-controls.tsx, preview.tsx and use-live-metadata.ts; the Video Playlist block's standalone behavior is unchanged (its Jest suites pass untouched), and it gains a latest-videos-inner.tsx mode used only under the parent.
  • The block reuses the playlist block's registered view script and style handles instead of shipping a second copy, so a page with both blocks loads one view script. It is only registered once videopress/playlist is.
  • Server side, Data::get_latest_videopress_playlist_entries() asks the media REST endpoint (/wp/v2/media) for the newest VideoPress attachments and hands the entries to the existing playlist render callback. The editor preview sends the same request. Both send the package's videopress_has_guid query param, which now also works off WordPress.com Simple (it sets post_mime_type = video/videopress there) rather than being ignored. Unlike core's mime_type param, it does not depend on video/videopress being an allowed upload mime.
  • The GUID is read from the jetpack_videopress_guid REST field, falling back to the attachment metadata when the site has no connection.
  • usePublishTracking takes the block name and event name, so the new block records jetpack_videopress_latest_videos_playlist_block_published on publish with the same properties as the playlist event.

Trade-offs worth a reviewer's eye:

  • The render callback runs an internal REST request on every render (which fires rest_api_init on the front end). It keeps the host differences (Simple's videos table vs. the video/videopress mime) in the one place that already handles them, at the cost of a heavier query than a bare WP_Query. No caching yet.
  • The inner block is inert in the editor, so clicking an entry in the canvas to preview another video does not work inside a Latest Videos Playlist (it does in a standalone Video Playlist and on the front end).
  • Private videos are included like they are in the Video Playlist block (the view script shows the lock placeholder for viewers who can't play them). Filtering them out of "latest videos" is left for a follow-up.

Related product discussion/links

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

Yes: a new Tracks event, jetpack_videopress_latest_videos_playlist_block_published, fired when a post containing the block is published, with the same properties as the existing jetpack_videopress_playlist_block_published event (post_type, layout, video_count, playlist_count).

Testing instructions

Automated (all run locally): jp test js packages/videopress (1346 tests), jp test php packages/videopress (new Latest_Videos_Playlist_Block_Test, plus Playlist_Block_Test and Data_Test), jp phan packages/videopress, PHPCS and tsgo --noEmit on the package.

Not run: the Jetpack plugin's VideoPress_Video_Extension_Test (extended here) needs the jp docker phpunit jetpack environment, which was not available on my machine at the time.

Manual, on a site with VideoPress videos in the media library (a Docker site with the Jetpack and VideoPress plugins active, and a few video/videopress attachments, is enough):

  • Insert the Latest Videos Playlist block. The canvas should show the newest videos with their live titles and posters, newest first, in the side-rail layout.
  • In the block settings, move Number of videos. The preview reloads with that many videos; the value is saved with the block.
  • Check the Playback, Show on each entry and Styles (layout, dark surface, typography) options behave like the Video Playlist block's.
  • Publish and view the post: the front end renders the same list, clicking entries switches the player, and "Autoplay next" / "Loop playlist" advance as in the playlist block.
  • Upload (or sync) a new VideoPress video and reload the post: it appears at the top without editing the post.
  • With no VideoPress videos on the site the editor shows a "No VideoPress videos yet" placeholder and the front end renders nothing.
  • Open List View: the block contains one Video Playlist block that cannot be selected, moved or removed; clicking the canvas selects the Latest Videos Playlist block and its settings.
  • Switch to the code editor: the saved content is the parent block wrapping a bare <!-- wp:videopress/playlist /-->, with no video data.
  • Add a Video Playlist block to the same post and confirm both keep working (they share the view script).

Screenshots

Front end Editor
Latest Videos Playlist on the front end Latest Videos Playlist in the editor with the Number of videos control

🤖 Generated with Claude Code

Plays the site's newest VideoPress videos in the Video Playlist block's
player, with the number of videos chosen in the block settings. The
preview, inspector panels, view script and styles are shared with the
Video Playlist block; the entries come from the media library at render
time on both hosts, so new uploads show up without editing the post.
@heydemoura heydemoura self-assigned this Sep 22, 2026
@heydemoura heydemoura added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. labels Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

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 change/videopress-dynamic-playlist branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack change/videopress-dynamic-playlist

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 [Package] VideoPress [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Tests] Includes Tests labels Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

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 🤖


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:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 6, 2026

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


Videopress 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.

@jp-launch-control

jp-launch-control Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 8 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/packages/videopress/src/class-access-control.php 139/183 (75.96%) -0.71% 2 ❤️‍🩹
projects/packages/videopress/src/class-data.php 143/288 (49.65%) 5.29% 2 ❤️‍🩹
projects/plugins/jetpack/extensions/extended-blocks/videopress-video/videopress-video.php 12/24 (50.00%) -4.55% 2 ❤️‍🩹
projects/packages/videopress/src/class-initializer.php 445/501 (88.82%) 0.40% 1 ❤️‍🩹
projects/packages/videopress/src/class-wpcom-rest-api-v2-attachment-videopress-data.php 90/216 (41.67%) 0.55% 0 💚

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

File Coverage
projects/packages/videopress/src/client/block-editor/blocks/playlist/use-live-metadata.ts 34/38 (89.47%) 💚
projects/packages/videopress/src/client/block-editor/blocks/playlist/preview.tsx 16/17 (94.12%) 💚
projects/packages/videopress/src/client/block-editor/blocks/latest-videos-playlist/context.ts 1/1 (100.00%) 💚
projects/packages/videopress/src/client/block-editor/blocks/latest-videos-playlist/edit.tsx 21/21 (100.00%) 💚
projects/packages/videopress/src/client/block-editor/blocks/latest-videos-playlist/fetch-latest-videos.ts 29/29 (100.00%) 💚

Full summary · PHP report · JS report

@heydemoura
heydemoura marked this pull request as ready for review September 23, 2026 16:32
@heydemoura
heydemoura requested a review from a team as a code owner September 23, 2026 16:32
@heydemoura heydemoura changed the title VideoPress: add a Dynamic Video Playlist block Sep 23, 2026
…Video Playlist block

The parent block keeps every setting and hands the inner block the newest
videos and its options through block context, so the post stores only the
bare inner block and nothing about the videos. The inner block is disabled
in the editor, so clicks select the parent, and it is skipped on the front
end, where the parent renders the newest videos fresh.
@heydemoura
heydemoura merged commit 3179f46 into trunk Sep 23, 2026
80 checks passed
@heydemoura
heydemoura deleted the change/videopress-dynamic-playlist branch September 23, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Package] VideoPress [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

1 participant