=== Internal Pingback Comments ===
Contributors: pontocinza
Donate link: https://pontocinza.com.br/apoiando-o-ponto/
Tags: pingback, internal links, comments
Requires at least: 5.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

Detects internal links in posts and automatically inserts a pingback-style comment on each linked post. No XML-RPC required.

== Description ==

When a post is published or updated, Internal Pingback Comments scans its content, finds all internal links, and creates a pingback-style comment on each linked post. It mimics native WordPress pingback behavior but eliminates the need for XML-RPC or outbound network requests.

Works with posts only. No settings page, no configuration.

**How it works**

The plugin parses post content with DOMDocument — not regex — so it handles real-world HTML correctly: nested tags, encoded entities, relative and protocol-relative URLs. For each internal link found, it inserts a pingback comment on the target post. The comment includes a short excerpt from the source post, with image captions (figcaption) stripped so they do not bleed into the pingback text.

Duplicate detection is precise: the source permalink is stored as private comment meta, and the plugin queries that meta before every insert. Republishing or updating a post never creates duplicate comments. New links added to an existing post will generate their own pingbacks on the next save.

**What the pingback looks like to your theme**

The comment is stored with `comment_type = 'pingback'` and auto-approved. Your theme renders it exactly as it would render a native pingback. If your theme does not display pingbacks, the comment will be stored in the database but remain hidden on the front end.

== Installation ==

1. Upload the `internal-pingback-comments` folder to `/wp-content/plugins/`, or install it directly from the WordPress Plugins screen.
2. Activate the plugin.
3. Done. Pingbacks will be created automatically the next time you publish or update a post.

== Frequently Asked Questions ==

= Does this plugin use XML-RPC? =

No. Comments are inserted directly with `wp_insert_comment()`. No XML-RPC, no outbound network requests.

= Does it work with pages or custom post types? =

No. This plugin processes posts only, on both the source and target side.

= Will it create pingbacks for posts published before activation? =

No. It only processes posts published or updated after activation. To backfill an older post, open it in the editor and save it again.

= What happens if I update a post and add a new internal link? =

The plugin re-scans the content on every save. The new link will generate a new pingback. Removed links do not delete existing pingback comments.

= Will it create duplicate pingbacks if I save the same post multiple times? =

No. Before inserting, the plugin checks for an existing pingback from the same source. If one is found, the insert is skipped.

= Are pingback comments auto-approved? =

Yes. Comments are inserted with `comment_approved = 1`. You can edit or delete them individually from the WordPress Comments screen.

= Is it multisite-compatible? =

The plugin works correctly within each site on a multisite network. It does not create cross-site pingbacks between subsites.

== Disclaimer ==

This plugin is provided "as is", without warranty of any kind. While best efforts have been made to ensure reliability and security, the author is not liable for any damages or losses resulting from its use.

== Screenshots ==

1. The plugin runs entirely in the background. There is no settings page, keeping the WordPress dashboard clean.

== Changelog ==

= 1.0.1 =
* Simplified: plugin now works with posts only, removing the settings page entirely.
* Fixed: Stripped 'figcaption' blocks to ensure captions are excluded from the pingback.
* Fixed: Gutenberg's double-save pattern no longer causes duplicate pingbacks within the same request.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.1 =
Plugin now works with posts only.