=== Easy Search Replace – Find & Replace Text/HTML/URLs, Remove Footer Credit ===
Contributors: easywpstuff
Tags: search replace, find replace, search and replace, find and replace, remove footer credit, url replace, text replace, html replace, css selector, content replace
Requires at least: 5.0
Tested up to: 7.0
Requires PHP: 7.2
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Real-time search & replace for text, HTML, and URLs. Target by post type, ID, or URL. Safely remove footer credit — no database changes.

== Description ==

The **Easy Search Replace** plugin lets you **find and replace** any text, HTML, or URL across your WordPress site in real time — without editing files or touching the database.
It's the safest way to do **search and replace** on front-end output. Update branding, fix old links, swap outdated content, or **remove footer credit** with a few clicks.

Target replacements precisely with:

- Post Types (Posts, Pages, WooCommerce Products, any CPT)
- Specific Post IDs (comma separated)
- Exact URLs (one per line)

**Why it's safe:**
All changes are applied dynamically at render time. Your posts, pages, and database stay untouched. Disable the plugin or toggle a rule off and your original content is back instantly.

**Popular use cases**

- **Remove footer credit** — delete or replace any theme footer text, copyright notice, or "Powered by" link.
- **Replace company names** — rebranding? Update every mention of your old name site-wide in seconds.
- **Fix old links** — swap broken URLs, redirect HTTP → HTTPS links, or update moved resources.
- **WooCommerce text changes** — rename "Add to cart" buttons, change checkout labels, or translate WooCommerce strings without code.
- **Hide plugin or theme branding** — remove "Built with Elementor", "Jepack stats", or any injected text.
- **Conditional content** — show different text to logged-in users, mobile visitors, or during specific date ranges (Pro).

== Features ==

**Free version:**

- Real-time **search and replace** for text, HTML, and URLs — no database changes.
- Enable or disable each rule with a toggle (no need to delete and recreate).
- Limit rules by **post type**, **post ID**, or **URL** (one per line).
- Case-insensitive matching (Ignore Case option).
- "**Don't match if page contains**" safety switch — add a marker to any page you want to leave untouched.
- Configurable "Skip HTML tags" setting — protect `<script>`, `<style>`, or any tag from being modified.
- Multiple rules, executed in the order you define.
- Lightweight: buffer filtering only starts if you have active rules.

