=== Hermes Conector ===
Contributors: hermesadv
Tags: seo, search-console, analytics, rest-api, law-firm
Requires at least: 5.6
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Optional companion for Hermes, which writes your law firm's blog: read counts, Search Console verification and SEO fields over REST.

== Description ==

[Hermes](https://hermes.adv.br) helps Brazilian law firms keep their own blog up to date. It suggests topics, drafts articles whose case-law citations are checked against official court sources, and schedules them. The firm decides whether each article waits for its approval or goes live on the scheduled date.

Hermes publishes through the standard WordPress REST API, signed in with an Application Password that a site administrator approves. **This plugin is optional: publishing works without it.** It adds what the core REST API does not provide:

* **SEO fields over REST** - registers the Yoast SEO and Rank Math title and description fields in the REST API, so the values Hermes sends are saved instead of silently discarded.
* **Article read counts** - while the site is connected to Hermes, a tiny inline script on single posts records one read per visit: post, time, referrer domain, utm_source and utm_medium, device type, operating system, a truncated network prefix (never the full IP address) and the country sent by Cloudflare, when present. No cookies and nothing stored on the visitor's device. Logged-in users, bots and browsers that send Global Privacy Control or Do Not Track are not counted.
* **Google Search Console verification** - prints the verification meta tag (and serves the matching verification file) so that the firm's own Google account becomes the verified owner of the site.
* **Search engine visibility** - only tells Hermes whether "Discourage search engines from indexing this site" is checked, so Hermes can warn the firm and hold scheduled posts. The plugin never changes this or any other site setting: an administrator changes it in Settings > Reading.
* **Connection status** - Settings > Hermes and Tools > Site Health show whether Hermes can sign in, how many reads arrived and what to fix.

No ads, no upsells, no locked features. A Hermes account is needed to see the data in the Hermes dashboard.

== Installation ==

1. In Hermes, connect your WordPress site (one click, using WordPress Application Passwords).
2. Install and activate this plugin from Plugins > Add New.
3. That's it. Settings > Hermes shows the connection status. We recommend turning on automatic updates for this plugin in the Plugins list.

== Frequently Asked Questions ==

= Do I need this plugin to publish with Hermes? =

No. Hermes publishes with the core REST API. The plugin adds read counts, Search Console verification and the Yoast/Rank Math fields.

= Will it slow down my site? =

No. While the site is connected to Hermes, it adds a small inline script to single posts, loads no external files, sets no cookies and sends one small request to your own site per read. Reads are stored in a small table in your own database and deleted after 180 days.

= Do I need a cookie banner for it? =

The script sets no cookies and stores nothing on the visitor's device. A suggested paragraph for your privacy policy is available under Settings > Privacy > Policy Guide. If your site has visitors in the European Union and uses a consent plugin compatible with the WP Consent API, reads wait for consent to the "statistics" category.

= How do I turn read counting off? =

Untick "Count article reads" in Settings > Hermes, or add `add_filter( 'hermes_conector_contar_leituras', '__return_false' );`.

= Hermes cannot sign in, or my security plugin blocks it =

Wordfence turns application passwords off by default: Wordfence > All Options > Brute Force Protection > untick "Disable WordPress application passwords". If a plugin blocks the REST API for visitors, allow `/wp-json/blog-juridico/v1/batida`, or reads will not be counted. If an optimization plugin delays JavaScript, exclude `hermes-conector-leitura`. Tools > Site Health shows what is wrong.

= My site is behind a CDN other than Cloudflare =

Reads are still counted, but the approximate city may come out wrong, because every visitor seems to come from the CDN. Developers can add the CDN's address ranges with the `hermes_conector_proxies_confiaveis` filter.

= What happens if I deactivate or delete the plugin? =

Publishing keeps working. Read counting stops and the Search Console verification tag goes away, so Google may eventually stop recognizing you as the verified owner; reinstalling fixes it. Deactivating erases the network prefixes and the reload hashes right away. Deleting the plugin also deletes the stored reads and the verification codes.

= I see two copies of Hermes in the Plugins list =

Only one copy works at a time. A notice on the Plugins screen (and on Settings > Hermes) links to deactivating the extra copy; then delete it. Your data is kept. The notice can be dismissed.

== Screenshots ==

1. Settings > Hermes: connection, Google visibility and reads at a glance.
2. Tools > Site Health: Hermes explains what blocks the connection.

== External services ==

This plugin does not send requests to any external server by itself. It only answers requests made to your own site.

**Hermes** (https://hermes.adv.br), the service the law firm uses to write and publish its articles. After an administrator connects the site in the Hermes dashboard, which creates a WordPress Application Password for a user of their choice, Hermes calls these authenticated routes:

* GET /wp-json/blog-juridico/v1/saude - when connecting and about once an hour. Returns the plugin and WordPress versions, the active SEO plugin, whether page caching and read counting are on, whether the site is visible to search engines and what the connected user is allowed to do.
* GET /wp-json/blog-juridico/v1/metricas - about once an hour. Returns the view counter, status, date and link of the posts Hermes published.
* GET /wp-json/blog-juridico/v1/visitas - about once an hour, only for editors or administrators. Returns the reading statistics described under Privacy.
* POST /wp-json/blog-juridico/v1/verificacao-google - when you link Google Search Console in Hermes. Stores the verification code issued by Google.

Hermes Terms of Use: https://hermes.adv.br/termos
Hermes Privacy Policy: https://hermes.adv.br/privacidade

**Google Search Console**: the plugin prints a google-site-verification meta tag (and serves the matching file) that Google's crawler reads to confirm ownership. No visitor data is sent to Google. Google Terms: https://policies.google.com/terms - Google Privacy Policy: https://policies.google.com/privacy

**Cloudflare** (only if your site already uses it): the plugin reads the CF-IPCountry header that Cloudflare adds to each request. Nothing is sent to Cloudflare.

The reading script sends data only to your own site (/wp-json/blog-juridico/v1/batida).

== Privacy ==

* Reads are recorded only while read counting is on (Settings > Hermes) and the site is connected to Hermes (Hermes signed in during the last 30 days).
* Stored in the {prefix}blog_juridico_visitas table: post, date and time, referrer domain, utm_source and utm_medium, device type and operating system (derived from the User-Agent, which is not stored), country (only behind Cloudflare) and a network prefix (IPv4 /24, IPv6 /48) used only to estimate the city.
* The network prefix is erased once Hermes has read the record (usually within a couple of hours) and in any case after 7 days. Records are deleted after 180 days.
* To avoid counting reloads, a keyed hash (HMAC-SHA256 with a key derived from your wp-config.php salts, rotated daily) of the IP address and browser is kept with the record for at most one day, then erased. It is never sent to Hermes and cannot be reversed with the database alone.
* Hermes keeps a copy without the network prefix, with the estimated city, for up to 25 months. The site owner is the controller; Hermes processes the data on the owner's behalf.
* After that day, records cannot be linked to a person, so the plugin does not register personal data exporters or erasers.
* A suggested text for your privacy policy is added to Settings > Privacy > Policy Guide.

== Changelog ==

= 1.0.1 =
* Removed the remote search-visibility route; the plugin no longer changes site settings. Hermes only reads whether the site is visible; the administrator changes it in Settings > Reading.
* Notices appear only on the Plugins screen and on Settings > Hermes, and can be dismissed.
* Translations now come from translate.wordpress.org (no bundled language files).

= 1.0.0 =
* First release on WordPress.org (previously distributed as a zip named "Hermes" 0.6.0 and "Conector Blog Jurídico").
* Reading script loaded through the WordPress script API; respects Global Privacy Control, Do Not Track and the WP Consent API.
* Reads counted, and the script added, only while connected to Hermes; on/off switch in Settings > Hermes.
* No full IP stored; the daily reload hash is erased after one day; rate limits and Origin check on the public route.
* Google verification accepts the full meta tag; verification file served only for valid Google file names, also in subfolder installs.
* Authenticated REST responses marked as not cacheable for page-cache plugins.
* Site Health test, privacy policy suggestion, clean uninstall.
* Brazilian Portuguese translation included.
* The old plugin is no longer deactivated automatically; a notice explains what to do.

= 0.6.0 =
* Renamed to "Hermes"; zip with its own folder.

== Upgrade Notice ==

= 1.0.1 =
Removed the remote search-visibility route; the plugin no longer changes site settings.

= 1.0.0 =
First WordPress.org release. Routes, settings and stored reads are kept. Turn on automatic updates in Plugins to stay current.
