Repository navigation
Show media on GoDAM's public routes only where WordPress would show it - #2245
Open
subodhr258 wants to merge 3 commits into
Open
subodhr258 wants to merge 3 commits into
subodhr258 wants to merge 3 commits into
Conversation
🔍 WordPress Plugin Check Report
📊 Report
|
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
mismatched_plugin_name | Plugin name "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" is different from the name declared in plugin header "GoDAM". |
0 |
trademarked_term | The plugin name includes a restricted term. Your chosen plugin name - "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" - contains the restricted term "wordpress" which cannot be used at all in your plugin name. |
📁 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/10/23/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/10/23/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
The preview and embed pages, the video shortcode, ad tag and transcoding status routes, and the video gallery listing now follow WordPress's own media visibility instead of answering for any media ID. Media is shown when it is unattached, or when the post it was uploaded to is published (or has another public status) and has no password the visitor has not entered. Users who can edit the media always see it, and users who can read a private or draft parent, or edit a password-protected one, see its media. Media used on a publicly viewable post counts as public whichever post it was uploaded to, using the media usage index, so a video uploaded while drafting one post keeps working in the player, gallery, lightbox and embed of the published page that uses it. Media a visitor may not see is treated like a missing ID. The result can be adjusted with the new rtgodam_can_view_attachment filter. - rtgodam_can_view_attachment() answers for one attachment; the gallery listing applies the same rule in SQL (rtgodam_public_media_query_clauses) so paging and counts stay correct. - The transcoding status route takes at most 100 IDs per request and leaves out IDs the user may not see. Reading the status no longer writes: the short wait for a thumbnail after transcoding is based on the time of the last status update, stored when the status is set, instead of a counter incremented on every read. The media library requests statuses in batches of 100. - The rtgodam_meta REST field on attachments returns the stored settings only to users who can write posts (for editor previews) or edit the attachment. - Video schema is printed only for posts whose content is public: not drafts, private, scheduled or password-protected posts. - Add unit tests for each of these.
subodhr258
force-pushed
the
fix/public-media-visibility
branch
from
October 23, 2026 06:21
158f694 to
4c08086
Compare
6 of 7 tasks
Collaborator
Author
|
Tested together with the other five 2.5.1 PRs on a hosted test site connected to production GoDAM Central. Full table and all recordings: https://github.com/rtCamp/godam-plugin-wp/issues/68 (recordings are in the rtCamp Test media library; sign in to watch). Tested commit
All passed. Transcoding is not affected: each video transcoded in 70 to 104 seconds, and Central's site checks pass 6 of 6. |
GoDAM's public routes and pages now follow WordPress's media API for media attached to a password-protected post: it is shown, the same as media of any published post. The rest is unchanged: media of draft, pending, private, scheduled and trashed posts stays hidden from visitors, and media used on a public post still counts as public. The video schema is still left out of a password-protected post, since the post's own content is hidden until the password is entered.
elifvish
reviewed
Oct 23, 2026
elifvish
left a comment
Collaborator
There was a problem hiding this comment.
No issues found.
Verification
- Head tested:
cabb90ce63. PHPUnit on this PR's head: 737/737 OK. - All seven 2.5.1 PRs merged onto
main(no conflicts): PHPUnit 915/915, Jest 690/690,build:prodOK. - Playwright API checks against that build on a local WordPress 7.1.3 site: 30/30 for this PR.
- Not covered: Video SEO schema on a password-protected post with a real video block: fixtures had no rendered block; covered by code reading and unit tests; adTagURL route with ad breaks configured.
Screenshots and a recording of the local run are available on request.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
GoDAM's public pages and routes now show a media item only where WordPress itself would, instead of answering for any media ID.
The rule (
rtgodam_can_view_attachment()ininc/helpers/custom-functions.php):_godam_usage_post_ids). A video uploaded while drafting one post and placed on a published page keeps working in that page's player, gallery, lightbox and embed, and in embeds on other sites.rtgodam_can_view_attachment( $can_view, $attachment )to tighten or relax the answer.Where it applies
godam/v1/gallery-shortcoderoutertgodam_public_media_query_clauses()), so paging and counts stay right; the listing is the same for every viewergodam/v1/video-shortcoderouteadTagURL/{id}routegodam/v1/transcoding/transcoding-statusroutemaxItems, 400 above that); a read no longer writes anything (see below)rtgodam_metaREST field on attachmentsnullfor visitors and Subscriberswp_headand the footer path)Transcoding status read. A transcoded video with no thumbnail yet used to be reported at 95% for three reads, counted by writing
rtgodam_thumbnail_retry_counton every read. It is now reported at 95% for 15 seconds after the last status update, which the status callback stores (rtgodam_transcoding_status_updated). The media library's list-view poller (transcoding-checker.js) now sends IDs in batches of 100, because longer lists get a 400.The video sitemap needed no change: it already lists only published posts without a password.
Testing
Throwaway WordPress (Playground, PHP 7.4, WordPress latest) with the 2.5.0 release plus these PHP files. A video attached to a page in each state, an unattached video, an exception video (uploaded to a draft, used on a published page), an Editor and an Author. Logged out / Editor:
cabb90ce6, 23 Oct), the shortcode route, preview, embed, gallery and transcoding status were re-checked logged out on a second throwaway site: all show the video, and WordPress's media API shows it too. *The ad route uses the same check but was not re-run.adTagURLreturns the ad breaks (also for the exception page).transcoding-checker.jswas run in Node against the patched route with 131 IDs: two requests (100 + 31), all statuses delivered. Jest covers 250 IDs in 3 requests.tests/php/MediaVisibilityTest.phpandtests/php/MediaVisibilityShortcodeRouteTest.php; full suite OK (738 tests).phpcs, ESLint andbin/hook-checkbalance and coverage checks pass.Effect on godam.io
Checked on a copy of godam.io's database (24 Sep 2026), read directly, without loading the site:
Worth knowing
idsthat aren't an array, now get a 400.QA:
VideoObjectdata.Issue: rtCamp/godam-plugin-wp#67