=== Ad Engine - Gerenciador de Adx, Adsense e AdManager ===
Contributors: winup, winupsites
Tags: ads, ad inserter, ad engine, publishers, monetization
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.3.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Ad placement engine for publishers. Insert ads anywhere on your WordPress site.

== Description ==

**Ad Engine - Gerenciador de Adx, Adsense e AdManager** is a powerful ad placement tool for WordPress publishers. Configure up to 16 independent ad blocks and insert them anywhere on your site — before or after content, between paragraphs, in the header, footer, sidebar, or via shortcode.

= Features =

* 16 independently configurable ad blocks
* Insert ads anywhere: before/after content, between paragraphs, header, footer, shortcode, widgets
* Filters by post type, categories and tags
* Device detection (desktop, mobile, tablet)
* Scheduling by day of the week and time
* Request count per block
* Native Lazy Loading with IntersectionObserver
* Shortcode `[winup_ad id="1"]` for manual placement
* Sidebar widget
* Export and import block configuration as JSON
* Syntax highlighting in the code editors
* `ads.txt` written physically at the domain root (via WP_Filesystem), with a virtual PHP-served fallback when physical writing isn't possible
* Change history showing who changed each block, setting or ads.txt, and where the change came from

= Coming soon =

* Ad Engine - Gerenciador de Adx, Adsense e AdManager Pro — advanced metrics, per-block reports, estimated RPM and performance charts

== Installation ==

1. Upload the `winup-ad-engine` folder to the `/wp-content/plugins/` directory
2. Activate the plugin through the **Plugins** menu in WordPress
3. Go to **Ad Engine - Gerenciador de Adx, Adsense e AdManager** in the WordPress admin sidebar
4. Configure your ad blocks

== Frequently Asked Questions ==

= How many blocks can I configure? =

16 independent blocks, each with its own settings for position, device, scheduling and more.

= Does the shortcode work anywhere? =

Yes. Use `[winup_ad id="X"]` (where X is the block number from 1 to 16) in posts, pages or any area that supports shortcodes.

= Can I copy the configuration from one site to another? =

Yes. Use the export button to download a JSON file with the block configuration, then import it on the destination site. Import offers two modes: merge (only replaces blocks that have content in the file) and replace all.

= How is ads.txt served, and what happens if I deactivate the plugin? =

Whenever your server allows direct file writes, Ad Engine writes `ads.txt` physically at your domain root (using WP_Filesystem), where ad networks expect to find it at `https://yourdomain.com/ads.txt`. If direct writes aren't possible (subdirectory installs, path-based multisite networks, read-only filesystems), it serves the same content virtually through PHP, so ads.txt keeps working either way. **Deactivating or uninstalling the plugin does not delete the physical `ads.txt` file** — removing it automatically would immediately break every ad network relying on it, so the file is left in place; delete it manually if you no longer want it. Uninstalling removes only the change history table.

== Changelog ==

= 1.3.0 =
* Novo: o `ads.txt` passa a ser gravado fisicamente na raiz do domínio (via WP_Filesystem), com modo virtual (PHP) como fallback automático quando a escrita física não é possível (instalação em subdiretório, multisite por subdiretório, permissão de arquivo).
* Novo: na ativação, um `ads.txt` físico preexistente é importado para o editor, com backup do arquivo original. Se o conteúdo divergir do que já estava salvo, o plugin pergunta qual versão manter, sem sobrescrever nenhuma.
* Novo: detecção de alteração do `ads.txt` feita fora do plugin (FTP, deploy), com a mesma opção de escolher qual versão manter.
* Novo: indicador na aba ADS.TXT mostrando se o arquivo é servido fisicamente ou em modo virtual, com o motivo quando aplicável.
* Novo: histórico de modificações no painel, registrando qual usuário alterou cada bloco, configuração ou `ads.txt` e a origem da mudança (painel, importação, WP-CLI ou sistema).
* Novo: os campos "Exibir apenas em" e "Ocultar em" aceitam o ID do post ou da página, além do slug, na mesma lista separada por vírgula.
* Novo: ícone de ajuda nos campos de exibição por página, com instruções de uso.
* Novo: comandos WP-CLI `wp winup ads-txt status|sync|import`.
* Correção: edições do `ads.txt` feitas no painel não apareciam em /ads.txt quando havia um arquivo físico no servidor.
* Correção: /ads.txt continua respondendo mesmo se o arquivo físico for removido por FTP, restore ou deploy.
* Correção: a importação de blocos (JSON) agora também atualiza o arquivo `ads.txt` físico.
* Correção: a resposta virtual do `ads.txt` usava `wp_kses_post()`, que escapava indevidamente `&` e `<` numa resposta `text/plain`; o cache foi reduzido para 5 minutos, com revalidação por ETag.
* Correção: a barra de rolagem dos editores de código não respondia ao arrastar nem à roda do mouse.
* Correção: o card do módulo no painel mostrava a versão 1.0.0 em vez da versão instalada.
* Correção: a logo da Winup aparecia incompleta ("Win") no cabeçalho do painel.
* Correção: "home" não funcionava nos campos de exibição por página quando a página inicial do site era uma página estática.
* Ajuste: destaque de colchetes correspondentes no editor de código sem sublinhado, para melhor leitura.

