Skip to content

Image Studio: gate video clip generation by Image Studio enablement#48712

Merged
aagam-shah merged 5 commits into
trunkfrom
gate-image-studio-video-clip-by-enablement
May 13, 2026
Merged

Image Studio: gate video clip generation by Image Studio enablement#48712
aagam-shah merged 5 commits into
trunkfrom
gate-image-studio-video-clip-by-enablement

Conversation

@aagam-shah
Copy link
Copy Markdown
Contributor

Fixes #N/A

Proposed changes

  • image_studio_can_generate_video_clips() now requires is_image_studio_enabled() to be true; on sites where Image Studio itself isn't surfaced, video clip generation is also unavailable.
  • Reordered the helper so is_image_studio_enabled() and wpcom_site_can_upload_videos() run as hard gates before the jetpack_image_studio_can_generate_video_clips filter. A stray __return_true on the filter can no longer widen support past either capability check — it can still force-disable or set the off-WPCOM default.
  • Trimmed the inline filter docblock and updated the function-level docblock to describe the new gate.
  • Added test coverage:
    • test_can_generate_video_clips_false_when_image_studio_disabled — function returns false when Image Studio is disabled.
    • test_can_generate_video_clips_filter_cannot_override_disabled_image_studio__return_true filter cannot bypass the Image Studio gate.
    • test_can_generate_video_clips_filter_cannot_override_no_video_upload__return_true filter cannot bypass wpcom_site_can_upload_videos() (process-isolated, stubs the helper).

Related product discussion/links

  • N/A

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

No. No tracking changes; this is a capability-gate adjustment.

Testing instructions

  • On WordPress.com with an Image-Studio-supported plan: confirm window.imageStudioData.canGenerateVideoClips is true in the post editor and the video clip generation entry point appears as before.
  • On WordPress.com with a plan that doesn't support video uploads: confirm canGenerateVideoClips is false and the entry point is hidden.
  • On a site where Image Studio isn't enabled (no AI features, no Big Sky, not CIAB): confirm the helper returns false regardless of any add_filter( 'jetpack_image_studio_can_generate_video_clips', '__return_true' ).
  • Off-WPCOM (self-hosted Jetpack) with Image Studio enabled: confirm the helper returns true by default and the filter can still force-disable.
  • Run the unit tests: jp docker phpunit jetpack -- --filter=Image_Studio_Test.

Restrict image_studio_can_generate_video_clips() so video generation is
only offered on plans/environments that surface Image Studio itself.
is_image_studio_enabled() and wpcom_site_can_upload_videos() now act as
hard gates ahead of the jetpack_image_studio_can_generate_video_clips
filter, so a stray __return_true override cannot widen support past the
underlying capability checks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aagam-shah aagam-shah added [Status] In Progress [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels May 12, 2026
@aagam-shah aagam-shah self-assigned this May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 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 gate-image-studio-video-clip-by-enablement branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack gate-image-studio-video-clip-by-enablement

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
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: June 2, 2026
    • Code freeze: June 1, 2026

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

@jp-launch-control
Copy link
Copy Markdown

jp-launch-control Bot commented May 12, 2026

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/extensions/plugins/image-studio/image-studio.php 164/178 (92.13%) 0.09% 0 💚

Full summary · PHP report · JS report

Two pre-existing tests assumed the `jetpack_image_studio_can_generate_video_clips`
filter could force-enable independently of `wpcom_site_can_upload_videos()`.
Now that the wpcom helper is a hard gate ahead of the filter, those tests
failed in WPCOMSH-style CI where the helper is defined and returns false.

Mirror the existing process-isolation pattern (see
test_can_generate_video_clips_true_when_wpcom_helper_true): run each test
in a separate process and `eval`-stub `wpcom_site_can_upload_videos()` to
return true so the filter's force-enable path is actually exercised. Also
split the combined filter-override test into _true / _false variants so
the _false case keeps running everywhere (it doesn't depend on the gate).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aagam-shah aagam-shah marked this pull request as ready for review May 12, 2026 12:01
@aagam-shah aagam-shah requested review from Copilot and saroshaga May 12, 2026 12:15

This comment was marked as resolved.

Both `_filter_override_false` and `_inline_script_..._false_via_filter`
could pass for the wrong reason in WPCOMSH-style envs where
`wpcom_site_can_upload_videos()` returns false: the wpcom hard gate
short-circuits to false before the filter is consulted, so the assertion
succeeds without actually exercising the filter override.

Process-isolate both tests and stub `wpcom_site_can_upload_videos()` to
return true so both gates pass and the filter is the thing under test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

projects/plugins/jetpack/extensions/plugins/image-studio/image-studio.php:118

  • The docblock sentence "Off-WPCOM ... we don't gate the entry point" is now a bit misleading since the function always hard-gates on is_image_studio_enabled() even off-WPCOM. Consider rewording to clarify that only the video-upload capability gate is skipped off-WPCOM (while Image Studio enablement is still required).
 * Requires that Image Studio itself is enabled on this site, so video clip
 * generation is only offered on the same plans/environments that surface
 * Image Studio. Also mirrors the WordPress.com server-side gate: defers to
 * `wpcom_site_can_upload_videos()` when available so the client and server
 * agree on capability. Off-WPCOM (self-hosted Jetpack, standalone VideoPress,
 * dev environments) the helper isn't loaded; we don't gate the entry point in
 * those contexts and let the server respond if generation is unsupported.

The previous wording ("we don't gate the entry point in those contexts")
became misleading once is_image_studio_enabled() became a hard gate that
runs everywhere. Reword to say Image Studio enablement is always required
and that only the `wpcom_site_can_upload_videos()` check is skipped
off-WPCOM.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aagam-shah aagam-shah merged commit fcfdf4b into trunk May 13, 2026
72 checks passed
@aagam-shah aagam-shah deleted the gate-image-studio-video-clip-by-enablement branch May 13, 2026 05:19
@github-actions github-actions Bot added this to the jetpack/15.9 milestone May 13, 2026
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] In Progress labels May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Extension] Image Studio [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants