=== Post Tags Export/Import ===
Contributors: baiatulutata
Tags: export, import, migration, tag management, bulk edit
Requires at least: 5.0
Tested up to: 6.9
Requires PHP: 7.2
Stable tag: 1.4.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A simple and lightweight plugin to export all posts to a JSON file and import tags from a JSON file to update posts, matching them by slug.

== Description ==

Do you need to back up your post tags, migrate them to another site, or perform a bulk update in a spreadsheet? **Post Tags Export/Import** is the perfect tool for the job.

This plugin provides a simple interface under "Tools" in your WordPress admin area to handle two key tasks:

1.  **Export Posts to JSON:** With a single click, you can download a clean JSON file containing the `title`, `slug`, and an array of `tags` for every post on your site.
2.  **Import Tags from JSON:** Upload a JSON file (in the same format as the one you exported) to bulk update tags. The plugin uses the post `slug` to identify which post to update and **replaces** its existing tags with the ones from the file.

This is incredibly useful for:
* Backing up and restoring tag structures.
* Editing tags offline in bulk using a text editor or script.
* Migrating tag information between staging and production environments.
* Quickly applying a new set of tags to hundreds of posts.

The plugin is designed to be lightweight, secure, and easy to use.

== Installation ==

You can install the plugin in a few simple steps:

**From your WordPress dashboard (easiest):**
1. Navigate to 'Plugins' > 'Add New'.
2. Search for 'Post Tags Export/Import'.
3. Click 'Install Now' and then 'Activate'.

**Manual Installation:**
1. Download the plugin zip file from the repository.
2. Unzip the file to get the `post-tags-export-import` directory.
3. Upload the `post-tags-export-import` directory to the `/wp-content/plugins/` directory on your server.
4. Go to the 'Plugins' page in your WordPress admin and click 'Activate' for the "Post Tags Export/Import" plugin.

**After Activation:**
1. Navigate to 'Tools' > 'Post Tags Export/Import' to access the plugin's page.

== Frequently Asked Questions ==

= Where do I find the settings page? =
You can find the plugin's page in your WordPress admin dashboard under **Tools -> Post Tags Export/Import**.

= What is the format of the JSON file? =
The JSON file is an array of objects. Each object represents a post and must contain a `slug` (string) and `tags` (array of strings). The `title` is included for reference in the export but is not used during the import.

Example:
`[
    {
        "title": "My First Blog Post",
        "slug": "my-first-blog-post",
        "tags": ["news", "updates"]
    },
    {
        "title": "A Guide to WordPress",
        "slug": "a-guide-to-wordpress",
        "tags": ["wordpress", "guide", "tutorial"]
    }
]`

= What happens if a slug in my import file doesn't exist on my site? =
The plugin will simply skip that entry. The success message after the import will tell you how many posts were updated and how many were skipped.

= Does the import add to existing tags or replace them? =
The import process **replaces** all existing tags on a post with the tags provided in the JSON file for that post's slug. If the "tags" array for a post is empty in the file, it will remove all tags from that post.

= Will this plugin work with Custom Post Types? =
Currently, the plugin is designed to work only with the default 'post' post type.

== Screenshots ==

1. The main admin page showing the Export and Import sections.
2. The success notice after a successful import, showing updated and skipped counts.
3. An example of the exported JSON file structure.

== Changelog ==
= 1.4.2 =
*  Sanitize early, Escape Late, Always Validate
= 1.4.1 =
* Update readme.txt and readme.md for clarity.
* Verified compatibility up to WordPress 6.8.

= 1.4.0 =
* Security Enhancement: Refactored all function names with the `PTIMPEX_` prefix to prevent conflicts.
* Added `Requires at least` and `Requires PHP` headers for better dependency management.
* Minor code cleanup and comment improvements.

= 1.0.0 =
* Initial release.
* Functionality to export all posts to JSON.
* Functionality to import tags from JSON, replacing existing tags.
