=== Migratik ===
Contributors: hossamhamdy99
Tags: migration, export, json, headless, seo
Requires at least: 5.6
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.3.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Pack up any WordPress site — any builder — into one clean JSON file for migration, preserving SEO signals, internal links, and images.

== Description ==

**Migratik** packs up an entire WordPress site — every article, page, service, and custom post type — into one clean JSON file, ready to migrate to a new stack (headless, Next.js, or anywhere) while keeping everything that matters for SEO.

It was built to migrate a live WPBakery site to a Next.js + Supabase stack, then generalized into a reusable tool. It is **read-only**: it only reads your content and hands you a file. Nothing on your site is changed.

= What it captures =

For every published item, Migratik records:

* Rendered `content_html` (builder shortcodes and blocks executed) plus the original `content_raw`.
* Title, `document_title` (the theme-rendered `<title>`), slug, and permalink — for building 301 redirects.
* Excerpt, publish/modified dates, menu order, and parent.
* Featured image (URL, alt, dimensions) and every in-content image (src + alt).
* Image custom fields (ACF/JetEngine/Pods) resolved from attachment IDs to real media objects (URL, alt, dimensions) in a `custom_fields_media` map.
* Internal and external links with anchor text, parsed from the rendered HTML.
* Taxonomies (categories, tags, and custom taxonomies) as name + slug.
* SEO meta from Yoast, Rank Math, All in One SEO, or theme fields.
* Approved comments per item (author, date, text, threading) — commenter emails are never included.
* Navigation menus (structure, items, and theme locations) as a top-level `menus` list.
* Optionally, unpublished content (drafts, pending, private, scheduled) — each item carries its `status`.

= Builder-agnostic =

Each item is rendered with the right method and tagged with the path used, so empty renders are detectable:

* **Elementor** via the Elementor frontend renderer.
* **Beaver Builder** via `FLBuilder::render_content_by_id()`.
* **Bricks** via the Bricks frontend renderer (`\Bricks\Frontend::render_data()`).
* **Oxygen** via Oxygen's own render pipeline (JSON elements on 4.0+, classic shortcodes otherwise).
* **Gutenberg, Classic editor, WPBakery, Divi, and plain HTML** via the standard `the_content` pipeline.

= Configurable =

Under **Migratik** in the admin menu you can choose which content types to export, toggle whether the raw `post_content` is included, and rotate the REST API key.

= Automation (REST) =

Two read-only endpoints back the export for automation:

* `GET /wp-json/migratik/v1/manifest` — counts per content type.
* `GET /wp-json/migratik/v1/all` — the full export payload.

Both require a logged-in administrator **or** the Migratik REST key (`?key=...`). The one-click admin download uses a nonce and needs no key.

**Migratik Pro** (optional, upgrade from inside your dashboard): adds Markdown/MDX, WordPress WXR and CSV export formats, plus one-click media bundling with rewritten URLs.

== Installation ==

1. Upload the `migratik` folder to `/wp-content/plugins/`, or install the zip via **Plugins → Add New → Upload Plugin**.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Go to **Migratik** in the admin menu.
4. (Optional) Adjust content types, raw-content, and the REST key under **Settings** on that screen.
5. Review the counts, then click **Download Migratik (JSON)**.
6. When your migration is done, you can safely delete the plugin — it leaves nothing behind.

== Frequently Asked Questions ==

= Is it safe to run on a live site? =

Yes. Migratik is read-only — it only reads content and returns a JSON file. It never writes to your posts, options (beyond its own settings), or database content.

= Which page builders are supported? =

Gutenberg, Classic editor, WPBakery, Divi, Elementor, Beaver Builder, Bricks, and Oxygen. Anything that renders through `the_content` is handled by the default path.

= Does it include SEO data? =

Yes — titles, slugs and permalinks (for redirects), and any stored SEO meta (Yoast, Rank Math, All in One SEO, or theme fields matched by key pattern).

= Can I choose what gets exported? =

Yes. Under **Migratik** in the admin menu you can pick which content types to include and toggle whether the raw `post_content` is exported alongside the rendered HTML.

= What do I need the REST key for? =

Only for the REST endpoints, if you want to automate exports without an admin session. The admin Download button uses a nonce and never needs the key. You can rotate the key from the settings screen, or pin it by defining `MIGRATIK_KEY` in `wp-config.php`.

= Does it clean up after itself? =

Yes. Deleting the plugin removes its single stored option. There are no custom tables, post meta, or scheduled tasks to leave behind.

== Screenshots ==

1. The Migratik screen: a summary of what will be packed and the one-click JSON download.
2. The Settings section: choose content types, toggle raw content, and rotate the REST API key.

== Changelog ==

= 1.3.0 =
* New: upgrade to Migratik Pro from inside the dashboard — Markdown/MDX, WordPress WXR and CSV exports, plus one-click media bundling (optional paid upgrade).
* New: license and account management under Migratik → Account (powered by the Freemius SDK, opt-in only).
* Safety: silently retires a leftover legacy copy of the plugin instead of conflicting with it.

= 1.1.3 =
* Fix: the Settings link on the Plugins screen pointed to the old Tools location.

= 1.1.2 =
* New brand icon for the Migratik admin menu.
* New REST API keys now use the mgk_ prefix (existing keys keep working).
* Docs: menu references updated to the new top-level Migratik menu.

= 1.1.1 =

* Migratik now has its own top-level admin menu with a brand icon, instead of living under Tools.

= 1.1.0 =

* Added **Bricks** and **Oxygen** support — content from both builders is now rendered and captured (Bricks via the Bricks frontend renderer; Oxygen via its JSON elements on 4.0+ or classic shortcodes), each item tagged with the render path used.
* Excluded Oxygen's internal builder meta (`ct_*`) from captured custom fields.

= 1.0.0 =
Initial release.

* Builder-agnostic content export — Gutenberg, Classic, WPBakery, Divi, Elementor, and Beaver Builder — rendered with the right method and tagged with the path used.
* Captures rendered `content_html` plus the original `content_raw`, title, slug, permalink, excerpt, dates, menu order, and parent.
* SEO meta from Yoast, Rank Math, All in One SEO, or theme fields, plus permalinks for building 301 redirects.
* Public custom fields (ACF, JetEngine, Pods), with image fields resolved from attachment IDs to full media objects.
* Featured and in-content images, internal and external links, and taxonomies.
* Approved comments (without emails) and navigation menus.
* Optional export of unpublished content (drafts, pending, private, scheduled).
* Settings screen to choose content types and toggles; one-click JSON download; read-only REST endpoints guarded by a rotatable key; full i18n; clean uninstall.
