=== Social Preview ===
Contributors:      snehalpancholi
Tags:              open graph, twitter card, og meta tags, social sharing, facebook preview, seo
Requires at least: 6.0
Tested up to:      6.7
Requires PHP:      8.1
Stable tag:        1.0.0
License:           GPL-2.0+
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

Live Facebook and Twitter/X card previews in the post editor, with automatic Open Graph and Twitter Card meta tag output.

== Description ==

Social Preview adds a real-time card preview panel to the WordPress post and page editor, showing exactly how your content will appear when someone shares it on **Facebook** or **Twitter / X** before you hit Publish.

**Works in both Classic Editor and Block Editor (Gutenberg).**

= Key Features =

* **Live Facebook Card Preview** — See the 1200×630 image, title, description, URL and site name exactly as Facebook renders them.
* **Live Twitter Summary Large Image Card** — See the 2:1 image, title, description, site handle, and domain as Twitter/X renders them.
* **Real-time updates** — Preview refreshes instantly as you type the post title, excerpt, or custom OG fields — no page reload needed.
* **Custom OG Fields** — Override the OG title, OG description, and OG image on a per-post basis without affecting the post title or excerpt.
* **Automatic Meta Tag Output** — Outputs `og:*` and `twitter:*` meta tags in `<head>` automatically. No additional SEO plugin needed for basic OG support.
* **Sensible Fallbacks** — If custom OG fields are empty, the plugin falls back to the post title → excerpt → featured image → settings default image.
* **Settings Page** — Configure your Twitter/X site handle and a global default OG image fallback under Settings > Social Preview.
* **No jQuery** — Built with modern vanilla ES6 JavaScript.
* **Lightweight** — CSS and JS loaded only on post/page editor screens.
* **Secure** — All output escaped, nonces on all forms, capability checks throughout.

= Open Graph Meta Tags Output =

The following tags are added to the `<head>` of singular posts and pages:

```
<meta property="og:type"        content="article" />
<meta property="og:title"       content="..." />
<meta property="og:description" content="..." />
<meta property="og:url"         content="..." />
<meta property="og:site_name"   content="..." />
<meta property="og:image"       content="..." />
<meta property="og:image:width"  content="1200" />
<meta property="og:image:height" content="630" />
<meta name="twitter:card"        content="summary_large_image" />
<meta name="twitter:title"       content="..." />
<meta name="twitter:description" content="..." />
<meta name="twitter:image"       content="..." />
<meta name="twitter:site"        content="@yourhandle" />
```

= Compatibility Note =

If you use another SEO plugin (e.g. Yoast SEO, RankMath) that already outputs OG tags, you may get duplicate tags. In that case, either disable the other plugin's social tags feature or leave the Social Preview meta tag output disabled by not setting a default OG image and not filling in per-post custom fields (the fallback chain will simply be skipped for pages already covered).

== Installation ==

1. Upload the `social-preview` folder to `/wp-content/plugins/`.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Go to **Settings > Social Preview** to set your Twitter/X handle and default OG image.
4. Open any post or page editor — the **Social Preview** meta box / sidebar panel will appear.

== Frequently Asked Questions ==

= Will this conflict with Yoast SEO or RankMath? =

If those plugins output their own OG tags you may see duplicate `<meta>` tags. Both Yoast and RankMath have options to disable social meta — disable theirs and let Social Preview handle it, or vice versa.

= Does the preview work in the Block Editor? =

Yes. In Gutenberg a sidebar panel (Document > Social Preview) is registered. It shows the same Facebook and Twitter card previews and lets you edit the custom OG fields without leaving the editor.

= What image size should I use? =

For best cross-platform results use **1200 × 630 pixels** (PNG or JPEG). This covers both Facebook (1.91:1) and Twitter large image cards (2:1 when centre-cropped).

= Where are custom OG values stored? =

In `wp_postmeta` as `_addlc_spv_og_title`, `_addlc_spv_og_description`, and `_addlc_spv_og_image` (hidden meta keys — not visible to general queries).

= What is removed on uninstall? =

The plugin option `addlc_spv_options` and the update cache transient are deleted. Per-post meta is preserved so your OG customisations survive a reinstall.

== Screenshots ==

1. Classic Editor meta box showing Facebook card preview.
2. Classic Editor meta box showing Twitter/X card preview.
3. Block Editor (Gutenberg) Document Settings sidebar panel.
4. Settings > Social Preview page — Twitter handle and default OG image.

== Changelog ==

= 1.0.0 — 2026-06-14 =
* Initial release.
* Live Facebook Open Graph card preview in post editor.
* Live Twitter/X summary_large_image card preview in post editor.
* Tab switcher between Facebook and Twitter preview.
* Custom per-post OG Title, OG Description, OG Image fields.
* Automatic `og:*` and `twitter:*` meta tag output on frontend.
* Settings page: Twitter site handle, default OG image with media picker.
* Classic Editor (meta box) and Block Editor (Gutenberg sidebar panel) support.
* Media library image picker for OG image field.
* Character count indicators (95-char title, 160-char description).
* Responsive, dark-mode-aware CSS.
* AddonLogic update server integration.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
