=== Safe Elementor Search Replace ===
Contributors: mostafanoor
Tags: elementor, search replace, url replace, gutenberg, backup, rollback
Requires at least: 5.8
Tested up to: 6.6
Requires PHP: 7.4
Stable tag: 1.2.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Safe Elementor text replacement plus preview-first whole-site URL replacement for WordPress, Gutenberg, Elementor, post meta and persistent site options — with automatic backups and 7-day rollback.

== Description ==

Safe Elementor Search Replace lets you find and replace text inside content built with Elementor (both free and Pro) without risking corrupted layouts.

Key safety features:

* Automatic full backup of every affected `_elementor_data` value before any real change, stored in the database and downloadable as JSON.
* Mandatory Dry Run step — preview exactly what and how many things would change before anything is written.
* One-click Rollback, available for at least 7 days after a run.
* JSON-safe processing: only known text fields (title, editor, text, html, description, etc.) are modified. Structure, keys, numeric and boolean values are never touched.
* Limit by post type, post status, or a specific list of post IDs.
* Whole-word and case-sensitive matching options (Unicode-aware, works correctly with Persian/Arabic text).
* Configurable maximum number of replacements per run to cap potential damage.
* Full activity log, including dry runs.
* Only users with the `manage_options` capability can use the tool; all actions are nonce-protected.

After running a real replacement, go to Elementor → Tools → Regenerate CSS & Data to refresh cached styles.


== Global URL Replace ==

Version 1.1.0 adds a dedicated **Global URL Replace** tab under Tools → Elementor Search Replace.

* Enter an old/source URL and new/destination URL. Internal links are matched URL-aware, including common relative and encoded representations.
* Preview first: no data is written during preview.
* See total replacements, affected storage records, affected pages/posts, and the storage area where each match was found.
* Covers post content/excerpts (including Gutenberg), post meta (including Elementor `_elementor_data`, menus, custom fields and common builder data), and persistent WordPress options used by widgets/themes/builders.
* JSON values are decoded before replacement, so Elementor URLs stored with escaped slashes are handled safely.
* Serialized arrays are processed structurally and re-serialized with correct string lengths.
* Execution is locked to the preview snapshot. If a record changes after preview, it is skipped instead of overwritten.
* Every write gets an exact raw-value backup first. Rollback also refuses to overwrite records that were edited after the replacement run.
* `guid`, `home`, `siteurl`, revisions, auto-drafts, transients, cron, rewrite rules and generated Elementor CSS are intentionally excluded.
* A configurable safety cap blocks execution when a preview is larger than expected.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` or install the zip via Plugins → Add New → Upload Plugin.
2. Activate the plugin.
3. Go to Tools → Elementor Search Replace.

== Changelog ==

= 1.2.1 =
* Fixed internal links inside article anchor tags not being detected when stored as root-relative URLs.
* Added URL-aware matching for href targets, trailing-slash differences, http/https variants and percent-encoded paths.
* Added equivalent matching for standalone URL values inside builder JSON/meta while keeping different hosts and query strings isolated.
* Expanded the SQL preview prefilter with safe path variants so matching records reach the canonical URL verifier.
* Prevented literal prefix replacement inside non-equivalent href values.

= 1.2.0 =
* Redesigned the admin experience with a modern responsive visual system while preserving all existing workflows.
* Added accessible pill navigation, clearer cards, status badges, form hierarchy and responsive tables.
* Added lightweight motion, submit feedback and reduced-motion support with no external UI dependencies.

= 1.1.0 =
* Added dedicated whole-site URL replacement with mandatory preview.
* Added Gutenberg/post-content, post-meta/Elementor and persistent-option coverage.
* Added generic exact-value backups and conflict-safe rollback.
* Added snapshot hash protection so execution cannot silently overwrite records changed after preview.

= 1.0.0 =
* Initial release.