**Pro features ([Easy Search Replace Pro](https://fluxpress.io/plugins/easy-search-replace/)):**

- **CSS selector targeting** — restrict replacements to elements matching `.footer`, `#main`, `h1`, or any CSS selector. Inspect the element in your browser and paste the class or ID. Perfect for removing footer credits from a specific element without affecting the rest of your page.
- **Regex patterns** — full PHP regex with smart defaults. `.` matches newlines and patterns are UTF-8 aware by default. Write `<div class="x">.*?unwanted.*?</div>` and it just works.
- **Match text between two markers** — replace everything between a "starts with" and "ends with" snippet without writing regex. Safer because it stops at the first end marker.
- **Scheduled rules** — activate rules only within specific date ranges, times of day, or weekdays. Perfect for seasonal banners, holiday promotions, or timed content swaps.
- **Audience & device targeting** — show different replacements for logged-in users vs guests, target specific user roles, or serve different content to desktop, mobile, or tablet visitors.
- **Exclusion rules** — apply a rule everywhere EXCEPT specific post types, post IDs, or URLs.
- **Import / Export** — export rules as JSON or CSV for backups. Bulk import hundreds of rules at once from CSV for agency migrations.


== Installation ==

1. Download the plugin ZIP from [WordPress.org](https://wordpress.org/plugins/easy-search-replace/).
2. In WP Admin, go to **Plugins → Add New → Upload Plugin**.
3. Upload the ZIP, click **Install Now**, then **Activate**.
4. Go to **Settings → Easy Search Replace** to add your first rule.

Or search "Easy Search Replace" directly from **Plugins → Add New** in your WordPress dashboard.

== Usage ==

1. Open **Settings → Easy Search Replace**.
2. **Find**: Enter the text/HTML/URL to search.
3. **Replace with**: Enter the replacement (leave empty to remove — great for footer credits).
4. *(Optional)* Limit by **Post Types**, **Post IDs**, or **URLs** (one per line).
5. Enable **Ignore case** if needed.
6. Add multiple rules and **Save Changes**.

Full documentation with examples: [fluxpress.io/docs/easy-search-replace](https://fluxpress.io/docs/easy-search-replace/)

== Examples ==

**Replace text globally**

Find: Old Company
Replace: New Company

**Remove footer credit**

Find: Powered by MyTheme
Replace: *(leave empty)*

**Remove "Powered by WordPress"**

Find: Powered by WordPress
Replace: *(leave empty)*
*(Optionally set CSS selector to `.site-info` in Pro for precision)*

**Replace URL site-wide**

Find: http://oldsite.com
Replace: https://newsite.com

**Change WooCommerce button text**

Find: Add to cart
Replace: Buy now

**Only on specific posts**

Find: Coming Soon
Replace: Launching Now
Post IDs: 25,47,88

**Case-insensitive**
Enable **Ignore case** to match "WordPress", "wordpress", "WORDPRESS", etc.

== Frequently Asked Questions ==

= Does this modify my database or theme files? =
No. All replacements happen in the output buffer at runtime. Your posts, pages, and theme files stay completely untouched. Disable the plugin and everything reverts instantly.

= Can I remove theme footer credits? =
Yes. Put the exact footer text in **Find**, leave **Replace** empty. With Pro, you can also use a **CSS selector** (e.g., `.footer-credit`, `.site-info`) to target only the footer element — so identical text elsewhere on your page stays untouched.

= Can I remove "Powered by WordPress"? =
Yes. Set "Powered by WordPress" as the Find text and leave Replace empty. It works with any theme. If your theme wraps it in a specific class, use that as a CSS selector in Pro for even more precision.

= Will it work with page builders like Elementor, Divi, or WPBakery? =
Yes. The plugin works on the final rendered HTML output, so it's fully compatible with Elementor, Divi, WPBakery, Beaver Builder, Bricks, GeneratePress, Kadence, and any theme or builder that produces standard HTML.

= Does it work with WooCommerce? =
Yes. You can replace WooCommerce-generated text like button labels, checkout fields, product descriptions, or any front-end string. For example, change "Add to cart" to "Buy now" globally or only on specific product pages using Post ID targeting.

= Will it work with caching plugins? =
Yes. Clear your cache after adding or updating rules so the cached version picks up the new replacements. Compatible with WP Super Cache, W3 Total Cache, LiteSpeed Cache, WP Rocket, and others.

= What about CDN caching (Cloudflare, etc.)? =
Same principle — purge your CDN cache after making changes. Once the cache refreshes, your replacements appear normally. The plugin itself adds negligible overhead.

= Performance impact? =
Minimal. Plain text replacements add just a few milliseconds. DOM parsing only kicks in if you use CSS selector-based rules (Pro). With page caching enabled, the replaced output is cached like any normal page, so returning visitors have zero extra processing.

= Does it support regex? =
Yes — regex is available in the Pro version. Patterns use smart defaults: `.` matches newlines (dotall mode) and patterns are UTF-8 aware, so common HTML patterns work out of the box. Useful for replacing complex HTML structures, cleaning up shortcode remnants, or pattern-based URL rewrites.

= Can I use this to translate or change WooCommerce / plugin text? =
Yes. Any text that appears in your site's HTML output can be replaced. This makes it a lightweight alternative to translation plugins when you just need to change a few strings — like renaming "Cart" to "Bag" or changing "Reviews" to "Testimonials".

= Can I schedule a replacement to run only during certain dates or times? =
Yes, with Pro. The Schedule feature lets you set a date range, time of day, and specific weekdays. Useful for holiday banners, event countdowns, sale announcements, or any content that should appear only during a specific window.

= Can I show different content to logged-in users vs guests? =
Yes, with Pro. The Audience section lets you target by login state, specific user roles, or device type (desktop, mobile, tablet).

= What happens to my rules if I deactivate Pro? =
Your rules are fully preserved. Pro-only fields (regex, CSS selector, schedule, audience, etc.) stop being applied but remain saved. Reactivate Pro later and everything picks up where you left off — nothing is deleted.

= Does it work on multisite? =
Yes. The plugin can be activated network-wide or on individual sites. Pro licenses are per-site.

= Can I export my rules and import them on another site? =
Yes, with Pro. Export as JSON (full fidelity) or CSV (spreadsheet-friendly). Import on any other site running Easy Search Replace Pro. Great for agency workflows or migrating rules across staging and production.

= Where can I find full documentation? =
Visit [fluxpress.io/docs/easy-search-replace](https://fluxpress.io/docs/easy-search-replace/) for detailed guides, examples, and troubleshooting.

== Screenshots ==

1. Settings page – create multiple search & replace rules
2. Remove footer credit

== Changelog ==

= 1.2.0 =
* NEW: Pro tier via Freemius — regex, CSS selector targeting, scheduled rules, user role / logged-in / device targeting, exclusion rules, import / export with bulk CSV import.
* NEW: Enable/disable toggle on every rule without deleting it.
* NEW: Redesigned admin with tabs — Rules, Import / Export, Settings — and a sticky "How it works" sidebar.
* NEW: "Skip HTML tags" setting — protect contents inside `<script>`, `<style>`, `<code>`, or any custom tag from replacement.
* NEW: "Don't match if page contains" safety switch — add a marker to skip rules on specific pages.
* NEW: "Match text between two markers" (Pro) — a no-regex way to replace content between two HTML snippets.
* IMPROVED: Regex now matches across newlines by default (dotall mode), so patterns like `<div>.*text.*</div>` work on multi-line HTML.
* IMPROVED: Save/error notices now appear as floating toasts instead of stacking above the form.
* IMPROVED: Buffer filter now skips feeds, REST, and admin-AJAX requests for better performance.
* SECURITY: Defense-in-depth capability checks added to all POST handlers.
* SECURITY: Sanitize and unslash `$_SERVER['REQUEST_URI']` when resolving the current URL for rule matching.
* SECURITY: Explicit `isset()` + `is_array()` checks on all `$_POST` access; stop mutating the `$_POST` superglobal.
* SECURITY: Validate post-ID input as integers; validate URL lines via `esc_url_raw`.
* SECURITY: Use `get_current_screen()` hook-suffix matching instead of `$_GET['page']` to enqueue admin assets.
* Dev: Refactored into class-based architecture (rule engine, schema, Freemius gate, Pro feature classes) with backward-compatible data migration from 1.x.
* Dev: Introduced `ESRN_VERSION`, `ESRN_PLUGIN_DIR`, `ESRN_PLUGIN_URL`, `ESRN_PLUGIN_BASENAME`, and `ESRN_OPTION_KEY` constants.
* COMPAT: Existing users who had CSS selector for free are automatically grandfathered — no action needed.

= 1.1.4 =
* Minor issues fixed.

= 1.1.2 =
* Bug fixes.

= 1.1.1 =
* Fixed advanced options bug.

= 1.1.0 =
* Added targeting by Post Types, Post IDs, and URLs.
* Added **Ignore Case** option.
* Improved footer credit removal workflow.
* Better performance: single-pass DOM parsing when needed.
* UI polish and multiple-rule flow.

= 1.0.2 =
* Minor fixes.

= 1.0.1 =
* Fixed search function issues.

= 1.0.0 =
* Initial release: front-end search and replace with optional CSS selector.

== Upgrade Notice ==

= 1.2.0 =
Major update: redesigned admin, enable/disable toggle per rule, regex and CSS selector targeting (Pro), scheduled and audience-targeted rules, configurable tag-skip setting, and more. Your existing rules are automatically migrated. If you had CSS selector for free, you keep it.

= 1.1.4 =
Minor issues fixed.
