Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.