=== GEOforge Schema ===
Contributors: delchostanimirov
Tags: schema, json-ld, seo, geo
Requires at least: 5.6
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Emits GEOforge-generated JSON-LD schema markup into the page head of single posts and pages, and opens Yoast SEO / Rank Math description meta for REST writes.

== Description ==

GEOforge generates JSON-LD schema markup and meta descriptions for the articles it publishes. WordPress strips inline `<script>` tags from post bodies (KSES sanitization) and hides underscore-prefixed meta from the REST API by default, so neither can be set by an external publishing tool without a companion plugin.

This plugin solves that by:

1. Registering a `_geoforge_jsonld` post-meta key, exposed via the REST API, that GEOforge writes to when publishing or updating an article.
2. Printing the stored JSON-LD inside a proper `<script type="application/ld+json">` tag in the page `<head>` for single posts and pages.
3. Registering the SEO post-meta keys used by Yoast SEO (`_yoast_wpseo_metadesc`) and Rank Math (`rank_math_description`) for REST API write access, so GEOforge can sync meta descriptions on publish. Each registration uses an `edit_post` auth check and `sanitize_text_field`-based sanitization capped at 320 characters. Registration is idempotent — if the SEO plugin already exposes the key for REST, our registration is a no-op.

No configuration required. Install, activate, and any GEOforge-published article will get its schema markup rendered correctly and its meta description handed to whichever SEO plugin is active.

== Installation ==

1. Upload the plugin zip via Plugins → Add New → Upload Plugin.
2. Activate.
3. Publish from GEOforge as normal — schema will appear in `<head>` on each article.

== Frequently Asked Questions ==

= Do I need GEOforge to use this plugin? =

The plugin is designed to render JSON-LD that GEOforge writes during publish. It will work with any tool that writes a JSON-encoded string to the `_geoforge_jsonld` post-meta key via the REST API, but on its own it does nothing — there is no admin UI for entering schema by hand.

= Will this conflict with Yoast SEO, Rank Math, or All in One SEO? =

No. Multiple `<script type="application/ld+json">` blocks per page are valid Schema.org and supported by Google — search engines merge the data. If both your SEO plugin and GEOforge emit schema, both will appear in the page head.

For meta descriptions, the plugin registers Yoast and Rank Math meta keys for REST. The registration calls are idempotent — if the SEO plugin has already registered the key itself, our call is a no-op. The auth callback restricts writes to users with `edit_post` capability on the target post.

= Why is the meta key prefixed with an underscore? =

WordPress treats underscore-prefixed meta as "protected" — hidden from the default Custom Fields UI in the post editor. This prevents accidental editing of the JSON blob while still allowing the REST API (and this plugin) to read and write it.

= What happens if I deactivate the plugin? =

The stored schema data is preserved in post meta. Re-activating restores schema rendering on the front end. Uninstalling the plugin does not remove the meta.

== Changelog ==

= 1.2.0 =
* JSON-LD output: decode the stored value and re-encode via `wp_json_encode` with `JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT` (plus `JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES`) before emitting. Every HTML-sensitive character is emitted as a `\uXXXX` escape, replacing the prior `str_replace('</', '<\/', $json)` approach.
* Register `_yoast_wpseo_metadesc` (Yoast SEO) and `rank_math_description` (Rank Math) post-meta keys for REST write access. Both use `show_in_rest`, an `edit_post` auth callback, and a `sanitize_text_field`-based sanitizer capped at 320 characters. Idempotent — no-op when the SEO plugin already exposes the key.

= 1.1.1 =
* Readme: rewrite the short description so the wp.org renderer doesn't strip the literal `<head>` tag and leave the sentence incomplete. Functionality unchanged.

= 1.1.0 =
* Enqueue a small scoped stylesheet on single posts and pages that constrains `.geoforge-content` to a 768px max-width and makes inline images responsive. Fixes edge-to-edge text on themes that don't apply a content container around `the_content()`. No typography or color rules — host theme keeps full control of look-and-feel.

= 1.0.0 =
* Initial release.
