Add new column to sites page

here is a modified version of your class that should work:

class Add_Blog_ID {
    public static function init() {
        $class = __CLASS__ ;
        if ( empty( $GLOBALS[ $class ] ) )
            $GLOBALS[ $class ] = new $class;
    }
    public function __construct() {
        add_filter( 'wpmu_blogs_columns', array( $this, 'get_id' ) );
        add_action( 'manage_sites_custom_column', array( $this, 'add_columns' ), 10, 2 );
        add_action( 'manage_blogs_custom_column', array( $this, 'add_columns' ), 10, 2 );
        add_action( 'admin_footer', array( $this, 'add_style' ) );
    }
    public function add_columns( $column_name, $blog_id ) {
        if ( 'blog_id' === $column_name ){
            echo $blog_id;
            //render column value
        }elseif( 'blog_expire' === $column_name ){
            echo get_blog_option($blog_id,'blog_expire',"Default Value To Show if none");
        }
        return $column_name;
    }
    // Add in a column header
    public function get_id( $columns ) {
        $columns['blog_id'] = __('ID');
        //add extra header to table
        $columns['blog_expire'] = __('Blog Expires');

        return $columns;
    }
    public function add_style() {
        echo '<style>#blog_id { width:7%; }</style>';
    }
}
add_action( 'init', array( 'Add_Blog_ID', 'init' ) );

Leave a Comment