Repository navigation
VideoPress: add a Latest Videos Playlist block - #52665
Conversation
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.
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
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:
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. |
Code Coverage SummaryCoverage changed in 8 files. Only the first 5 are listed here.
9 files are newly checked for coverage. Only the first 5 are listed here.
|
…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.
Proposed changes
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.videopress/playlistinner 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 thedisabledediting 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.edit.tsxintoinspector-controls.tsx,preview.tsxanduse-live-metadata.ts; the Video Playlist block's standalone behavior is unchanged (its Jest suites pass untouched), and it gains alatest-videos-inner.tsxmode used only under the parent.videopress/playlistis.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'svideopress_has_guidquery param, which now also works off WordPress.com Simple (it setspost_mime_type = video/videopressthere) rather than being ignored. Unlike core'smime_typeparam, it does not depend onvideo/videopressbeing an allowed upload mime.jetpack_videopress_guidREST field, falling back to the attachment metadata when the site has no connection.usePublishTrackingtakes the block name and event name, so the new block recordsjetpack_videopress_latest_videos_playlist_block_publishedon publish with the same properties as the playlist event.Trade-offs worth a reviewer's eye:
rest_api_initon the front end). It keeps the host differences (Simple'svideostable vs. thevideo/videopressmime) in the one place that already handles them, at the cost of a heavier query than a bareWP_Query. No caching yet.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 existingjetpack_videopress_playlist_block_publishedevent (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(newLatest_Videos_Playlist_Block_Test, plusPlaylist_Block_TestandData_Test),jp phan packages/videopress, PHPCS andtsgo --noEmiton the package.Not run: the Jetpack plugin's
VideoPress_Video_Extension_Test(extended here) needs thejp docker phpunit jetpackenvironment, 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/videopressattachments, is enough):<!-- wp:videopress/playlist /-->, with no video data.Screenshots
🤖 Generated with Claude Code