Show Site ID Columns in MultiSite

This is totally a use at your own risk sort of thing. I really have no plans to do anything with it, and no, you cannot sort by ID due to limitations in how the columns work in WordPress.

Installation Instructions
Make a file called show-site-ids.php, put this code in it, and upload to your mu-plugins folder.

<?php
/*
Plugin Name: Show Site ID
Plugin URI: http://halfelf.org/hacks/site-id-columns-multisite/
Description: Show Site ID in Sites Column for Multisite
Version: 1.0
Author: Mika 'Ipstenu' Epstein
Author URI: http://www.ipstenu.org/

        This plugin is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.

        This plugin is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
        GNU General Public License for more details.

*/

function siteid_columns($column, $blog_id) {
        global $wpdb;
        if ( $column == 'site_id' ) {
                echo $blog_id;
        }
        return $value;
}

// Add in a column header
function site_id($columns) {
    $columns['site_id'] = __('ID', 'site_id');
    return $columns;
}

        add_filter( 'wpmu_blogs_columns', 'site_id' );
        add_action('manage_sites_custom_column',  'siteid_columns', 10, 3);
        add_action('manage_blogs_custom_column',  'siteid_columns', 10, 3);

6 Responses

  1. Jennifer
    Jennifer 14 August, 2011 at 11:16 pm · Reply

    I really need this, but I’m not a programmer. Where do I put this?

    Thanks,
    J

  2. Surbma
    Surbma 26 January, 2012 at 4:00 am · Reply

    Thank you Ipstenu for the code! Just what I need. :)

  3. Max
    Max 23 February, 2012 at 4:49 am · Reply

    Ipstenu.
    May I add my thanks for writing that useful little script. Saved my sanity… for now!

  4. Paul
    Paul 7 May, 2012 at 5:16 am · Reply

    ;-) Many Thanks

    I was wondering a long time how to get the stupid id visible.

    I think the code above misses a php ending statement. ?>

    Or is the some more code left?

    Once again thanks for putting me into the right direction.

    :smile: :smile: :smile:

Leave a Reply

By posting a comment, you agree to abide by the Terms of Use and follow these guidelines:
Don't be a dick. Be excellent to one another. If you know what to do and you don't do it, there you bloody well are, aren't you?