=== 3Min API Connector ===
Contributors: 3minapi
Tags: api, shortcode, forms, rest-api, ai
Requires at least: 6.5
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Build a UI for your 3Min API data in HTML / CSS / JavaScript, and embed it on any post or page via a shortcode.

== Description ==

3Min API Connector is the official WordPress plugin for [3Min API](https://3minapi.com) — a SaaS that turns any data model into an HTTP endpoint with its own API key.

The plugin pairs each endpoint with an editable HTML / CSS / JavaScript snippet, then renders that snippet on any page via a single shortcode:

`[3minapi name="your-snippet"]`

A built-in **Snippet Builder** walks you through pasting an endpoint + key, testing the response, picking a starter template, and finishing the UI with an LLM (ChatGPT / Claude / Gemini) using a one-click **Copy AI prompt** button.

= Features =

* **One shortcode** — `[3minapi name="..."]` for every snippet. Same shortcode can appear on multiple pages, and a single page can hold several different snippets.
* **Four modes** — Get Record (display a single record), Get List (paginated collection with `threeminApi.fetch()` for "Load more"), POST (submit a form to your endpoint), and by-id helpers (`threeminApi.fetchById` / `update` / `delete`) for record-scoped UI.
* **Six built-in templates** — Card, List, Hero, List feed, Form, Comment. Pick one and iterate with AI.
* **Copy AI prompt** — generates a tuned system prompt with the plugin's authoring rules baked in. Paste into your LLM, iterate on the UI, paste the result back into the Builder.
* **JavaScript (optional) pane** — inline JS per snippet, auto-wrapped with a `scope` parameter; lifecycle hooks `before-submit` / `success` / `error` for POST forms.
* **Live preview** in the Builder with server-rendered data.
* **Response caching** via the WordPress Transients API (tunable via the `3minapi_cache_ttl` filter).
* **i18n-ready** — `.pot` template plus translations for English, Korean, Simplified Chinese, Traditional Chinese, Spanish, and Japanese.

= Security =

* The API key is stored per-snippet, **server-side only** — never exposed to the browser, even in the Builder.
* All requests to 3Min API are proxied through admin-ajax on the server. No direct browser → 3Min API call.
* User-defined templates support `{{variable}}` substitution only — PHP tags are stripped on save and never executed.
* `<script>` tags in the HTML/CSS pane are stripped on save; JavaScript lives in a separate pane that requires the `unfiltered_html` capability (Administrator by default on single-site WordPress).
* Every AJAX endpoint verifies a WordPress nonce and a capability check.

= Requirements =

* WordPress 6.5+
* PHP 7.4+
* A free or paid account at [3minapi.com](https://3minapi.com) to obtain endpoints and API keys.

== Installation ==

1. Upload and activate the plugin.
2. Open **3Min API → Overview** in the admin menu and read the quick start.
3. Click **+ New**, paste an endpoint ID + API key, choose an HTTP method, and press **Test endpoint**.
4. Pick a starter template, optionally click **Copy AI prompt** and iterate the UI with your favorite LLM.
5. Save the snippet, then drop `[3minapi name="your-snippet"]` into any post, page, widget, or block.

== Frequently Asked Questions ==

= Where do I get an endpoint and API key? =

Sign up at [3minapi.com](https://3minapi.com). Each data model you create gives you an endpoint ID and a unique API key — paste both into the Snippet Builder.

= Is the API key sent to the browser? =

No. The API key is stored in `wp_options` and only read by the server-side AJAX handlers when proxying requests to 3Min API. The browser never sees it.

= Does the plugin store visitor data? =

No. Form submissions are forwarded to 3Min API and the response (a queue acknowledgement) is returned to the page. The plugin does not persist visitor data on your WordPress site.

= Can I add a new translation? =

Yes — copy `languages/3minapi-connector.pot` to `3minapi-connector-<locale>.po`, translate, compile to `.mo`, and drop both files into the `languages/` directory. PRs are welcome at the plugin's GitHub repository.

= Can I route requests through a self-hosted mirror or staging endpoint? =

Yes. Use the `3minapi_base_url` filter to override the production host.

== Screenshots ==

1. Overview tab — orientation, quick start, and authoring guides.
2. Snippets list — search, copy shortcode, edit, delete.
3. Snippet Builder — endpoint configuration with test result and detected variables.
4. Template gallery with live preview — six built-in starters across Get Record / Get List / POST, plus one-click AI prompt copy.
5. Snippet rendered on a page via `[3minapi name="..."]`.

== Changelog ==

= 1.0.0 =
* Snippet Builder UI with live preview, six built-in templates, and one-click AI prompt copy.
* Four modes: Get Record, Get List (with `threeminApi.fetch` pagination), POST, and by-id helpers.
* Optional per-snippet JavaScript pane with lifecycle hooks.
* `unfiltered_html` capability gate for the JS pane.
* i18n infrastructure with `.pot` template and translations for en, ko_KR, zh_CN, zh_TW, es_ES, ja.
* Production base URL.

= 0.1.0 =
* Initial release: plugin skeleton, settings page, API key validation.
