Skip to content

Instantly share code, notes, and snippets.

@bogdan-mainwp
Last active December 6, 2018 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogdan-mainwp/d59d51b615295ec09832c101d9a948e8 to your computer and use it in GitHub Desktop.
Save bogdan-mainwp/d59d51b615295ec09832c101d9a948e8 to your computer and use it in GitHub Desktop.
Custom code snippet for creating a custom WP Version column in the Manage Sites table and displaying Child Site WP version for each child site.
<?php
// Add the following code snippet to the functions.php file of the MainWP Customisations plugin
// Download MainWP Customisations here: https://github.com/mainwp/mainwp-customisations
// More about the plugin: https://mainwp.com/mainwp-customisations/
// WP Version example
add_filter( 'mainwp-sitestable-getcolumns', 'mycustom_sites_table_column', 10 );
add_filter( 'mainwp-sitestable-item', 'mycustom_sitestable_item', 10 );
function mycustom_sites_table_column( $cols ) {
$cols['wpversion'] = 'WP Version';
return $cols;
}
function mycustom_sitestable_item( $item ) {
$options = apply_filters('mainwp_getwebsiteoptions', array(), $item['id'], 'site_info');
$website_info = json_decode( $options, true );
if (is_array($website_info) && isset($website_info['wpversion'])) {
$item['wpversion'] = $website_info['wpversion'];
} else {
$item['wpversion'] = '';
}
return $item;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment