Repository navigation
Add GoDAM videos to LearnDash Video Progression - #2376
KMchaudhary wants to merge 12 commits into
Conversation
Media_Edit_Enhancements::video_shortcode_override() returned false for any [video] that is not a .mov file. WordPress renders the shortcode itself only when the override is '', so every other [video] shortcode on the site came out empty while GoDAM was active, including LearnDash's own self-hosted lesson videos. It now hands back what it was given. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A lesson or topic can use its GoDAM Video block, or a GoDAM video URL, as the LearnDash Video Progression video. GoDAM videos go through LearnDash's own video path, so LearnDash keeps deciding when the video shows (Display Timing, [ld_video], completed steps, admin bypass), builds the wrapper with the cookie key its Mark Complete check reads, and works out auto-complete and the hidden Mark Complete button. A new script drives the GoDAM player (or the GoDAM embed, through the Player SDK) with LearnDash's progress helpers: it locks the lesson until the video ends, resumes from the last position, auto-starts, pauses while the window is out of focus and hides the controls when asked. The "Use GoDAM Video" switch in the lesson and topic settings stores [video_godam] as the Video URL, since LearnDash only saves its own fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
🔍 WordPress Plugin Check Report
📊 Report
|
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
mismatched_plugin_name | Plugin name "GoDAM - Video Hosting for LMS & Online Courses" is different from the name declared in plugin header "GoDAM". |
📁 assets/build/pages/video-editor.min.js (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
2 |
react_removed_api | This file calls "ReactDOM.findDOMNode", which was removed in React 19 and stops working once WordPress upgrades React. Use a ref on the element instead. |
📁 assets/build/css/main.css (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedStylesScope | This style is being loaded in all contexts. |
📁 assets/src/libs/analytics.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/11/17/hello-world/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
📁 assets/build/js/main.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/11/17/hello-world/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check
LearnDash runs its metabox save filters for REST requests too. The "Use GoDAM Video" save read a missing switch as off and cleared [video_godam], so LearnDash then turned Video Progression off. It now reads the switch only when the settings form was posted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Autostart and resume were sent to the GoDAM embed as soon as the lesson loaded, before the iframe was listening, so the embed never started on its own. Commands now wait for the embed's ready message, or five seconds if that message came before the SDK was listening. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LearnDash_Video_Progress_setSetting() replaces a `complete` video state, so playing the video again after it ended saved `play` over it, and LearnDash's Mark Complete check then refused the lesson. Progress is no longer saved once the video is complete, the way LearnDash stops tracking its own players. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With "Use GoDAM Video" on, a GoDAM Video field now follows the switch: Select video opens the media library (GoDAM tab included), shows the picked video with a preview, and Remove clears it. The picked video is the progression video; without one, the first GoDAM Video block in the content is used, as before. The pick is stored in the Video URL marker as [video_godam id="123"], so LearnDash still routes it as a video shortcode and its cookie key changes with the video. A GoDAM tab pick is swapped for its WordPress attachment ID once GoDAM creates it, and anything that is not a video is ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The picked video now shows its preview with rounded corners, the title under it, and Replace and Remove as two matching buttons in a row, Remove in the editor's red. With no video picked, only Select video shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LearnDash fills its autostart and controls values, and drives the player, only while it applies progression, so admins and learners on a completed step got none of Autostart, Video Controls Display, Pause on Window Unfocused or Video Resume. GoDAM now passes the step's settings itself and the player follows them on every view. Locking Mark Complete until the video ends still applies only where LearnDash enforces progression, and the end of the video never unlocks or auto-completes a step that is not locked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Once a video was complete, nothing about it was saved any more, so Video Resume stopped following a second viewing. Only the `complete` state is kept now, also when an earlier view saved it; the position is still saved, and Pause on Window Unfocused keeps working while the video is watched again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The picker reads the picked attachment's title, post type and MIME type without the rtgodam_before/after_attachment_lookup pair, so integrations that keep media on another site could not switch to it first, and the hook check failed. The lookups now fire the pair. The check is renamed is_picked_video() too: sharing the name of Video_Metadata::is_video_attachment() stopped the hook check from tracing either one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
subodhr258
left a comment
There was a problem hiding this comment.
Code review of 0e9e7e67e. I read the code and checked CI; I did not run it on a site.
Going through LearnDash's own local path instead of copying its logic is the right call. It keeps Display Timing, [ld_video], admin bypass and the Mark Complete cookie check in LearnDash's hands. The [video] override fix is correct too: wp_video_shortcode() only renders the shortcode itself when the override is '', so false emptied every non-.mov [video] on the site.
| Claim | How checked | Result |
|---|---|---|
GoDAM source goes down LearnDash's local path, renamed to godam |
Read filter_video_provider() and filter_video_data() |
✅ |
| Picked video, else first GoDAM Video block | Read render_block_shortcode(), maybe_hide_video_block() |
✅ |
complete state is never overwritten on replay |
Read connectPlayer() isComplete() / saveState() |
✅ |
| Lock only where LearnDash enforces progression | Read init(): data-video-progression + ldWithoutLock |
✅ |
| REST saves keep the marker | Read save_settings_field(): returns early without the posted form |
✅ |
[video] with a non-.mov src renders again |
Read wp_video_shortcode() override check |
✅ |
| CI: PHP + JS unit tests, PHPCS, Plugin Check, hook integrity | Checks on 0e9e7e67e |
✅ all green |
Two things inline:
- GoDAM URL lessons make a remote call to the GoDAM API on every page view (
wp_oembed_get()is not cached). Should fix before merge. - Saving before a GoDAM-tab pick finishes can save the wrong video. Small fix.
Not checked: the picker on a real site, and the GoDAM embed fallback when oEmbed does not answer.
| return $html; | ||
| } | ||
|
|
||
| $embed = wp_oembed_get( $src ); |
There was a problem hiding this comment.
Uncached remote call on every lesson view. wp_oembed_get() has no cache (only WP_Embed::shortcode() caches, in post meta). For a GoDAM URL it runs Embed::pre_oembed_result() in inc/classes/class-embed.php, which does a blocking wp_remote_post() to the GoDAM API every time this shortcode renders, so on every view of the lesson by every learner.
When the API does not answer for a video (the case the comment below mentions), pre_oembed_result() returns null and WordPress then fetches the registered provider endpoint itself: two blocking requests per page view, each up to the 5 s default timeout, before the fallback runs.
Suggestion: since build_embed_iframe() already builds the right iframe, use it directly and skip oEmbed. Or keep oEmbed but cache the result (transient keyed on the URL). If you go with build_embed_iframe() only, keep the URL's query string (?org= is in your test table), because it currently keeps only the path.
There was a problem hiding this comment.
Fixed in 62fb4f5. render_video_shortcode() no longer calls wp_oembed_get(); it returns build_embed_iframe() directly, so a lesson view makes no request to the GoDAM API. build_embed_iframe() now keeps the query string: /web/video/1qciebqba9?org=860eda8a66 becomes /web/embed/1qciebqba9?org=860eda8a66. New tests cover the query string and the shortcode output.
There was a problem hiding this comment.
Fixed in 62fb4f5: read render_video_shortcode() at 321846bbb. It no longer calls wp_oembed_get() and returns build_embed_iframe() directly, so a lesson view makes no remote request. build_embed_iframe() appends the URL query string, and test_embed_iframe_keeps_the_query_string covers ?org=. A GoDAM-host URL that is not /web/video/<id> or /web/embed/<id> still returns "", so WordPress renders that [video] itself. Read from code and tests; I did not load a lesson on a site.
| // phpcs:ignore WordPress.Security.NonceVerification.Missing -- LearnDash verified the metabox nonce before running this filter. | ||
| $posted = isset( $_POST[ $metabox_key ][ self::FIELD ] ) ? sanitize_text_field( wp_unslash( $_POST[ $metabox_key ][ self::FIELD ] ) ) : ''; | ||
| // phpcs:ignore WordPress.Security.NonceVerification.Missing -- LearnDash verified the metabox nonce before running this filter. | ||
| $video_id = isset( $_POST[ $metabox_key ][ self::VIDEO_FIELD ] ) ? absint( wp_unslash( $_POST[ $metabox_key ][ self::VIDEO_FIELD ] ) ) : 0; |
There was a problem hiding this comment.
A GoDAM-tab pick saved too early can store the wrong video. Until godam-virtual-attachment-created fires, the hidden input holds GoDAM's ID (your PR body example: 88o035h31e). absint( '88o035h31e' ) is 88 (checked with abs( (int) '88o035h31e' ) in PHP), so if attachment 88 is a video, that unrelated video becomes the progression video with no error. An ID starting with a letter becomes 0 and silently falls back to the block, while the picker showed a video.
Suggestion: only accept an all-digit value, e.g. ctype_digit( $raw ) ? absint( $raw ) : 0, and in admin.js keep the button disabled or the input empty until the real attachment ID arrives.
There was a problem hiding this comment.
Fixed in 62fb4f5, both sides:
- PHP:
save_settings_field()only accepts an all-digit value (ctype_digit()), so88o035h31esaves as no picked video instead of attachment 88. Test:test_save_does_not_cast_a_godam_id_to_an_attachment_id, where 88 is a video. - JS: a GoDAM-tab pick shows its title and preview, but the hidden input stays empty until
godam-virtual-attachment-createdgives the attachment ID. The pending GoDAM ID is kept indata-pending-id, and the event only fills a picker whose pending ID matches, so a pick that was replaced in the meantime is not overwritten. Saving before that falls back to the lesson's first GoDAM Video block.
There was a problem hiding this comment.
Fixed in 62fb4f5: read save_settings_field() and renderPicked() at 321846bbb. PHP only accepts an all-digit value (ctype_digit()), so 88o035h31e saves as no picked video; test_save_does_not_cast_a_godam_id_to_an_attachment_id covers it with 88 being a video. JS keeps the hidden input empty until godam-virtual-attachment-created arrives and matches on data-pending-id, so a replaced pick is not overwritten (covered by the new "pick that was replaced" test). Read from code and tests; I did not use the picker on a site.
A GoDAM URL lesson now renders the embed iframe directly, keeping the URL's query string. wp_oembed_get() is not cached, so it called the GoDAM API on every lesson view, twice when the API had no answer. The picker keeps a GoDAM-tab pick out of the form until its WordPress attachment exists, and the save only accepts an all-digit ID: absint() read `88o035h31e` as attachment 88. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Feature PRs into develop don't regenerate languages/godam.pot; that happens on the PR into main, where CI checks it. Keeping it here only made the PR conflict with develop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
subodhr258
left a comment
There was a problem hiding this comment.
Re-review of 321846bbb (changes since 0e9e7e67e). I read the code and checked CI; I did not run it on a site.
| Earlier finding | How checked | Result |
|---|---|---|
| GoDAM URL lessons called the GoDAM API on every view | Read render_video_shortcode() and build_embed_iframe(); new PHP tests |
✅ fixed in 62fb4f5 |
| A GoDAM-tab pick saved too early could store the wrong video | Read save_settings_field() and renderPicked(); new PHP and JS tests |
✅ fixed in 62fb4f5 |
| CI: PHP + JS unit tests, PHPCS, Plugin Check, hook integrity | Checks on 321846bbb |
✅ all green |
No new findings. Both threads can be resolved.
One optional note, not a blocker: while a GoDAM-tab pick is waiting for its attachment ID, the picker shows the video but a save stores no pick and the lesson falls back to its first GoDAM Video block. A short "preparing video" hint in the picker during that wait would make this visible.
Not checked: the picker and a GoDAM URL lesson on a real site.
subodhr258
left a comment
There was a problem hiding this comment.
Approving 321846bbb: both earlier findings are fixed and CI is green. Code read only, not run on a site.
Closes #1172 (development task). Replaces #1238, rebuilt from scratch on the latest
develop.Summary
GoDAM videos now work with LearnDash Video Progression on lessons and topics, in two ways:
<GoDAM API host>/web/video/<id>), embed iframe or[embed]into LearnDash's Video URL field.Instead of rebuilding LearnDash's logic like #1238 did, GoDAM videos go through LearnDash's own video path. LearnDash still decides when the video shows (Display Timing,
[ld_video], completed steps, admin bypass). It also builds the.ld-videowrapper with the cookie key its server-side Mark Complete check reads, and it computes auto-complete, the delay message and the hidden Mark Complete button.The switch and the picked video are saved as that
[video_godam …]marker in the Video URL setting. LearnDash only saves the fields in its own map, and it needs a non-empty Video URL to keep progression on. Its cookie key includes the URL, so picking a different video starts the learner's progress over.[ld_video]placementAlso fixes: every
[video]shortcode rendered empty with GoDAM activeMedia_Edit_Enhancements::video_shortcode_override()returnedfalsefor any[video]that isn't a.mov. WordPress renders the shortcode itself only when the override is'', so every other[video]on the site came out empty. That included LearnDash's own self-hosted lesson videos, which LearnDash renders as[video src]. The fix is in its own commit (fa9ee43).if ( ! isset( $attrs['src'] ) || false === strpos( $attrs['src'], '.mov' ) ) { - return false; + return $html; }Bugs found while testing on a site, fixed in later commits
LearnDash_Video_Progress_setSetting()replaces acompletestate, so a replay savedplayover it and LearnDash's Mark Complete check refused the lesson. Progress is no longer saved once the video is complete.rtgodam_player) and the player always follows them. Locking Mark Complete until the video ends still applies only where LearnDash enforces progression, and the video ending never unlocks or auto-completes a step that is not locked.completestate is protected now (also when an earlier view saved it); the position keeps saving.rtgodam_before/after_attachment_lookup, and the check is namedis_picked_video()so it no longer shares a name withVideo_Metadata::is_video_attachment().Screencasts
Recorded on a test site (kuldip-godam.rt.gw) with this branch.
Admin: turn on Video Progression and Use GoDAM Video, pick a video from the media library, save.
Learner: Mark Complete stays locked while the video plays (controls hidden, as set), unlocks when it ends, and the lesson completes.
Mark Complete lock (LearnDash Video Progression)
This lock is LearnDash's own: with Video Progression on ("Require users to watch the full video as part of the course progression"), LearnDash disables Mark Complete until the video ends, and its server check refuses the step until then. It is not the Forced Lesson Timer, which LearnDash won't let you turn on together with Video Progression. This PR makes GoDAM videos report their end to that lock.
Checked on kuldip-godam.rt.gw as an enrolled subscriber, with a plain video file and with a GoDAM video. Each time: the button was disabled on load, re-enabling it in the browser and submitting was refused (the lesson stayed "In Progress"), the button turned on when the video ended, and clicking it completed the lesson.
.mp4(no GoDAM, LearnDash'slocalplayer)"Ended" means the video reached its end: with Video Controls Display on, a learner can drag to the end (both checks above did), and with it off they can't skip ahead.
Evidence
Local site (LearnDash 5.3.1), as an enrolled student; admins bypass progression:
[video_godam id="4874"].88o035h31euntil GoDAM created attachment4978, then stored that. Since 62fb4f5 the form holds nothing until the attachment exists, and the save only accepts an all-digit ID (checked by unit tests, not on a site).[video_godam].play); after the fix the lesson completed (state stayscomplete).[video src="…mp4"]with GoDAM active: before 0 bytes of output, after 299 bytes.kuldip-godam.rt.gw (preprod GoDAM API), one lesson per setting combination, as a subscriber:
[ld_video]placement?org=[video_godam]Unit tests:
LearnDashIntegrationTest(46),MediaEditVideoShortcodeOverrideTest(3),learndash/frontend.test.js+admin.test.js(38). Full suites pass (PHP 1597, Jest 1318), and so do phpcs, ESLint and the hook checks.languages/godam.potis left out: it is regenerated on the PR into main.Merge Danger
Door: two-way
Nothing is migrated. Turning the switch off, or reverting, leaves standard LearnDash settings.
Blast Radius: moderate
[video]fix applies site-wide.[video]shortcodes that rendered empty will now show WordPress's player, which is the intended behavior.🤖 Generated with Claude Code