=== Grandranker ===
Contributors: grandranker
Tags: seo, articles, schema, ai, content
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Sync AI-generated articles and inject schema markup from Grandranker into your WordPress site.

== Description ==

Grandranker is an AI-powered SEO platform that helps you create optimized content and track your visibility across AI search engines. This plugin connects your WordPress site to your Grandranker account, enabling seamless content publishing and structured data management.

= Features =

* **Article Sync** — Pull AI-generated articles from Grandranker directly into WordPress posts with a single click or automatically on an hourly schedule.
* **Schema Markup** — Automatically inject JSON-LD structured data into post pages to improve search engine understanding of your content.
* **SEO Meta Integration** — Automatically populate meta titles and descriptions for Yoast SEO and Rank Math.
* **Bulk Sync** — Sync all new and updated articles at once, with outdated detection so you never miss an update.
* **Featured Images** — Automatically sideload featured images from Grandranker into your WordPress media library.
* **Author & Category Mapping** — Map Grandranker authors and categories to their WordPress equivalents, with configurable fallbacks.

= How It Works =

1. Generate your API token in your Grandranker dashboard under Settings > API Tokens.
2. Install this plugin and enter your API URL and token on the Settings page.
3. Select the domain you want to sync articles from.
4. Browse your articles and sync them individually or in bulk.
5. Schema markup is automatically injected into the page head for synced posts.

= Requirements =

* A [Grandranker](https://grandranker.com) account with an active subscription
* An API token with the following scopes: `articles:read` and `schema:read`

== Third-Party Service ==

This plugin connects to the **Grandranker API** to retrieve articles, schema markup, and domain information. Data is sent to and received from the Grandranker servers whenever you:

* Test your API connection
* Fetch your list of domains
* Sync articles (manually or via the hourly auto-sync)
* Generate JSON-LD schema for articles

The API endpoint used is configured in the plugin settings (default: `https://app.grandranker.com`). Your API token is sent as a Bearer token in the Authorization header with each request.

* [Grandranker Website](https://grandranker.com)
* [Terms of Service](https://grandranker.com/terms)
* [Privacy Policy](https://grandranker.com/privacy-policy)

== Installation ==

1. Upload the `grandranker` folder to `/wp-content/plugins/` or install directly from the WordPress plugin directory.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Go to **Grandranker > Settings** and enter your API URL and token.
4. Click **Test Connection** to verify your credentials.
5. Select your domain from the dropdown and save settings.
6. Go to **Grandranker > Articles** to browse and sync your content.

== Frequently Asked Questions ==

= Do I need a Grandranker account to use this plugin? =

Yes. This plugin requires an active Grandranker account and an API token. You can sign up at [grandranker.com](https://grandranker.com).

= What API token scopes do I need? =

Your token needs the `articles:read` and `schema:read` scopes. You can generate a token in your Grandranker dashboard under Settings > API Tokens.

= Does this plugin work with Yoast SEO and Rank Math? =

Yes. When syncing articles, the plugin automatically populates the meta title and meta description fields for both Yoast SEO and Rank Math.

= What happens when I sync an article that already exists? =

The plugin detects previously synced articles by their unique ID. If the article has been updated in Grandranker since the last sync, it will be updated in WordPress. Otherwise, it will be skipped.

= Can I set articles to publish automatically? =

Yes. In the plugin settings, you can choose between "Draft" and "Publish" as the default post status for synced articles.

= How does auto-sync work? =

When enabled, the plugin uses WordPress Cron (WP-Cron) to check for new and updated articles every hour. New articles are created and outdated articles are updated automatically.

= Will deleting the plugin remove my synced posts? =

No. Uninstalling the plugin only removes plugin settings from the database. Your synced WordPress posts remain untouched.

== Changelog ==

= 1.0.1 =
* Fixed: YouTube, Vimeo, Loom, and Wistia iframe embeds were stripped from synced article content (KSES allowlist).
* Fixed: Featured image upload failed on hosts without the PHP `fileinfo` extension (MIME fallback from URL extension).
* Improved: Longer HTTP timeouts (45s GET, 60s POST) for reliability on long-form articles and slower hosts.
* Improved: Prevent duplicate posts when manual sync and auto-sync run on the same article simultaneously.

= 1.0.0 =
* Initial release
* Article sync from Grandranker API
* JSON-LD schema injection
* Yoast SEO and Rank Math meta integration
* Hourly auto-sync via WP-Cron
* Featured image sideloading
* Author and category mapping
