=== Linkstraight Redirect Fixer ===
Contributors: maintenancewp
Tags: redirects, internal links, broken links, seo, search replace
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Replace links pointing to redirected URLs (3xx) with their final destination, from a crawler CSV export, with a dry run and one-click restore.

== Description ==

Internal links that go through a 301 or 302 redirect waste crawl budget, slow down visitors and dilute SEO signals. Linkstraight Redirect Fixer replaces them in bulk with the final URL, safely.

**Workflow (Tools > Fix Redirects)**

1. **Import** the "Response Codes > Redirection (3xx)" CSV export of your SEO crawler (such as Screaming Frog SEO Spider, English or French headers, comma or semicolon separated).
2. **Select**: redirect chains are resolved to the final URL. Risky cases are unchecked by default with the reason shown (302 to the home page, WooCommerce empty cart, /embed/ and pagination URLs, protocol-only changes, redirect loops).
3. **Dry run**: number of replacements per URL and list of affected contents with edit links. Nothing is changed.
4. **Validate**: confirm you reviewed the dry run and have a backup, then apply.
5. **Afterwards**: caches are flushed, you can search for remaining URLs across the site tables, and restore the original values in one click.

**Link formats handled**

* Absolute links, http or https, with or without www.
* JSON-escaped links (page builders such as Elementor).
* Links inside block attributes, including ACF blocks (`\u0022` encoded quotes).
* Relative links (`href="/path/"`), including menu custom links and ACF URL or link fields storing a bare `/path/`. They stay relative when the target is on the same site.
* JSON-escaped relative links (`"\/path\/"`).

**Data processed**

Post content and excerpts, custom fields (ACF included), options (widgets, ACF options pages, theme mods), menus, term descriptions and meta, user meta. Serialized data is unserialized, updated and serialized again; values containing PHP objects are never instantiated and are reported instead.

**Never modified**

Redirection plugin tables, revisions, transients, Yoast SEO Premium redirects, the siteurl and home options.

**Built for large sites**

Processing runs through AJAX in short slices (15 seconds by default) and resumes automatically after a timeout. Original values are stored in a dedicated database table, never in public files.

Screaming Frog SEO Spider is a trademark of Screaming Frog Ltd. Linkstraight Redirect Fixer is not affiliated with or endorsed by Screaming Frog; it only reads the CSV export format.

== Installation ==

1. Upload the plugin through Plugins > Add New > Upload Plugin, or copy the `linkstraight-redirect-fixer` folder to `/wp-content/plugins/`.
2. Activate the plugin.
3. Go to Tools > Fix Redirects.

On a multisite network, the tool is available to super admins only, because it reads and writes tables shared by the network (users and user meta).

== Frequently Asked Questions ==

= Does it create redirects? =

No. It fixes the links that point to existing redirects. Keep your redirects in place for external backlinks.

= Is a backup required? =

The plugin keeps the original value of every modified row and can restore them, but a full database backup before applying is strongly recommended.

= The crawler still finds some URLs after the replacement =

Clear external caches (CDN, hosting cache) and crawl again. Then use "Search for remaining URLs": if a URL is not in the database, the link is hard-coded in a theme file or served from a cache.

= Can I change the slice duration or the chunk size? =

Yes, with the `linkstraight_slice_seconds` (default 15) and `linkstraight_chunk_size` (default 3000 rows) filters. The `linkstraight_purge_caches` action lets you purge additional caches after a replacement.

== Changelog ==

= 1.0.0 =
* First release.

== Upgrade Notice ==

= 1.0.0 =
First release.
