Skip to content

Commit b2061df

Browse files
committed
Sync: IDC: Add support for domain mapping
1 parent e42cc8f commit b2061df

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

3rd-party/3rd-party.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
require_once( JETPACK__PLUGIN_DIR . '3rd-party/bitly.php' );
1111
require_once( JETPACK__PLUGIN_DIR . '3rd-party/bbpress.php' );
1212
require_once( JETPACK__PLUGIN_DIR . '3rd-party/woocommerce.php' );
13+
require_once( JETPACK__PLUGIN_DIR . '3rd-party/domain-mapping.php' );
1314

1415
// We can't load this conditionally since polldaddy add the call in class constuctor.
1516
require_once( JETPACK__PLUGIN_DIR . '3rd-party/polldaddy.php' );

3rd-party/domain-mapping.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
if ( Jetpack_Constants::is_defined( 'SUNRISE' ) ) :
4+
function jetpack_domain_mapping_check_compatible_plugins() {
5+
// Once we've satisfied a condition for adding domain mapping compatibility, then bail
6+
$hooked = jetpack_domain_mapping_maybe_support_wordpress_mu_domain_mapping();
7+
8+
if ( ! $hooked ) {
9+
jetpack_domain_mapping_maybe_add_wpmu_dev_domain_mapping_support();
10+
}
11+
}
12+
add_action( 'plugins_loaded', 'jetpack_domain_mapping_compatibility' );
13+
14+
// Compatibility with Donncha's WordPress MU Domain Mapping plugin
15+
function jetpack_domain_mapping_maybe_support_wordpress_mu_domain_mapping() {
16+
if ( ! Jetpack_Constants::is_defined( 'DOMAIN_MAPPING' ) || function_exists( 'domain_mapping_siteurl' ) ) {
17+
return false;
18+
}
19+
20+
add_filter( 'jetpack_sync_home_url', 'domain_mapping_siteurl' );
21+
add_filter( 'jetpack_sync_site_url', 'domain_mapping_siteurl' );
22+
23+
return true;
24+
}
25+
26+
27+
// Compatibility with WPMU DEV's Domain Mapping plugin
28+
function jetpack_domain_mapping_maybe_add_wpmu_dev_domain_mapping_support() {
29+
if ( ! class_exists( 'domain_map' ) || ! method_exists( 'domain_map', 'utils' ) ) {
30+
return false;
31+
}
32+
33+
$utils = domain_map::utils();
34+
add_filter( 'jetpack_sync_home_url', array( $utils, 'swap_to_mapped_url' ) );
35+
add_filter( 'jetpack_sync_site_url', array( $utils, 'swap_to_mapped_url' ) );
36+
}
37+
endif;

0 commit comments

Comments
 (0)