PHPackages                             beapi/mercator-domain-replacements - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. beapi/mercator-domain-replacements

ActiveWordpress-muplugin[Utility &amp; Helpers](/categories/utility)

beapi/mercator-domain-replacements
==================================

Force the replacement of all the original domains of the network by the corresponding mapped domains

1.1.0(1mo ago)14.9k↓50%GPL-3.0-or-laterPHPPHP &gt;=8.0CI failing

Since May 7Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/BeAPI/mercator-domain-replacements)[ Packagist](https://packagist.org/packages/beapi/mercator-domain-replacements)[ RSS](/packages/beapi-mercator-domain-replacements/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (20)Versions (19)Used By (0)

[![Be API Github Banner](.wordpress.org/banner-github.png)](https://beapi.fr)

Mercator Domain Replacements
============================

[](#mercator-domain-replacements)

Add-on for [Mercator](https://github.com/humanmade/Mercator) on **WordPress multisite**. It rewrites the HTML output so internal URLs (network domain, subsite URLs, uploads, plugins, themes, DNS prefetch, etc.) use the **mapped public domains** instead of the original multisite domains.

Mercator maps domains to sites; this plugin makes sure the front-end output consistently reflects those mappings—including variants used in JavaScript (`https:\/\/…`), protocol-relative URLs (`//…`), and URL-encoded strings.

Requirements
------------

[](#requirements)

- [WordPress](https://wordpress.org/) **multisite** (4.6+)
- [Mercator](https://github.com/humanmade/Mercator) installed and domain mappings configured
- PHP **8.0+**

The plugin does nothing if Mercator is unavailable or if `$GLOBALS['mercator_current_mapping']` is not set in context.

How it works
------------

[](#how-it-works)

1. On `init`, it builds a map of source URLs → mapped URLs for the current network and for sites returned by `WP_Site_Query` (public sites by default).
2. It starts an output buffer callback that runs `str_replace` over the full response for each pair, including escaped and encoded forms.

**Note:** This is a full-page string replacement. Use it in environments where that trade-off is acceptable.

Features
--------

[](#features)

- Replaces subsite internal URLs with Mercator `mangle_url()` results for active mappings.
- Aligns network-level URLs (uploads, plugins, parent and child theme URIs, DNS prefetch host) with the mapped domain when the main site differs from the mapped URL.
- Optional early pass on `init` (priority `0`) for **FacetWP** AJAX refresh / autocomplete requests so URLs stay correct in those responses.

Hooks
-----

[](#hooks)

### `mercator.domain_replacement.site_query_args`

[](#mercatordomain_replacementsite_query_args)

Filters the arguments passed to `WP_Site_Query` when collecting sites for replacement (default: public sites, ordered by ID, max 500).

```
add_filter( 'mercator.domain_replacement.site_query_args', function ( array $args ): array {
	$args['number'] = 1000;
	return $args;
} );
```

Installation
------------

[](#installation)

### WordPress

[](#wordpress)

1. Install and activate **Mercator** according to its documentation.
2. Install this plugin (ZIP upload, or clone into `wp-content/plugins/` or `wp-content/mu-plugins/`).
3. **Network activate** if you use it as a normal plugin, or place the folder under `mu-plugins` if you run it as a must-use plugin.

### Composer

[](#composer)

Package: `beapi/mercator-domain-replacements` (type `wordpress-muplugin`). Point Composer’s installer to your MU-plugins directory, for example:

```
{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/BeAPI/mercator-domain-replacements"
    }
  ],
  "require": {
    "beapi/mercator-domain-replacements": "^1.0"
  },
  "extra": {
    "installer-paths": {
      "wp-content/mu-plugins/{$name}/": ["type:wordpress-muplugin"]
    }
  }
}
```

Adjust `installer-paths` to match your project layout.

Contributing
------------

[](#contributing)

Issues and pull requests are welcome on [GitHub](https://github.com/BeAPI/mercator-domain-replacements). Please describe steps to reproduce for bugs and, when possible, the multisite + mapping setup you use.

Credits
-------

[](#credits)

Made by [Be API](https://beapi.fr). This plugin is **maintained on a best-effort basis**; we do not guarantee free support. If it helps your project, you can [support us](https://www.paypal.me/BeAPI).

License
-------

[](#license)

GPL-3.0-or-later. See [LICENSE](LICENSE).

Changelog
---------

[](#changelog)

### 1.1.0

[](#110)

- Changed: minimum PHP version is 8.0
- Docs: README refresh (requirements, hooks, installation)

### 1.0.10

[](#1010)

- Fixed: support mapping for encoded URLs

### 1.0.9

[](#109)

- Fixed: mapping network private domain

### 1.0.8

[](#108)

- Fixed: handle parent theme URLs

### 1.0.6

[](#106)

- Fixed: URLs on FacetWP refresh

### 1.0.5

[](#105)

- Add filter to modify site query args

### 1.0.4

[](#104)

- Fixed: URL fixes (notably Polylang / `sitemap.xml`)

### 1.0.3

[](#103)

- Fixed: mapped upload path
- Add mapped plugin and theme paths
- Change DNS-prefetch path

### 1.0.2

[](#102)

- Fixed: use active mapped domain for the current subsite only (not the network domain)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance90

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~195 days

Recently: every ~350 days

Total

12

Last Release

49d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.6.0

1.1.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/132dc92943554d6b55bffa7f4914c907e5694adf872bc7ac6afebf3955a065d6?d=identicon)[beapi](/maintainers/beapi)

![](https://www.gravatar.com/avatar/418d53a3cb5efc3d8df7a7be9c80e92b966cf4156a9d92bd30f75ea265eb6272?d=identicon)[herewithme](/maintainers/herewithme)

---

Top Contributors

[![lphoumpakka](https://avatars.githubusercontent.com/u/42072910?v=4)](https://github.com/lphoumpakka "lphoumpakka (15 commits)")[![herewithme](https://avatars.githubusercontent.com/u/898608?v=4)](https://github.com/herewithme "herewithme (9 commits)")[![julesfell](https://avatars.githubusercontent.com/u/133788677?v=4)](https://github.com/julesfell "julesfell (8 commits)")[![ecorica](https://avatars.githubusercontent.com/u/44062770?v=4)](https://github.com/ecorica "ecorica (7 commits)")[![Rahe](https://avatars.githubusercontent.com/u/1007502?v=4)](https://github.com/Rahe "Rahe (7 commits)")[![stephane-gillot](https://avatars.githubusercontent.com/u/44164024?v=4)](https://github.com/stephane-gillot "stephane-gillot (2 commits)")[![Dacobah](https://avatars.githubusercontent.com/u/9110026?v=4)](https://github.com/Dacobah "Dacobah (1 commits)")

###  Code Quality

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/beapi-mercator-domain-replacements/health.svg)

```
[![Health](https://phpackages.com/badges/beapi-mercator-domain-replacements/health.svg)](https://phpackages.com/packages/beapi-mercator-domain-replacements)
```

###  Alternatives

[rainlab/blog-plugin

Blog plugin for October CMS

17257.7k](/packages/rainlab-blog-plugin)[rainlab/builder-plugin

Builder plugin for October CMS

17147.2k1](/packages/rainlab-builder-plugin)[pfefferle/wordpress-activitypub

The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.

5671.4k1](/packages/pfefferle-wordpress-activitypub)[civicrm/civicrm-drupal-8

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

18238.1k2](/packages/civicrm-civicrm-drupal-8)[mediawiki/semantic-glossary

A terminology markup extension with a Semantic MediaWiki back-end

1352.4k](/packages/mediawiki-semantic-glossary)[humanmade/lottie-lite

A lightweight Lottie Animations Extension for WordPress

374.3k](/packages/humanmade-lottie-lite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
