=== Migratik – Migrate & Export Any WordPress Site ===
Contributors: hossamhamdy99
Tags: export, migration, json, headless, markdown
Requires at least: 5.6
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.3.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Migrate & export any WordPress site (content, SEO, media, custom fields) into clean JSON. Works with any page builder. Markdown, WXR & CSV in Pro.

== 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 (everything you need to build 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.

= Free vs Pro =

The free plugin captures **everything** and hands you a JSON file. **Migratik Pro** turns that capture into whatever your destination needs, right from the same screen, no command line:

* **Markdown / MDX** with YAML front-matter for Next.js, Astro, Hugo, and 11ty.
* **WXR** (WordPress eXtended RSS) for WordPress-to-WordPress imports.
* **CSV**: one table per content type, for Sheets, Airtable, or a generic importer.
* **Media bundle**: one click packages every image and file alongside the export and rewrites the URLs to the packaged copies, so the result is self-contained. Large libraries split into parts automatically.

Pro is licensed through Freemius; the free tier never expires.

= 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.

== 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), plus 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.2 =
* Pro: MDX export now uses MDX-specific rendering instead of reusing the Markdown output.
* The free and Pro builds now share the same version number.

= 1.3.0 =
* Freemius licensing built into the free version: in-dashboard upgrade, automatic free-to-Pro switch after purchase, and license management under Migratik → Account.
* Safety: the premium build now silently deactivates a leftover legacy free copy instead of conflicting with it.

= 1.2.0 =
* Pro: Markdown/MDX, WordPress WXR, and CSV export formats.
* Pro: one-click media bundling with URL rewriting (large libraries split into parts automatically).
* Licensing and in-dashboard upgrades via Freemius.
* Fix: correct redirect target for multi-part media bundles.

= 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, Beaver Builder), each item tagged with the render path used.
* Rendered `content_html` + raw `content_raw`, title, slug, permalink, excerpt, dates, menu order, and parent.
* SEO meta (Yoast, Rank Math, AIOSEO, theme fields) and permalinks for building 301 redirects.
* Public custom fields (ACF, JetEngine, Pods), with image fields resolved from attachment IDs to full media objects.
* Featured + in-content images, internal/external links, taxonomies, approved comments (no emails), and navigation menus.
* Optional export of unpublished content (drafts, pending, private, scheduled).
* Settings screen, one-click JSON download, read-only REST endpoints with a rotatable key, full i18n, and clean uninstall.
* Pro (license-gated): export to Markdown/MDX, WXR, and CSV, plus a one-click media bundle that packages every file and rewrites URLs.
