=== MandantenFilter Gesetzestexte ===
Contributors: mandantenfilter
Tags: german-law, bgb, legal, law-firm, statutes
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 0.3.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Embed selected German federal statutes from Gesetze im Internet dynamically as a Gutenberg block or shortcode.

== Description ==

This plugin lets German law firms, legal publishers, and editorial teams embed selected sections and articles of German federal law directly in the block editor or via the `[mfgesetz_norm]` shortcode.

= Features =
* Search federal statutes by title or common abbreviation (e.g. BGB, StGB, GG, ZPO).
* Preview individual provisions and select specific paragraphs via checkboxes before inserting.
* Shared semantic HTML5 renderer for both the Gutenberg block and `[mfgesetz_norm gesetz="bgb" norm="§ 622"]` shortcodes.
* Per-embedding update control (`manual`, `auto_except_structure`, `auto`, `frozen`), SHA-256 version tracking, `wp_text_diff()` comparison view, and affected-post tracking.
* Local storage for actively used norms only; daily background check via WP-Cron.
* Configurable outage warnings, customizable notice templates with placeholders (`{days}` / `{tage}`, `{date}` / `{datum}`), fallback handling for unsupported structures (e.g. tables), and clean static HTML conversion before uninstall.

= Disclaimer =
The plugin fetches consolidated, non-official texts from *Gesetze im Internet* (BMJV/BfJ). The official Federal Law Gazette (*Bundesgesetzblatt*) remains authoritative.

== External services ==

This plugin connects to an external service **strictly after explicit administrator opt-in** in **Statute Texts → Setup & Settings**. Without opt-in enabled, **zero** outbound HTTP requests are made (including during the system check).

* **Service:** *Gesetze im Internet* (`https://www.gesetze-im-internet.de/`), provided by the German Federal Ministry of Justice and Consumer Protection (BMJV) and the Federal Office of Justice (BfJ).
* **Purpose:** Retrieving the federal statute catalog index (`gii-toc.xml`) and statute XML archives (`xml.zip`) exclusively for statutes actively searched, previewed, or embedded on the site.
* **When requests are sent:**
  1. When an administrator runs the HTTPS connection test on the settings page (skipped if opt-in is disabled).
  2. When searching statutes or loading an index/preview inside the block editor.
  3. When saving a post whose embedded `[mfgesetz_norm]` shortcode or `mfgesetz/norm` block references a statute not yet cached locally.
  4. During a manual full sync or the daily scheduled WP-Cron sync for actively used statutes.
* **Data transmitted:** Server-side HTTPS requests transmit only your web server's IP address and standard HTTP headers (`User-Agent`). **No** post content, WordPress user data, or visitor data is ever transmitted.
* **Site visitors:** Site visitors never automatically connect to `www.gesetze-im-internet.de` or `mandantenfilter.de`. Optional clickable source/credit links are disabled by default.
* **Service terms & privacy policy:**
  * Legal Notice & Terms (*Impressum*): https://www.gesetze-im-internet.de/impressum.html
  * Usage Notes (*Hinweise*): https://www.gesetze-im-internet.de/hinweise.html
  * Privacy Policy (*Datenschutzerklärung*): https://www.gesetze-im-internet.de/datenschutz.html

== Installation ==

1. Upload `mandantenfilter-gesetzestexte.zip` under **Plugins → Add New → Upload Plugin** or extract it to `/wp-content/plugins/mandantenfilter-gesetzestexte/`.
2. Activate the plugin.
3. Open **Statute Texts → Setup & Settings**, confirm external data fetching (opt-in), save settings, and run the connection test.

== Frequently Asked Questions ==

= Does the plugin download all 6,000+ German federal laws? =
No. Only the compact index is fetched. Full archives are downloaded exclusively for statutes you actually embed, and only used provisions are stored locally.

= How are statutory amendments handled? =
By default, existing embeddings keep their approved version (and its original fetch timestamp) until an editor or administrator reviews the word-by-word diff under **Statute Texts → Embedded Statutes** and approves the update. Each block or shortcode can also be configured individually.

= Will my posts remain intact if I uninstall the plugin? =
Yes. Editorial posts are never modified on uninstall, and you can convert all dynamic embeds into static HTML with one click beforehand.

== Changelog ==

= 0.3.2 =
* Renamed plugin display name and slug to `MandantenFilter Gesetzestexte` (`mandantenfilter-gesetzestexte`) with unified `mfgesetz_` / `.mfgesetz-*` prefixes and `[mfgesetz_norm]` shortcode.
* Blocked outbound HTTPS requests during system diagnostics until external data fetching opt-in is confirmed, updated User-Agent, and enforced opt-in plus manual redirect host validation inside the download helper.
* Restricted change review screens and approval actions to `edit_others_posts` plus per-post `edit_post` verification, moved admin diff CSS to an external stylesheet, scoped/dismissible admin notices, and hardened REST preview routes.
* Switched source strings to English with bundled German (`de_DE` and `de_DE_formal`) `.mo` and block editor JSON translations under `/languages`.
* Updated `readme.txt` External services documentation with verified links to Gesetze im Internet legal notice, usage notes, and privacy policy.

= 0.3.1 =
* Fixed settings redirect slug.
* Shortened source footer date to date-only format.
* Switched outage warning threshold from hours to days (default: `7` days) and added customizable warning/hidden notice text templates.

= 0.3.0 =
* Controlled per-embedding update modes, SHA-256 version snapshots, `wp_text_diff()` review queue, affected-post links, and email/admin notifications.
* Paragraph checkbox selection in block preview and inspector sidebar, plus improved edit flow.
* Configurable outage thresholds, toggleable source attribution line, Danger Zone grouping, and responsive admin tables.

= 0.2.0 =
* Initial release with opt-in external fetching, connection diagnostics, streaming XML parser, Gutenberg block, shortcode, outage fallbacks, and clean uninstall.