= 1.2.1 =
* Correção: o atributo `slot` da tag `<winupads>` (e os atributos relacionados `sizes`, `refresh`, `priority` e `collapse`) não é mais descartado ao salvar o bloco — permite segmentar um slot específico do GAM.

= 1.2.0 =
* Ajuste: plugin renomeado para Ad Engine - Gerenciador de Adx, Adsense e AdManager.
* Novo: syntax highlighting (CodeMirror) nos editores de código dos blocos e das configurações globais.
* Novo: exportação e importação da configuração dos blocos em JSON, com modos de mesclagem e substituição total.
* Correção: código de anúncio com a tag `<winupads>` não é mais descartado ao salvar o bloco.
* Correção: os blocos passam a ser injetados também em temas/page builders que aplicam o filtro `the_content` fora do loop principal.

= 1.1.0 =
* Correção: código de anúncio com <script> (Google Publisher Tag/AdSense) não é mais removido na sanitização.
* Correção: erro "div já associado a outro slot" do GPT em blocos com lazy-load (script deixou de ser executado em duplicidade).
* Novo: indicador na barra de administração mostrando os blocos ativos na página atual.
* Ajuste: nome do menu na barra lateral encurtado para "Winup Ad Engine".

= 1.0.5 =
* Plugin renamed to Winup Ad Engine - Gerenciador de Adx e Ads.
* Compliance fixes: plugin headers updated, version synced.
* Security improvements: additional escaping in admin templates.
* Updated readme.txt for WordPress.org directory compliance.

= 1.0.4 =
* Internal improvements and bug fixes.

= 1.0.3 =
* Internal improvements and bug fixes.

= 1.0.2 =
* Internal improvements and bug fixes.

= 1.0.1 =
* Internal improvements and bug fixes.

= 1.0.0 =
* Initial release with full Winup Ad Engine - Gerenciador de Adx e Ads module.

== Upgrade Notice ==

= 1.3.0 =
Recommended update: ads.txt is now written physically at the domain root with automatic virtual fallback, and a pre-existing file is imported instead of overwritten. Adds a change history showing who changed what, WP-CLI ads-txt commands, and code editor fixes.

= 1.2.1 =
Recommended update: fixes the `slot` attribute (and related attributes) on the `<winupads>` tag being stripped on save, which prevented targeting a specific GAM slot.

= 1.2.0 =
Plugin renamed to Ad Engine - Gerenciador de Adx, Adsense e AdManager. Recommended update: adds export/import of block configuration and syntax highlighting, and fixes ad code being stripped on save (`<winupads>` tag) and missing injection on themes that render content outside the main loop.

= 1.1.0 =
Recommended update: fixes ad <script> sanitization, resolves GPT duplicate-slot errors on lazy-loaded blocks, and adds a per-page block status indicator in the admin bar.

= 1.0.5 =
Recommended update with security improvements, compliance fixes and plugin rename.

= 1.0.0 =
Initial release.