=== 404ops Web Embed ===
Contributors: spwhite
Tags: embed, iframe, shortcode, security, url
Requires at least: 7.0
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 1.6.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Professional URL embedding with visual builder, security controls, caching, and smart fallback handling for enterprise applications.

== Description ==

404ops Web Embed adds embeddable external content to WordPress pages and posts, for dashboards, monitoring tools, internal applications and other content whose source allows embedding. Generic URLs render in an HTML object with fallback content. Known providers use their own rendering paths.

**Key features:**

* Known-provider presets: YouTube, Vimeo, Twitter/X, TikTok, SoundCloud, Spotify, Dailymotion, Flickr and Reddit through WordPress oEmbed. Google Maps, Instagram, Twitch and Google Docs, Sheets, Slides and Forms render as sanitised iframes. LinkedIn posts fall back to a link.
* A visual shortcode builder with live preview, and an embeddability check that reports allowed, blocked or unknown, with an explanation.
* A Web Embed block for the block editor, using the same renderer and rules as the shortcode.
* Security controls: a domain whitelist, an HTTPS-only mode and URL validation. Building embeds needs the edit_posts capability, and settings need manage_options.
* Caching, including the site's persistent object cache. A cache duration of 0 turns caching off.
* Auto-height, and a PDF viewer mode for PDF files in the Media Library or on a whitelisted HTTPS address.
* Aggregate embed view counts per embed and per page on a Usage screen, with no IP addresses, cookies or user IDs. Visitors who send Do Not Track or Global Privacy Control are not counted, and counting can be switched off.
* Multisite: network activation, with each site's own settings, whitelist, cache and counts, and a read-only network overview.
* An opt-in header relay for enterprise applications that cannot change their own framing headers. It is off until an administrator enables it and whitelists each host.
* Optional "Explain embeddability", using your own AI provider.

An optional paid add-on, Web Embed Pro, adds daily analytics with interactions and CSV export, cache refresh rules per host or path, a fallback template library, members-only embeds and gallery layouts. Everything listed above is free and stays free; nothing in this plugin is locked or limited.

**Please note:** whether an embed displays depends on the target site and the visitor's browser. The plugin does not bypass a site's framing restrictions, and "unknown" is a real answer. The External services section lists every outside request the plugin can make.

== Installation ==

= Install the Supplied ZIP =

This candidate does not claim a published WordPress.org listing. Use the ZIP supplied through your approved distribution channel.

1. Download the plugin zip file
2. Go to Plugins → Add New → Upload Plugin
3. Choose the zip file and click "Install Now"
4. Activate the plugin

= After Activation =

