I’m trying to get info into my network sites page in a column. Below works great to grab the network site ID for each site.
How can I make it display the option_value for the item (blog_expire) in the option_name column within my blogname_options table?
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;
return $column_name;
}
// Add in a column header
public function get_id( $columns ) {
$columns['blog_id'] = __('ID');
return $columns;
}
public function add_style() {
echo '<style>#blog_id { width:7%; }</style>';
}
}
add_action( 'init', array( 'Add_Blog_ID', 'init' ) );
here is a modified version of your class that should work:
This is not an answer to the question, but an extra feature to JonnyPlow & Bainternet code.
I wanted the ID column at the beginning, not the end. This can be achieved this way:
But, if we want to fine tune and put it as the second (or 3rd) column, then an extra function comes handy.
admin_footer
is harmless in other screens, I put the correct suffix for only loading insites.php
blog_expire
was not rendering anything for me, I changed totemplate
for a quick view of what theme each site is using.