=== Facem Web Import & Export Articles ===
Contributors: marredelplata23
Tags: import, export, docx, alt text, ai
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 8.0
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Import a Word/ODT/Markdown/text document as a post draft, or export the current post to DOCX, ODT, PDF or TXT — one button, no LibreOffice.

== Description ==

A single button in the post editor lets you **import** an office document to create a draft, or **export** the current post to a downloadable file. No external rendering tool is required: import and export are 100% native PHP.

**On import:**

* The first level‑1 heading becomes the post title (otherwise the file name is used).
* The **first image** of the document becomes the **featured image**.
* The other images are inserted at their position in the content.
* Each content image is **named** (file + `alt` attribute, on the tag and in the Media Library) after the **subheading that precedes it**.
* Optionally, the `alt` attribute can be generated by an **AI** based on the context and the image (see "External services" below).
* All images are added to the Media Library.
* Content is saved as clean HTML (no visible block markup), readable in Gutenberg, the Classic Editor and page builders.
* The source document is **deleted from the server** immediately after processing.

Supported import formats (native, no server tools): `.docx` (Word), `.odt` (LibreOffice/OpenOffice), `.txt`, `.md` (Markdown).

**On export:** download the current post as `.docx`, `.odt`, `.pdf` or `.txt`, generated entirely in PHP (no LibreOffice). The featured image is placed before the title and content images are embedded (DOCX/ODT/PDF — PDF images require the GD extension, otherwise a text fallback is used). Headings, bold/italic/underline/strikethrough, lists, quotes, tables and alignment are preserved.

**Editors and page builders:** the button appears in Gutenberg and the Classic Editor, a button is injected into the Elementor editor panel, and a "Document" entry is added to the WordPress admin bar as a universal fallback. On export, content built with Divi (shortcodes) or Elementor (post meta) is rendered to HTML before conversion.

**Internationalization:** the interface follows the WordPress site language. Translations are bundled for many European and Asian languages, and a `.pot` template is provided.

== External services ==

This plugin can optionally connect to a third‑party AI API **only if you enable it** in Settings → Import / Export articles and provide an API key. It is **disabled by default**.

When enabled, during import the plugin sends, for each imported image, the following data to the provider you select in order to generate the image `alt` text:

* the surrounding textual context (post title, the preceding subheading, and a short excerpt of nearby text);
* and, if the "Analyze the image (vision)" option is enabled, the image itself.

Supported providers and their endpoints:

* **Mistral AI** — requests sent to https://api.mistral.ai/v1/chat/completions. Terms: https://mistral.ai/terms/ — Privacy: https://mistral.ai/terms/#privacy-policy
* **OpenAI** — requests sent to https://api.openai.com/v1/chat/completions. Terms: https://openai.com/policies/terms-of-use/ — Privacy: https://openai.com/policies/privacy-policy/

No data is sent to any external service when the AI option is disabled. The API key is stored in your site's database and used only to authenticate these requests.

== Installation ==

1. Upload the `import-export-articles` folder to `/wp-content/plugins/`, or install the ZIP from Plugins → Add New → Upload Plugin.
2. Activate the plugin through the Plugins menu.
3. Open a post (new or existing): the **Document** button appears in the editor toolbar (and in the admin bar).
4. (Optional) To enable AI‑generated alt text, go to Settings → Import / Export articles, choose a provider, paste your API key and enable it.

== Frequently Asked Questions ==

= Is the imported document stored on the server? =

No. It is read in a temporary file and deleted immediately after conversion, whether the conversion succeeds or fails. Only the images extracted from the document are kept, added to the Media Library so they can be displayed.

= Does it work with Gutenberg, the Classic Editor and page builders? =

Yes. The import creates a standard draft (clean HTML) that any editor can open. The export renders Divi and Elementor content to HTML before conversion.

= Is AI required? =

No. AI is optional and disabled by default. Without it, the image `alt` text is set from the preceding subheading.

= Which languages are available? =

The source language is French; the UI follows the WordPress site language. Ready‑to‑use translations are bundled (English, Spanish, German, Italian, Portuguese, Dutch, Polish, Russian, Simplified Chinese, Japanese, Korean, Arabic, Hindi, Indonesian, Vietnamese, Thai) and a `.pot` template is provided.

== Screenshots ==

1. The import / export modal opened from the "Document" button in the post editor.
2. The settings page to connect an AI provider (Mistral / OpenAI) for alt text.

== Changelog ==

= 1.0.0 =
* Initial release.
* One‑button import (DOCX, ODT, TXT, MD) to a post draft: first image as featured image, other images placed in context and named/alt‑tagged after the preceding subheading.
* Export to DOCX, ODT, PDF, TXT (native PHP, no LibreOffice).
* Optional AI‑generated alt text (Mistral, OpenAI), disabled by default.
* Gutenberg, Classic Editor and page builder support (Divi, Elementor); admin bar entry.
* Internationalization with bundled translations.

== Upgrade Notice ==

= 1.0.0 =
First public release.
