定制 beapi/mercator-domain-replacements 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

beapi/mercator-domain-replacements

最新稳定版本:1.1.0

Composer 安装命令:

composer require beapi/mercator-domain-replacements

包简介

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

README 文档

README

Be API Github Banner

Mercator Domain Replacements

Add-on for 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

  • WordPress multisite (4.6+)
  • 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

  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

  • 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

mercator.domain_replacement.site_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

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

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

Issues and pull requests are welcome on GitHub. Please describe steps to reproduce for bugs and, when possible, the multisite + mapping setup you use.

Credits

Made by Be API. This plugin is maintained on a best-effort basis; we do not guarantee free support. If it helps your project, you can support us.

License

GPL-3.0-or-later. See LICENSE.

Changelog

1.1.0

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

1.0.10

  • Fixed: support mapping for encoded URLs

1.0.9

  • Fixed: mapping network private domain

1.0.8

  • Fixed: handle parent theme URLs

1.0.6

  • Fixed: URLs on FacetWP refresh

1.0.5

  • Add filter to modify site query args

1.0.4

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

1.0.3

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

1.0.2

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

统计信息

  • 总下载量: 4.99k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2020-05-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固