=== Automarticles Sync ===
Contributors: automaticles
Tags: content automation, blog automation, publishing, webhook, seo
Requires at least: 5.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.6.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Official integration between your WordPress site and the Automarticles platform: automatically publish, update and sync posts and categories.

== Description ==

Automarticles is a content generation and management platform for blogs. This plugin connects your WordPress site to your Automarticles account, so posts generated and scheduled on the platform are published automatically on your blog, with no manual copy-pasting required.

**What the plugin does:**

* Receives and creates published/scheduled/draft posts coming from Automarticles, with title, content, description, featured image and category.
* Updates an existing post when it is edited on Automarticles (content, image, status, category).
* Removes a post when it is deleted on Automarticles.
* Creates, updates and organizes categories automatically, avoiding duplicates when the category already exists on your blog.
* Returns the final published post URL back to Automarticles, enabling automatic sharing on social networks.
* Shares your blog's category list with Automarticles, so you can link existing categories instead of creating new ones.

**How it works:**

Communication happens through a token-authenticated webhook: Automarticles sends events (post and category creation/update/deletion) directly to your WordPress site, which processes them and responds. No continuous read access to your blog or installation of external services is required — everything happens inside WordPress itself.

== Installation ==

1. Upload the plugin `.zip` file under **Plugins > Add New > Upload Plugin**, or install it directly from the WordPress plugin search by looking for "Automarticles".
2. Activate the plugin under **Plugins > Installed Plugins**.
3. In the WordPress admin menu, go to **Settings > Automarticles**.
4. Copy the **Token** generated in your Automarticles account (under Settings > Integrations) and paste it into the "Token" field on this screen.
5. Copy the **Webhook URL** shown on this screen and paste it into the matching field in Automarticles.
6. Choose the default **Author** who will be credited on posts published by the plugin (optional).
7. Click **Save Settings**.
8. Go back to Automarticles and click **Verify Integration**.

That's it — from then on, posts published/scheduled on Automarticles are automatically sent to your WordPress site.

== Frequently Asked Questions ==

= Do I need to configure any webhook manually? =

No. The plugin automatically exposes the required endpoint after activation — just paste the URL shown on the plugin's settings screen into your Automarticles account.

= Does the plugin access my blog continuously? =

No. The plugin makes no periodic outbound calls. It only receives and responds to events sent by Automarticles (webhook model), authenticated by a token you control.

= What happens if I already have categories created on my blog? =

You can sync your existing categories with your Automarticles account before publishing, avoiding duplicate categories. This link is always created manually, with your confirmation.

= Does the plugin work with any theme? =

Yes. The plugin works at the content layer (native WordPress posts and categories) and does not depend on any specific theme.

= Where do I find the Token and integration URL for Automarticles? =

Inside your Automarticles account, under Settings > Integrations > WordPress.

== External services ==

This plugin connects your WordPress site to the Automarticles platform (https://automarticles.com), a content generation and management platform for blogs, so posts and categories created there can be published on your blog automatically.

It downloads the featured image of a post from the URL included in the webhook payload your own Automarticles account sends to your site, using `wp_remote_get()`, so the image can be attached to the WordPress post as its featured image. This only happens when Automarticles sends a POST_CREATED or POST_UPDATED event that includes a featured image; no other browsing or periodic data is sent to or fetched from Automarticles.

This service is provided by Automarticles: [Terms of Service](https://automarticles.com/termos) and [Privacy Policy](https://automarticles.com/privacidade).

== Screenshots ==

1. Plugin settings screen inside WordPress.

== Changelog ==

= 1.6.4 =
* Fixed: settings-page CSS/JS are now loaded via `wp_enqueue_style()`/`wp_enqueue_script()` instead of inline `<style>`/`<script>` tags.
* Fixed: renamed the `token_automarticles` and `autor_automarticles` options to `automarticles_token` and `automarticles_autor`, so stored option names are properly prefixed.
* Added: `== External services ==` section documenting the featured-image download from Automarticles.

= 1.6.3 =
* Removed debug `error_log()` calls from the image download routine entirely, instead of just gating them behind `WP_DEBUG`.

= 1.6.2 =
* Fixed: `date()` calls replaced with `gmdate()` for deterministic, timezone-independent date handling.
* Fixed: settings form nonce is now verified before any `$_POST` data is read.
* Fixed: webhook token header is now sanitized and unslashed before use.
* Fixed: debug `error_log()` calls are now gated behind `WP_DEBUG`, so they no longer run by default in production.

= 1.6.1 =
* Security: added a nonce (CSRF protection) to the settings form.
* Security: added output escaping (esc_attr/esc_html/esc_url) to all fields on the settings screen.
* Security: all plugin functions now use the `automarticles_` prefix, avoiding name collisions with other plugins.
* Added protection against direct access to the plugin file.

= 1.6.0 =
* Category resolution now automatically recognizes a category already linked by Automarticles (via the native WordPress ID), instead of relying only on metadata or name.

= 1.5.0 =
* New GET_CATEGORIES event: Automarticles can now read the list of categories that already exist on your WordPress site.
* POST_CREATED and POST_UPDATED now return the published post's public URL.

= 1.4.1 =
* Previous version, with support for creating/updating/deleting posts and categories via webhook.

== Upgrade Notice ==

= 1.6.4 =
Compliance update for the WordPress.org plugin review: enqueued assets, prefixed option names, documented external service. No reconfiguration required.

= 1.6.3 =
Minor cleanup update, no functional changes. No reconfiguration required.

= 1.6.2 =
Recommended update: fixes date handling and hardens nonce/input handling. No reconfiguration required.

= 1.6.1 =
Recommended security update for all users. No reconfiguration required.
