=== Apptimatic Facebook Product Video ===
Contributors: apptimatic
Tags: woocommerce, facebook video, reels, product video, product gallery
Requires at least: 5.6
Tested up to: 6.5
Requires PHP: 7.2
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Show a Facebook video or Reel in the WooCommerce product gallery. Paste a public Facebook URL on any product and it plays in the featured image position.

== Description ==

Product photos tell shoppers what an item looks like; a short video tells them how it works. If your marketing already lives on a Facebook page, this plugin puts those videos and Reels straight into the product gallery without re-uploading a single file.

Add a public Facebook video or Reel URL to any product and it appears in place of the featured image, sized to the right aspect ratio.

**Key features**

* **One field per product.** A Facebook Video / Reel URL box sits next to the product image in the editor.
* **Correct shape automatically.** Reels render 9:16 and page videos 16:9, or pick 1:1, 4:5 or a fixed ratio globally, with a per-product override.
* **Click to play.** Optionally keep the product photo visible and load the Facebook player only when a shopper taps play, so the third-party embed never slows down first paint on mobile.
* **Autoplay control.** Choose autoplay and muted independently, with a note about the browser rules that govern them.
* **Reliable placement.** The gallery slide is detected with a MutationObserver, so the video lands correctly on themes that build their gallery late.
* **URL validation.** Non-Facebook URLs are rejected at save time instead of rendering as an empty grey box on the storefront.
* **At-a-glance overview.** A Video column on the products list shows which products already have one.
* **Loads nothing extra elsewhere.** The script and stylesheet are enqueued only on product pages that actually have a video.

== Installation ==

1. Upload the `apptimatic-facebook-product-video` folder to `/wp-content/plugins/`, or install the ZIP through **Plugins > Add New > Upload Plugin**.
2. Activate the plugin through the **Plugins** menu. WooCommerce must be active.
3. Set the global defaults at **WooCommerce > Facebook Product Video**.
4. Edit any product and paste a public Facebook video or Reel URL into the **Facebook Product Video** box.

== Frequently Asked Questions ==

= Which URLs work? =

Any public Facebook video or Reel, for example `https://www.facebook.com/reel/1234567890` or `https://www.facebook.com/yourpage/videos/1234567890/`. Private videos, or videos limited to certain audiences, cannot be embedded by Facebook and will show an empty player.

= The video does not autoplay. Why? =

Browsers only allow autoplay when the video is muted. Autoplay therefore takes effect only while **Start muted** is also enabled. On some mobile browsers with data-saver active, autoplay is blocked regardless.

= Does it slow down my product pages? =

The Facebook player is a third-party embed, so it does carry a cost. Enable **Click to play** to avoid it: the product photo stays visible and the player only loads when a shopper taps the play button. The plugin's own script and CSS together are under 4 KB and load only on products that have a video.

= Does it work with my theme? =

It attaches to the standard `.woocommerce-product-gallery` markup that WooCommerce themes use, and it waits for the gallery rather than assuming it is ready. Heavily customised galleries that replace that markup entirely are the exception.

= Will my existing videos survive the rename from WC Facebook Product Video? =

Yes. The product meta key is unchanged, so every product that already had a video keeps it after upgrading.

== Changelog ==

= 1.1.0 =
* Renamed from WooCommerce Facebook Product Video to Apptimatic Facebook Product Video. Existing product videos are unaffected.
* Added a settings screen under WooCommerce for aspect ratio, autoplay, muted, click-to-play and caption defaults.
* Added a per-product aspect ratio override, plus 1:1 and 4:5 options.
* Added click-to-play so the heavy Facebook embed loads only on demand.
* Replaced the setTimeout retry chain with a MutationObserver, fixing videos that failed to appear on themes with slow or deferred galleries.
* Facebook URLs are now validated on save; a wrong URL no longer renders as an empty box on the storefront.
* Moved inline JavaScript and CSS into enqueued asset files, loaded only on product pages that have a video.
* Added a Video column to the products list, a capability check on save, and an admin notice when WooCommerce is inactive.
* Declared WooCommerce High-Performance Order Storage compatibility.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.1.0 =
Renamed plugin with a settings screen, click-to-play, and a reliability fix for themes whose gallery loads late. Product videos carry over unchanged; deactivate and delete the old plugin after activating this one.