1. In your WordPress admin menu, go to **404ops → Web Embed**
2. Click **Settings** in the navigation row at the top of that screen (404ops Web Embed's screens are reached from that row, not from the sidebar)
3. Configure security settings (optional):
   - Enable domain whitelist if needed
   - Add trusted domains
   - Enable HTTPS-only mode (recommended)
4. Click **Shortcode Builder** in the same row to start creating embeds!

== Frequently Asked Questions ==

= Where can I get help? =

Visit https://supportminer.404ops.com to open a support request.

= Why is my preview empty? =

The source site's embedding policy, authentication, cookies, content type, or the visitor's browser can prevent an embed from loading. Use the builder's embeddability check as a diagnostic, then test the actual page in the visitor's browser. Generic embeds include fallback content, but whether the browser displays it depends on the failure; this plugin cannot override the source site's restrictions.

YouTube and Vimeo URLs use WordPress oEmbed, but playback still depends on the provider's availability, permissions, and the visitor's browser. For Google Maps, use an embed-specific URL rather than a plain place link.

= How do I embed Google Maps? =

1. Go to Google Maps and find your location
2. Click "Share" → "Embed a map"
3. Copy the URL from the iframe src attribute
4. Use that URL in 404ops Web Embed

Unlike YouTube and Vimeo, Google Maps still needs this specific embed URL. Use the embed link supplied by Maps, not a plain place/share link. The plugin renders it as a dedicated, sanitized iframe rather than the generic object renderer.

= How do I embed YouTube videos? =

Just paste the normal watch URL:
`https://www.youtube.com/watch?v=VIDEO_ID`

It's detected automatically and rendered through WordPress's built-in oEmbed support. The older embed URL format (`https://www.youtube.com/embed/VIDEO_ID`) still works too -- it's recognized and converted internally -- but there's no need to look for it.

Vimeo links such as `https://vimeo.com/VIDEO_ID` use the same WordPress oEmbed path. Actual access and playback remain subject to provider permissions and the visitor's browser.

= Can I embed my internal company dashboards? =

You can try an authorized dashboard whose network, authentication, and framing policy allow it. See docs/ENTERPRISE_APPS_GUIDE.md in the plugin folder for diagnosis, platform configuration areas, and a least-privilege change checklist. Do not weaken the application's security simply to make an embed load.

= Can I manage the whitelist from a script or another system? =

Yes, two ways, both limited to administrators and both writing to the same setting the screen does, with every change in the audit log. With WP-CLI: `wp web-embed whitelist list` (table, CSV, JSON or YAML), `wp web-embed whitelist add youtube.com "*.vimeo.com"`, `wp web-embed whitelist remove youtube.com`, `wp web-embed whitelist enable` / `disable` to turn enforcement on or off, `wp web-embed check <url>` to ask whether a URL would be accepted, and `wp web-embed clear-cache`. Over the REST API: `GET /wp-json/web-embed/v1/whitelist` returns the enforcement flag, the HTTPS rule and the domains; `POST /wp-json/web-embed/v1/whitelist` with `domain` adds one; `DELETE /wp-json/web-embed/v1/whitelist/<domain>` removes one; `PUT /wp-json/web-embed/v1/whitelist/enforced` with `enabled` turns enforcement on or off; `GET /wp-json/web-embed/v1/check?url=` answers the same way the builder's preview does. Another system authenticates with an administrator's application password, which WordPress accepts over HTTPS only; the plugin issues no tokens of its own.

= Can an embed resize itself to fit its content (auto-height)? =

Yes. Turn on `autoheight="1"` on the shortcode, or the block's "Auto-resize height" toggle, and the embed grows or shrinks to fit its content instead of staying a fixed size, clamped between `minheight`/`maxheight` (50-5000px; default 200-3000px).

Auto-height works for any embed this plugin already allows to render -- no separate whitelisting needed for it. A same-origin embed resizes itself automatically: no setup needed. A cross-origin embed needs the destination page to report its own height, since a browser will not let this site read a cross-origin page's content directly. Add the small copy-paste snippet from the Settings screen's "Auto-height Embeds" section to the embedded page; it posts the page's own height with `window.postMessage`. This site only trusts that report when it comes from the embed's own iframe, from the exact origin that iframe already points at -- everything else is ignored. Besides this plugin's own message shape, a destination already running iframe-resizer's own script, or one that posts a bare `{ height }` object, both work too.

= What's the difference between this and an iframe? =

Generic URLs render in an `<object>` with fallback markup directly inside it. This is a different rendering path, not a guarantee of better browser support or access to otherwise blocked content. The source site's policies and the visitor's browser still control what can display.

The exception is YouTube, Vimeo, and Google Maps: these are detected automatically and rendered through a safer built-in path instead (WordPress's own oEmbed support for YouTube/Vimeo, which is an iframe under the hood; a dedicated sanitized iframe for Maps).

= Does this work with page builders? =

Use a page builder element that executes WordPress shortcodes, then test the saved page. Compatibility with every third-party page builder is not claimed.

= How do I embed a PDF? =

Set the shortcode/block to PDF mode and either pick a file from the Media
Library or give a direct URL:

`[web_embed type="pdf" attachment="123"]`

`[web_embed type="pdf" url="https://example.org/report.pdf"]`

In the block editor, choose **PDF Document** as the Embed Type, then either
select a file with **Select PDF from Media Library** or paste a URL. The
`attachment` attribute takes a Media Library attachment ID and always wins
over `url` when both are present; the attachment must be an
`application/pdf` file the current visitor is allowed to see (its parent
post must be published and not password-protected, or it must be
unattached). A `url` is accepted only if it passes this plugin's own
whitelist/HTTPS rules and ends in `.pdf` -- for a remote URL this plugin
checks only the file extension, never the file's actual content, since it
does not fetch the file just to decide whether to render it.

The PDF renders in the browser's own built-in PDF viewer -- no bundled PDF
library, no CDN, and no third-party document-viewing service is involved.
Height defaults to 800px (clamped 200-4000px) and width to 100%; a
"Download PDF" link appears under the viewer by default and can be turned
off with the block's toggle or `pdf_download="0"`.

Many mobile browsers have no built-in inline PDF viewer. When that happens
the browser falls back to this plugin's own `<iframe>` markup, and if even
that shows nothing, a plain paragraph with a direct download link is always
present inside it -- so a visitor without an inline viewer still reaches the
file, just as a download instead of an inline view.

= Can I customize the fallback message? =

Absolutely! Use the `fallback` parameter in the shortcode:

`[web_embed url="https://example.org" fallback="<p>Custom message here</p>"]`

docs/FALLBACK_TEMPLATES.md in the plugin folder includes HTML examples you can adapt. They are not a built-in template picker; WordPress sanitization and the embed's dimensions affect the result.

= What do I need to disclose for GDPR? =

Compliance is a property of your site rather than of any plugin, so no plugin can hand it to you. What this one can do is state exactly what it does, so you can write it down:

* Embedded content is loaded by the visitor's browser directly from the third-party host. That host therefore sees the visitor's IP address and may set cookies. This is the same situation as any iframe or embedded video, and it is the part most likely to belong in your privacy policy.
* Your server contacts youtube.com or vimeo.com for oEmbed markup when such a URL is embedded, including from an hourly cache-warming cron job that runs with no visitor present. Set Cache Duration to 0 to stop that job making any request.
* The plugin stores an audit log of settings changes containing administrator display names and IP addresses as a WordPress option; storage and caching depend on your site configuration. It registers a WordPress privacy exporter and eraser, so those entries appear in Tools -> Export Personal Data and are removed by Tools -> Erase Personal Data.
* The plugin counts embed views on your own server as plain totals per embed and per page. It sets no cookie, stores no IP address or user ID, skips visitors who send Do Not Track or Global Privacy Control, and sends nothing to 404ops. Turn counting off under Settings > Count Embed Views.

= What happens if the URL is broken? =

Generic embeds include fallback markup with a link to the source, but the browser determines whether it is displayed for a particular failure. Check the original URL and use the builder's diagnostic; an unknown result is not an availability guarantee.

= Can I restrict who can create embeds? =

Not from this plugin's Settings screen -- there is no such option. The split is fixed in code:

- The Shortcode Builder requires the `edit_posts` capability, which WordPress grants to Contributor and above.
- Settings and Clear Cache require `manage_options`, which only Administrators have.

Custom WordPress roles may assign these capabilities differently. Review any role changes site-wide; the plugin has no independent role-assignment setting.

= Does it work on multisite? =

Yes. Activate it on one site or for the whole network. Each site keeps its own settings, whitelist, cache, view counts and audit log, managed by that site's administrators; only the header relay needs a network administrator. A network administrator also gets a read-only overview of every site under Network Admin > Settings > Web Embed. Deleting a site removes its view counts with it.

= Does it work on mobile? =

Responsive mode provides a full-width 16:9 container. It cannot make the embedded application's own interface responsive. Test the actual page and controls at the visitor's viewport size.

== External services ==

The plugin makes no request to 404ops or to any licence, update or telemetry service. It contacts an outside service only in the cases below, and each one happens only because an administrator or a page author has set it up.

**Requests your server makes**

* Known oEmbed providers (YouTube, Vimeo, Twitter/X, TikTok, SoundCloud, Spotify, Dailymotion, Flickr, Reddit): when a page renders one of these URLs, WordPress's own oEmbed support fetches the embed markup from that provider. Your server's IP address and the content URL reach the provider.
* Cache warming: an hourly WP-Cron event re-renders embeds whose cache has expired. This makes the same oEmbed requests with no visitor on the page. Setting Cache Duration to 0 stops it.
* Test embeddability: when an administrator presses the button and the address is a public HTTPS or HTTP address that is not a recognised provider URL, the plugin sends one HEAD request, and follows up to three validated redirects. Recognised providers are answered locally with no request.
* Opt-in header relay: only when the feature is enabled, a page author sets proxy="true" on an embed, and the host is on the administrator's whitelist. The server connects to a validated public IP for that hostname, verifies the HTTPS certificate and serves an accepted response inside a sandboxed frame. It does not follow redirects or forward visitor headers or cookies. The relay bounds response headers, downloaded bytes, decompression and rewritten HTML. Its output limit defaults to 2 MiB. The transfer and decoding budget defaults to 5 seconds, and DNS lookup time depends on the server's resolver. The relay requires PHP cURL and a compatible libcurl. See the Enterprise Apps Guide for proxy, version and encoding support.
* Explain embeddability (optional): only when an AI provider is connected on the shared AI Connection screen (404ops > AI Connection) and an administrator presses the button. It sends the tested URL and the plugin's own verdict and findings to that provider, and nothing else. The page's content is never fetched or sent. The providers are OpenAI (`api.openai.com`), Anthropic (`api.anthropic.com`), Google Gemini (`generativelanguage.googleapis.com`), OpenRouter (`openrouter.ai`), an OpenAI-compatible base URL you enter, and Ollama (by default `localhost`). Each provider's own terms and privacy policy apply.

**Requests your visitors' browsers make**

* An embed is a live connection from the visitor's browser to the third-party host, as with any iframe or embedded video. That host sees the visitor's IP address and can set its own cookies.
* The Google Maps preset sends the referring page URL to Google.

**Data this plugin stores** is covered in the Privacy answers in the FAQ. The plugin stores settings, cached embed markup, a cache-warming list of embed URLs, aggregate view counts, and an audit log of the last 50 settings changes. The audit log records the administrator's display name and IP address, and the plugin's privacy exporter and eraser cover it.

Policy references for the recognised content providers:

* YouTube: [terms of service](https://www.youtube.com/static?template=terms) and [Google privacy policy](https://policies.google.com/privacy).
* Vimeo: [terms of service](https://vimeo.com/terms) and [privacy policy](https://vimeo.com/legal/privacy/policy).
* Twitter/X: [terms of service](https://x.com/en/tos) and [privacy policy](https://x.com/en/privacy).
* TikTok: [terms of service](https://www.tiktok.com/legal/page/us/terms-of-service/en) and [privacy policy](https://www.tiktok.com/legal/page/us/privacy-policy/en); use the regional terms applicable to your use.
* SoundCloud: [terms of use](https://soundcloud.com/terms-of-use) and [privacy policy](https://soundcloud.com/pages/privacy).
* Spotify: [terms of use](https://www.spotify.com/us/legal/end-user-agreement/) and [privacy policy](https://www.spotify.com/us/legal/privacy-policy/); use the regional terms applicable to your use.
* Dailymotion: [terms of use](https://legal.dailymotion.com/en/terms-of-use/) and [privacy policy](https://legal.dailymotion.com/en/privacy-policy/).
* Flickr: [terms of use](https://www.flickr.com/help/terms) and [privacy policy](https://www.flickr.com/help/privacy).
* Reddit: [user agreement](https://redditinc.com/policies/user-agreement) and [privacy policy](https://www.reddit.com/policies/privacy-policy).
* Google Maps and Google Docs, Sheets, Slides and Forms: [Google terms](https://policies.google.com/terms), [Maps additional terms](https://www.google.com/help/terms_maps/) and [Google privacy policy](https://policies.google.com/privacy).
* Instagram: [terms of use](https://help.instagram.com/581066165581870) and [privacy policy](https://privacycenter.instagram.com/policy/).
* Twitch: [terms of service](https://legal.twitch.com/en/legal/terms-of-service/) and [privacy notice](https://legal.twitch.com/en/legal/privacy-notice/).

Maps, Instagram, Twitch and Google document presets build their iframe URLs locally; the visitor's browser loads those services. LinkedIn is a link fallback; visiting the link is covered by LinkedIn's [user agreement](https://www.linkedin.com/legal/user-agreement) and [privacy policy](https://www.linkedin.com/legal/privacy-policy).

For other embed URLs, embeddability probes and the enabled header relay, review the terms and privacy policy of the operator of the address you choose. This also applies to self-hosted dashboards and the other potential applications listed below. The data and triggers for server requests and visitor-browser requests are described separately above.

AI provider policy references for the optional shared AI connection:

* OpenAI: [API services agreement](https://openai.com/policies/services-agreement/) and [privacy policy](https://openai.com/policies/privacy-policy/).
* Anthropic: [commercial terms](https://www.anthropic.com/legal/commercial-terms) and [privacy policy](https://www.anthropic.com/legal/privacy).
* Gemini: [API terms](https://ai.google.dev/gemini-api/terms) and [Google privacy policy](https://policies.google.com/privacy).
* OpenRouter: [terms](https://openrouter.ai/terms) and [privacy policy](https://openrouter.ai/privacy). OpenRouter can route requests to another model provider; review the provider selected in your account as well.

For Ollama or an OpenAI-compatible endpoint, requests go to the server URL you configure. Review that server operator's terms and privacy policy. The plugin sends requests to the configured address; its operator determines any onward processing. The information sent and the actions that trigger a request are described above.

== Screenshots ==

1. Visual Builder - Configure an embed before generating it
2. Settings Page - Configure security, caching, and defaults
3. Generated Shortcode - Copy the configured embed into a post or page
4. Example Embed - A local demo page displayed inside a WordPress page
5. Fallback Content - Controlled unavailable-resource fixture with a link and explanation
6. Embeddability Test - An explained verdict before embedding a URL

== Changelog ==

= 1.6.4 =
* Fixed: the opt-in HTTPS relay pins connections to validated public addresses and enforces response-size limits during download, decoding and HTML rewriting.
* Documentation: complete content-provider policy references, configured-host responsibility and the existing preset description.
* Maintenance: bundles ai-client 0.4.3, which normalizes the AI Connection nonce before verification and rejects malformed inputs.

= 1.6.3 =
* Added: guarded read-only administrative status interfaces.
* Added: five bundled draft language catalogs with checked WordPress loading.
* Improved: development test-session and catalog packaging checks.

= 1.6.2 =
* Updated: the header relay now sends a sandbox policy for relayed pages. Relayed pages that rely on cookies or browser storage may not work in the frame, and auto-height is not offered for relay embeds. New tabs may operate outside the frame's sandbox.
* Fixed: the guides now ship in a docs folder, and the plugin no longer calls load_plugin_textdomain() (WordPress loads translations itself).
* Fixed: the analytics queries bind the table name as an identifier, and the relay endpoint ignores array-valued parameters.

= 1.6.1 =
* Updated the licence client (0.3.5): Pro keeps working after a licence expires.

= 1.6.0 =
* New: multisite support. Network activation sets each site up on its first visit and new sites as they are created, network deactivation stops cache warming on every site, deleting a site drops its view counts, and a read-only network overview lists every site's usage and security settings.
* New: visitors who send Do Not Track or Global Privacy Control are not counted.
* New: extension points for an add-on's per-embed analytics (a counted-view action, a reset action, data attributes on a rendered embed, and YouTube's player API).
* Fixed: the Usage screen, and any screen an add-on adds, now load the admin styles.

= 1.5.2 =
* Updated the bundled licence client to 0.3.4.

= 1.5.1 =
* Pro update packages now publish with maintenance information and one shared licence client version.

= 1.5.0 =
* Added the Pro add-on extension points and refreshed wording.

= 1.4.6 =
* Admin menu labels and page headings drop the 404ops brand prefix; the generated Composer loader is hardened for Plugin Check.

= 1.4.5 =
* Plugin URI points to the 404ops.com plugins page.

= 1.4.4 =
* Fixed: WordPress.org listing corrections. The readme now has a standalone External services section and a shorter description, and the duplicate version headings in this changelog are merged. No runtime behaviour change.

= 1.4.3 =
* Changed: Bundled libraries updated; translatable strings now use this plugin's text domain.

= 1.4.2 =
* Requires WordPress 7.0 or newer (it was 6.9); tested up to WordPress 7.1.

= 1.4.1 =
* Requires WordPress 6.9 or newer (it was 6.1); tested up to WordPress 7.1.
* Internal: support code for the older WordPress request library was removed.

= 1.4.0 =
* Maintenance: bundles its own prefixed UI kit. No other change.

= 1.3.1 =
* Maintenance: AI features use a private, namespaced copy of the AI client. If you use AI features, re-enter your AI connection once.

= 1.3.0 =
* New: fourteen recognised providers, including Instagram, Twitch and Google Docs, Sheets, Slides and Forms, with an honest fallback where no public embed exists.
* New: an opt-in header relay for enterprise applications. It needs a double opt-in and an exact-hostname whitelist.

= 1.2.0 =
* New: embed usage analytics, with per-embed view counts and placements on a Usage screen. Counts are aggregate-only.
* New: auto-height for embeds, with minimum and maximum clamps.
* New: a PDF viewer mode for Media Library PDFs and whitelisted PDF URLs.

= 1.1.0 =
* New: AI-assisted embeddability diagnosis. "Explain embeddability" turns the probe's own verdict into plain language, using your own AI provider. It is advisory only.

= 1.0.0 =
* Initial release: a visual shortcode builder, an embeddability check, security controls, caching, fallback templates, and the WordPress privacy exporter and eraser.

== Upgrade Notice ==

= 1.6.3 =
Includes checked draft translations and administrative status reporting. Human linguistic review is separate.

= 1.6.0 =
Multisite support and Do Not Track handling for view counts. Safe to update.

= 1.4.4 =
Readme and WordPress.org listing corrections only; no change to plugin behaviour. Safe to update.

= 1.4.3 =
Bundled libraries updated. Safe to update.

= 1.4.2 =
Now requires WordPress 7.0 or newer and is tested up to 7.1. Safe to update.

= 1.4.1 =
Now requires WordPress 6.9 or newer and is tested up to 7.1. Safe to update.

= 1.4.0 =
Bundles its own prefixed UI kit. Safe to update.

= 1.3.1 =
Maintenance release: AI features use a private copy of the AI client; re-enter your AI connection once. Safe to update.

= 1.3.0 =
Provider expansion and an opt-in enterprise relay. Existing embeds unchanged. Safe to update.

= 1.2.0 =
Adds embed usage analytics under the plugin's Usage screen. No action needed on upgrade.


= 1.1.0 =
Adds the optional AI explanation of embeddability results. Connect an AI provider on the shared AI Connection screen to use it; the plugin remains fully functional without one.


= 1.0.0 =
Initial release of Web Embed - Professional URL Embedding plugin.

== Additional Info ==

= Recommended Use Cases =

These are potential applications, not a tested-provider compatibility list.
The recognised provider presets and rendering paths are listed in Description.
Other services must supply a compatible URL and permit the intended access.

* **Internal Dashboards**: Grafana, Kibana, Tableau, custom admin panels
* **Monitoring Tools**: System monitoring, log analysis, metrics
* **Maps**: Google Maps (embed URL), Mapbox, OpenStreetMap
* **Videos**: YouTube, Vimeo (normal URLs, detected automatically)
* **Collaboration**: Google Docs/Sheets/Slides (published versions)
* **Forms**: Google Forms, Typeform, JotForm
* **Code Demos**: CodePen, JSFiddle, CodeSandbox

= Known Limitations =

* A source site can block embedding. Generic embeds include fallback markup, but browser behavior varies; a blocked resource is not guaranteed to show that markup
* Requires the source URL to not block embedding via X-Frame-Options or CSP headers
* Some browsers may limit embed functionality for security reasons
* Responsive embeds are fixed at a 16:9 ratio. There is no ratio attribute or setting; for a different shape, switch responsive off and set an explicit width and height instead
* The embeddability test runs from your WordPress server, which refuses private and reserved IP addresses. An internal dashboard on a private network therefore reports "unknown" rather than a verdict -- that is the safety guard working, not a bug

= Support =

For support, please:
1. Check the included documentation files
2. Review the FAQ above
3. Visit https://supportminer.404ops.com to open a support request

= Contributing =

404ops Web Embed is open source! Contributions are welcome.

= Credits =

Built with care for WordPress users who need professional embedding solutions.
