Mapped Domain Column in the Network Sites List
Shows each site's public address next to its network address in Network Admin > Sites and flags sites whose Home and Site URLs do not match, a common domain-mapping mistake.
Opens WPIDE on
Code
if ( ! is_multisite() ) {
return;
}
add_filter( 'wpmu_blogs_columns', function ( $columns ) {
$columns['wpide_domain'] = __( 'Public address' );
return $columns;
} );
add_action( 'manage_sites_custom_column', function ( $column, $blog_id ) {
if ( 'wpide_domain' !== $column ) {
return;
}
$home = untrailingslashit( (string) get_blog_option( $blog_id, 'home' ) );
$siteurl = untrailingslashit( (string) get_blog_option( $blog_id, 'siteurl' ) );
printf( '<a href="%1$s">%2$s</a>', esc_url( $home ), esc_html( wp_parse_url( $home, PHP_URL_HOST ) . wp_parse_url( $home, PHP_URL_PATH ) ) );
if ( wp_parse_url( $home, PHP_URL_HOST ) !== wp_parse_url( $siteurl, PHP_URL_HOST ) ) {
echo '<br><span style="color:#b32d2e">' . esc_html( sprintf( 'Site URL differs: %s', $siteurl ) ) . '</span>';
}
}, 10, 2 );
Notes
Fix mismatches in Network Admin > Sites > Edit > Settings (home and siteurl).
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.