Halloween Sale 15% off Ends in See the plans
PHP

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.

Don’t have WPIDE yet? Install it on your site

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

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.