=== Nobeta Connect ===
Contributors: ricardonobeta
Tags: ads.txt, ad tags, publisher, advertising, header tag
Requires at least: 5.7
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.6
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect your WordPress to Nobeta: the ad scripts load automatically and you choose how your ads.txt is handled.

== Description ==

Nobeta Connect is a companion plugin for Nobeta, a third-party advertising service (https://nobeta.com.br/). It requires an active Nobeta account and an API token; without a valid token the plugin cannot serve ads or manage your ads.txt.

For sites that work with Nobeta. After installing, paste your Token API and click Connect. As soon as you connect, the plugin loads the Nobeta ad scripts on your site and reads your current ads.txt to learn and preserve your own lines. The one decision left to you is how your ads.txt should be handled: let Nobeta keep it up to date automatically, or manage it yourself.

What it does:

1. **Connects to Nobeta with your token.** Just paste the Token API that Nobeta sent you. If your token has one site, it is picked automatically. If it has more, you choose.
2. **Loads the Nobeta ad scripts automatically.** When you connect, the plugin loads both Nobeta tag families: the IAB family (gpt.js plus iab.nobeta.com.br) and the Proprietary family (go.nobeta.com.br). Which ad formats appear on each page is controlled by Nobeta, so there is nothing to configure. If your theme already loads a Nobeta family, the plugin reuses it instead of adding it twice, and it never loads gpt.js twice.
3. **Handles your ads.txt, your way.** In the ads.txt card you make one choice: let Nobeta keep your /ads.txt up to date automatically (recommended, the plugin writes and syncs the file and takes a backup before every change), or manage it manually (the plugin shows your ready-to-use lines to copy, and only writes the file when you click "Refresh lines"). Nothing is written to your site until you pick an option and save.
4. **Saves a backup** before each ads.txt change. The 10 most recent are kept.

= Your own ads.txt lines =

If you have ad partners besides Nobeta (your own AdSense, for example), the plugin keeps your lines safe. When you connect, it reads your current ads.txt and learns your own lines automatically, so they are preserved on every update. In manual mode, an advanced "Your personal lines" sub-section shows what it learned and lets you adjust it, or click "Import from my current ads.txt", if you ever need to.

= How Nobeta checks for new lines =

Once a day, Nobeta calls a REST endpoint on your site and compares your current ads.txt with the latest content. If there is anything new, a banner appears on the Dashboard, Plugins and Nobeta Connect screens. The check itself never changes your ads.txt. If you manage your ads.txt manually, nothing is applied until you click "Update now" (or "Refresh lines"). If you let Nobeta manage it automatically, the plugin applies the new lines for you during the daily refresh and keeps a backup.

= External services =

Nobeta Connect is a companion for the Nobeta advertising service and does nothing without it. It contacts the following external services. By using the plugin you agree to these calls.

Nobeta API (server to server, made by your site):

* `https://adm.nobeta.com.br/api/listasites/<token>`: resolves which Nobeta block belongs to your site. WHAT IS SENT: your API token (in the URL path) and your site's home URL (in the request User-Agent). WHEN: when you connect or save the token, and when the Nobeta Connect settings screen is loaded while a token is set but no block has been resolved yet (at most once every 5 minutes). It never runs on other wp-admin pages.
* `https://adm.nobeta.com.br/api/adstxt/content/<token>`: returns the Nobeta ads.txt lines for your block. WHAT IS SENT: your API token (in the URL path) and your site's home URL (in the User-Agent). WHEN: when you connect or save the token; when you turn on automatic management and save; when you click "Refresh lines"/"Update now"; when the Nobeta Connect settings screen is loaded (at most one freshness check every 10 minutes plus one cache refresh every 5 minutes), even in manual mode; once a day via WP-Cron; and when the Nobeta server calls your site's public check endpoint. It never runs on other wp-admin pages.

Your site also exposes POST /wp-json/nobeta/v1/check, a public unauthenticated endpoint that Nobeta calls once a day. Any caller can trigger it; it never changes what your site serves, is rate-limited to one outbound lookup per hour, and returns only whether an ads.txt update is pending.

WHAT IS STORED: the plugin saves your API token, your resolved block and, from the Nobeta response, the account holder name and the list of sites linked to your token, in the WordPress options table. All of it is removed on uninstall.

Advertising scripts (loaded in the visitor's browser once your site is connected):

* `https://iab.nobeta.com.br/<block>` and `https://go.nobeta.com.br/<block>`: the Nobeta ad tags.
* `https://securepubads.g.doubleclick.net/tag/js/gpt.js`: the Google Publisher Tag library, used by the IAB tag.

These advertising scripts run in the visitor's browser and, like any ad tag, may read the visitor's IP address, user agent and browsing context and set cookies in order to serve and measure ads, under Nobeta's and Google's own policies. These scripts load on every public page view once a block is resolved. There is no per-family toggle: to stop them, disconnect the plugin in Settings > Nobeta Connect or deactivate it.

Service terms and privacy policies:

* Nobeta service: https://nobeta.com.br/
* Nobeta privacy policy: https://nobeta.com.br/politica-privacidade/
* Google Publisher Tag, operated by Google LLC. Terms of service: https://policies.google.com/terms
* Google privacy policy: https://policies.google.com/privacy
* Google advertising technologies: https://policies.google.com/technologies/ads
* Google business privacy: https://business.safety.google/privacy/

You, the site owner, are responsible for any cookie/consent notice (GDPR, LGPD, etc.) required for running advertising on your site.

== Installation ==

1. Install the ZIP from **Plugins > Add New > Upload Plugin** and activate.
2. Open **Settings > Nobeta Connect**, paste your Token API and click **Connect**. The Nobeta ad scripts load automatically.
3. In the "ads.txt" card, pick how your /ads.txt should be handled: "Let Nobeta keep my /ads.txt up to date" or "I want to manage my /ads.txt manually", then click **Save changes**. Nothing is written to your ads.txt until you choose.

If you do not have a token, contact Nobeta.

== Frequently Asked Questions ==

= Where do I get the Token API? =

Contact Nobeta. They send the token to you.

= The plugin says the token is invalid. =

Check if you copied the whole token, with no extra spaces. Still failing? Contact Nobeta.

= The token has more than one site. =

The plugin shows a "Choose your site" picker. Pick this WordPress and click Save changes.

= Can the plugin update ads.txt automatically? =

Yes, if you want it to. Nothing is written to your ads.txt until you choose. If you would rather not manage the file by hand, pick "Let Nobeta keep my /ads.txt up to date" in the ads.txt card and save. From then on the plugin keeps /ads.txt in sync automatically, preserves your personal lines, and saves a backup before each change. You can switch back to manual at any time.

= My theme already loads a Nobeta script. Will the plugin duplicate it? =

No. When you connect, the plugin checks your home page first. If your theme already loads the Nobeta IAB endpoint (iab.nobeta.com.br) or the Proprietary endpoint (go.nobeta.com.br), the plugin skips that specific family, and it never loads gpt.js twice.

= What happens to my own AdSense or other partners? =

They are kept. The plugin detects which lines are yours (any line that is not from Nobeta) and preserves them on every update.

= What happens if I deactivate the plugin? =

The scripts stop loading. The last served `ads.txt` is written as a physical file at the site root so `/ads.txt` keeps responding.

= Where are the backups stored? =

In `wp-content/uploads/nobeta-connect/backups/`. The 10 most recent are kept.

= Does the plugin track visitors? =

The plugin itself does not track anyone: on its own it only talks to the Nobeta API using your token. However, once your site is connected, it loads third-party advertising scripts (Nobeta's iab.nobeta.com.br / go.nobeta.com.br and, for the IAB family, Google's gpt.js) into your visitors' browsers. Like any ad tag, those scripts may collect the visitor's IP address, user agent and browsing context and set cookies to serve and measure ads, under Nobeta's and Google's policies (linked in "External services" above). You are responsible for any consent notice your jurisdiction requires.

== Screenshots ==

1. The Connection card: paste the Token API sent by Nobeta. Once connected, the field is masked and the status shows your block.
2. The Ad scripts card: confirmation that the Nobeta ad scripts are loaded on your site.
3. The ads.txt card: let Nobeta keep your /ads.txt up to date, or manage it yourself, with the current file shown for review.
4. History and backups: every backup saved before a change, and the recent activity log.

== Changelog ==

= 1.0.6 =
* First release in the WordPress.org plugin directory.
* Connect the site with the API token sent by Nobeta: the block is resolved automatically and the Nobeta ad scripts start loading, with no tag to paste by hand.
* Choose how your /ads.txt is handled: let Nobeta keep it up to date automatically, or copy the lines and keep managing the file yourself.
* Your own ads.txt lines (an AdSense entry, for example) are read when you connect and preserved on every update.
* A backup is saved before every change to /ads.txt. The last ten are kept and can be downloaded from the settings screen.
* A notice tells you when Nobeta publishes new lines, and it only appears on the Dashboard, the Plugins list and the plugin's own screen.
