A lightweight WordPress plugin that, on post save, detects STN/SendtoNews embeds in post content, calls the STN Meta API to retrieve metadata for Heavy-owned videos, and stores normalized data for schema and sitemap.
- Scans post content for STN Video embeds:
- Shortcode:
[sendtonews key="..."]
- Shortcode:
- Gutenberg block comment:
<!-- wp:sendtonews/playerselector {"embedKey":"..."} /--> - For each shortcode key, calls the STN Meta API:
POST https://api.stnvideo.com/api/v1/videowithcid,authcode,searchKey=key,searchValue={key}
- Normalizes API response to a minimal structure and builds a
VideoObjectJSON-LD with whatever fields are available:- name (headline)
- description (summary/description)
- uploadDate (ISO8601, UTC)
- thumbnailUrl (if present)
- duration (ISO8601 if length present)
- contentUrl (preferred MP4 rendition else
videoUrl)
- Persists:
hvy_video_schema_data: JSON-LD used by sitemap and<head>schema outputstnvm_status: one ofok,no_shortcode,not_found,errorstnvm_keys: array of discovered keys
- Caches STN API responses in object cache (Memcached), success for 1 hour and errors for 10 minutes.
- Hooked to
save_post(after capability checks and revision/autosave guards) for supported post types (defaultpost,videos). - Extracts keys from content. If none:
- Sets
stnvm_status = no_shortcode - Deletes
hvy_video_schema_dataif present - Returns
- Sets
- Keys are tried in this order: shortcodes (content order), then blocks (content order). The first successful API response is used. A
404response short-circuits withnot_found. - If keys are unchanged and prior status is final (
ok,not_found), returns early without calling the API. - Fetches credentials from the STN plugin settings model and options.
- Calls the Meta API with caching:
- Successful responses cached for 1 hour
- Non-success responses cached for 10 minutes to avoid hammering
- If
success=true, normalizes and writes JSON-LD and setsstnvm_status = ok. - If
code=404, setsstnvm_status = not_foundand returns. - Otherwise sets
stnvm_status = errorand returns.
Notes:
- JSON-LD saves only fields present in the response; sitemap output remains guarded by existing site code (it emits only when
contentUrlanddurationare present). - Meta writes avoid unnecessary updates to reduce DB churn.
- WordPress
- STN "Video Player Selector" plugin installed, activated, and configured
- Credentials are read from the plugin model
SendtoNews\Models\Settings(or the corresponding options).
- Credentials are read from the plugin model
- PHP 8.0+
- Outbound HTTP access to
https://api.stnvideo.com/
- Post types to process (default
['post','videos']): use thestnvm_post_typesfilter. - Schema meta key (default
hvy_video_schema_data): use thestnvm_schema_meta_keyfilter. - API timeout (default
10seconds) is fixed in code; adjust here if needed. - MP4 selection priority (default
['MP43200k','MP41080p','MP4300k']): use thestnvm_mp4_priorityfilter. - Cache TTLs are fixed: success 1 hour, errors 10 minutes.
- Install this folder under
wp-content/plugins/stn-video-meta/. - Activate the plugin in WP admin.
- Configure STN plugin credentials under Settings → STN Video.
- Create or edit a post and add an STN embed:
- Shortcode example:
[sendtonews type="float" key="qI2M6B3PAC-4180995-10456"]
- Shortcode example:
- Save the post. The plugin will fetch metadata and write JSON-LD to
hvy_video_schema_data. - Sitemap and
<head>schema output already consumehvy_video_schema_dataelsewhere in the theme/plugins.
ok: JSON-LD saved for at least one keyno_shortcode: no STN embed detectednot_found: API returned 404 for the provided key(s)error: credentials missing, transport error, invalid JSON, or non-404 error response
- No credentials are hard-coded; credentials loaded from the STN plugin settings.
- Uses
wp_remote_postwith 10s timeout; no filesystem writes. - Caches in object cache with explicit TTLs; avoids unnecessary meta writes.
- Runs per-site; does not switch blogs.
- Add an admin meta box to show
stnvm_statusand last check time. - Add an explicit “Recheck” action to force refetch and refresh caches.
- Optional async processing via Action Scheduler or a custom queue if save latency becomes noticeable.