=== Video Offload for VideoPress ===
Contributors: druesome
Tags: videopress, video, offload, jetpack, media
Stable Tag: 1.5.83
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Offloads locally-stored videos to VideoPress via Jetpack, replacing local references with VideoPress blocks.

== Description ==

Video Offload for VideoPress offloads locally-stored videos to VideoPress via Jetpack, then replaces local video references in post content with the native VideoPress block.

= Features =

- **Single or bulk offload** — offload one video at a time or all pending videos at once
- **Content replacement** — automatically replaces Gutenberg video blocks, `<video>` tags, `[video]` shortcodes, and bare URLs with VideoPress embeds
- **Local file cleanup** — delete local files after confirming they are on VideoPress to free up disk space
- **WP-CLI support** — offload and manage videos from the command line with `wp vov`
- **Progress tracking** — real-time upload progress with chunked transfer support

== Requirements ==

- WordPress 6.0+
- [Jetpack](https://wordpress.org/plugins/jetpack/) connected to WordPress.com
- A plan that includes VideoPress: WordPress.com Premium, Business, or Commerce — or Jetpack VideoPress or Jetpack Complete
- VideoPress feature active under Jetpack → Performance

== Installation ==

1. Upload the `video-offload-for-videopress` folder to the `/wp-content/plugins/` directory, or install the plugin through the WordPress plugins screen directly.
2. Activate the plugin through the 'Plugins' screen in WordPress.
3. Go to **Media → VideoPress Offload** to begin offloading videos.

== Usage ==

= Offloading videos =

- **Single video**: Click **Offload to VideoPress** next to any video in the Media Library or in the VideoPress Offload admin page
- **Bulk**: Use the **Offload All to VideoPress** button on the admin page to process all pending videos sequentially with a progress counter

= After offloading =

Each offloaded video gets three actions:

- **View on VideoPress** — opens the video on VideoPress
- **Replace in Content** — finds every post/page that embeds the local video and replaces it with a `wp:videopress/video` block
- **Delete Local File** — permanently deletes the local file from the server (confirm VideoPress has the video first)

= WP-CLI =

    wp vov status          # Summary of offload status
    wp vov offload         # Offload all pending videos
    wp vov offload --id=42 # Offload a single video
    wp vov delete-local    # Delete local files for offloaded videos

== How it works ==

The plugin calls Jetpack's internal `/videopress/v1/upload/{id}` REST endpoint, which handles chunked uploads and authentication with WordPress.com. Upload state is tracked in post meta so a page refresh mid-upload picks up where it left off and auto-polls until complete.

== Notes ==

- Offloading requires the site to be publicly accessible (VideoPress fetches the file from the server)
- Large files upload in chunks; the spinner stays visible for the full duration
- Clicking an individual Offload button disables the others until the upload completes or errors, preventing simultaneous uploads within the same page session

== External Services ==

This plugin relies on the **VideoPress** video hosting service, provided by **Automattic**, to upload, store, and deliver video files. A Jetpack connection and a WordPress.com plan that includes VideoPress are required.

**What the service does:** VideoPress hosts and streams video files via a global CDN, replacing locally stored videos with optimized embeds.

**What data is sent and when:**

- **Video file uploads** — When you click "Offload to VideoPress" or run `wp vov offload`, the plugin uploads the video file to VideoPress through Jetpack's REST API (`/videopress/v1/upload/`). Video metadata (file name, dimensions, duration) is included with the upload.
- **Video existence checks** — When you visit the VideoPress Offload admin page or the Media Library, the plugin verifies that previously offloaded videos still exist on VideoPress by querying the WordPress.com public API (`public-api.wordpress.com/rest/v1.1/videos/`). This runs at most once per day per video.
- **Embed URLs** — When replacing local video references in post content, the plugin generates embed markup pointing to `videopress.com/embed/` and loads the VideoPress player script from `v0.wordpress.com`.

**Service links:**

- [WordPress.com Terms of Service](https://wordpress.com/tos/)
- [Automattic Privacy Policy](https://automattic.com/privacy/)
- [VideoPress](https://videopress.com/)

== Frequently Asked Questions ==

= What WordPress.com plans include VideoPress? =

VideoPress is included with Premium, Business, and Commerce plans on WordPress.com. For self-hosted sites, Jetpack VideoPress and Jetpack Complete both include VideoPress.

= Do I need Jetpack installed? =

Yes. The plugin uses Jetpack's connection to WordPress.com to upload videos to VideoPress. Jetpack must be installed, activated, and connected.

= Will this work on a local/staging site? =

The offload process requires your site to be publicly accessible because VideoPress fetches the video file from your server. Local or firewalled sites will fail to upload.

= What happens to my posts after offloading? =

Nothing changes automatically. After a video is offloaded, use the **Replace in Content** action to update all posts and pages that reference the local video. The local `wp:video` block is replaced with a `wp:videopress/video` block.

= Can I undo an offload? =

The video remains on VideoPress after offloading. You can delete the local file at any time. To revert content changes, use WordPress revision history on the affected posts.

== Screenshots ==

1. The VideoPress Offload admin page showing pending and offloaded videos.
2. Single video offload with progress tracking.
3. Media Library integration with offload status column.

== Changelog ==

= 1.5.83 =
- Rename internal prefix from `vov` to `vovp` (4-character minimum per WordPress.org guidelines)
- Update text domain to `video-offload-for-videopress` to match plugin slug
- Add External Services section documenting VideoPress/WordPress.com API usage
- Improve phpcs:ignore annotation for VideoPress block cacheHtml script tag

= 1.5.82 =
- Code quality improvements for WordPress.org plugin directory submission
- Update VideoPress availability messaging (Business and Commerce plans only)
- Add upgrade links for WordPress.com and self-hosted sites
