humanmade / mercator-redirect
Redirect component for Mercator.
Installs: 10 787
Dependents: 0
Suggesters: 0
Security: 0
Stars: 15
Watchers: 28
Forks: 11
Open Issues: 4
Type:wordpress-muplugin
Requires
- composer/installers: ~1.0
- humanmade/mercator: ~1.0 || ~2.0
This package is auto-updated.
Last update: 2024-10-28 13:40:25 UTC
README
Redirect component for Mercator.
Redirects to the domain listed in the wp_blogs
table. With newer versions
of Mercator this should be treated as the primary domain.
The addon also supports redirecting to aliases for legacy data.
Requirements
Mercator requires WordPress 3.9 or newer for the new sunrise processes. Mercator also requires PHP 5.3+ due to the use of namespaced code.
Installation
Include the file redirect.php
from your sunrise.php
in the same way you include Mercator itself.
For example:
<?php // Default mu-plugins directory if you haven't set it defined( 'WPMU_PLUGIN_DIR' ) or define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); require WPMU_PLUGIN_DIR . '/mercator/mercator.php'; require WPMU_PLUGIN_DIR . '/mercator-redirect/redirect.php';
Filters
You can modify SSO behaviour for example in a local environment with the
following filters in sunrise.php
:
mercator.redirect.enabled
Defaults to true
// Disable redirects add_filter( 'mercator.redirect.enabled', '__return_false' );
mercator.redirect.admin.enabled
Defaults to false
// Enable redirecting the admin add_filter( 'mercator.redirect.admin.enabled', '__return_true' );
mercator.redirect.legacy.enabled
Defaults to false
// Enable legacy redirects add_filter( 'mercator.redirect.legacy.enabled', '__return_true' );
mercator.redirect.status.code
Defaults to 301
// Change http redirect from 301 to 302. add_filter( 'mercator.redirect.status.code', function() { return 302; } );
License
Mercator is licensed under the GPLv3 or later.
Credits
Created by Human Made for high volume and large-scale sites, such as Happytables. We run Mercator on sites with millions of monthly page views, and thousands of sites.
Written and maintained by Ryan McCue. Thanks to all our contributors.
Mercator builds on concepts from WPMU Domain Mapping, written by Donncha O'Caoimh, Ron Rennick, and contributors.
Mercator relies on WordPress core, building on core functionality added in WP27003. Thanks to all involved in the overhaul, including Andrew Nacin and Jeremy Felt.
Interested in joining in on the fun? Join us, and become human!