=== Kainoto Simple RSS Importer ===
Contributors: dusanvr
Requires at least: 5.0
Tested up to: 7.0
Stable tag: 2.3
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A simple and secure plugin to import posts from an RSS or Atom feed (URL or file) with date, category, and content cleaning support.

== Description ==

This plugin provides a straightforward interface for WordPress administrators to import posts from an RSS 2.0 or Atom feed — by pasting a feed URL or uploading a feed file. It is designed to solve common import problems, such as content corruption from aggressive sanitization, by performing minimal processing.

Key Features:
* Import posts from a feed URL (e.g. Blogger/Blogspot) or an uploaded RSS/XML file.
* Supports both RSS 2.0 and Atom feeds.
* AJAX-based import with a live progress bar and per-post log — avoids server timeouts on large feeds.
* Reliable duplicate detection: posts are matched by the feed item's unique ID (stored in post meta), with a title fallback.
* Handles untitled posts (common on Blogger) by generating a title from the content.
* Correctly imports post publication dates.
* Option to import feed categories/labels as either WordPress Categories or Tags.
* Option to import as Published or Draft.
* Option to tag all imported/updated posts with custom tags, so they are easy to find after the import.
* Option to overwrite existing posts.
* Advanced content cleaning:
    * Remove all `style` and `class` attributes from HTML.
    * Remove specific tags (like `span`, `font`) while keeping the text inside them.
    * Fixes unwanted line breaks and extra spaces.
* Securely built with WordPress coding standards, including nonce verification and capability checks.

== Installation ==

1.  Upload the `kainoto-simple-rss-importer` folder to the `/wp-content/plugins/` directory.
2.  Activate the plugin through the 'Plugins' menu in WordPress.
3.  Navigate to the "Kainoto RSS Importer" page in the admin menu to begin.

== Frequently Asked Questions ==

= How many posts does a Blogger feed return? =

Blogger feeds return 25 posts by default. Append `?max-results=500` to the feed URL (or `&max-results=500` if the URL already contains `?`) to import more at once.

= How are duplicates detected? =

Each imported post stores the feed item's unique ID (`guid` in RSS, `id` in Atom) in post meta. On re-import, that ID is checked first. As a fallback, a post counts as a duplicate only if it has the identical title AND roughly the same content length (within ~10%) — so blogs that intentionally reuse the same title for many posts still import correctly. Untitled items are never matched by title.

== Upgrade Notice ==

= 2.3 =
Major update: import from feed URLs, Atom/Blogger support, AJAX import with live progress, reliable duplicate detection by feed ID, tagging of imported posts, and automatic featured images from post content. Review your import settings after updating.

== Changelog ==

= 2.3 =
* NEW: Featured image support — the first image in the post content is downloaded to the Media Library and set as the featured image (skipped for posts that already have one). Blogger image URLs are upgraded to their full-size variant automatically.
* FIX: Distinct posts sharing the same title could still be skipped as duplicates within one import run. Posts already carrying a different feed ID are now excluded from the title-fallback match, so the length heuristic only ever applies to posts imported before feed IDs were stored.

= 2.2 =
* NEW: "Tag Imported Posts" option — comma-separated tags added to every post the import creates or updates, so imported posts are easy to find and filter afterwards. Tags are appended, so labels imported from the feed are kept.

= 2.1 =
* FIX: Posts that intentionally share the same title were skipped as duplicates. The title fallback match now also requires the existing post's content length to be within ~10% of the incoming content, and all same-title posts are compared (not just the first one found).

= 2.0 =
* NEW: Import directly from a feed URL, not just a file upload.
* NEW: Atom feed support (Blogger's default format).
* NEW: AJAX-based import with live progress bar and per-post result log.
* NEW: Choose Published or Draft status for imported posts.
* FIX: Untitled feed items (common on Blogger) were wrongly reported as duplicates and skipped — WP_Query ignores an empty title and matched an arbitrary post. Duplicates are now matched by the feed item's unique ID first, and untitled posts get a title generated from their content.
* FIX: Invalid `post_status` value in the duplicate-check query.
* FIX: Overwriting an existing post now also updates its title.
* FIX: User-supplied tag names are regex-escaped before content cleaning.
* FIX: Content is no longer double-decoded when the feed already contains real HTML.
* TWEAK: Falls back to `content:encoded` handling for RSS feeds that use it.

= 1.6 =
* SECURITY: Hardened file upload and POST data handling to meet strict WordPress standards.
* FIX: Replaced deprecated `get_page_by_title()` with modern `WP_Query`.
* FIX: Escaped all admin notices for improved security.
* TWEAK: Removed broken image link from disclaimer.

= 1.5 =
* Initial stable release.
