I tried to solve this issue before. Taking a second look at it, we can alter the sites list using the query
filter hook.
Supposing our custom sort URL is
http://example.com/wp-admin/network/sites.php?orderby=site_category
add_action( 'plugins_loaded', function()
{
global $pagenow;
if(
is_super_admin()
&& 'sites.php' == $pagenow
&& isset( $_GET['orderby'] )
&& 'site_category' == $_GET['orderby']
)
add_filter( 'query', 'b5f_filter_site_query' );
});
function b5f_filter_site_query( $query )
{
global $wpdb;
if( FALSE !== strpos( $query, "SELECT * FROM {$wpdb->blogs} WHERE site_id = '1' LIMIT 0, 20" ) )
$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '1' ORDER BY mature DESC LIMIT 0, 20";
return $query;
}
Yes, I’m playing with the mature
column. Probably, a refined SQL query could be made, but not my league… This column is a TINYINT(2)
. WordPress recognizes 0
and 1
, leaving us with 98 options. In my case, enough to categorizing.
If mature > 1
, the site is marked as such in site-info.php
, but not in sites.php
. I’m not really sure how being mature affects the site output.
A workaround to use the mature
column liberally is to tell WordPress everything is ok, don’t worry, outside the sites.php
screen:
add_action( 'plugins_loaded', function()
{
global $pagenow;
if( 'sites.php' != $pagenow )
add_filter( 'blog_details', 'b5f_hack_mature_queries' );
# Hide the Mature checkbox in site-info.php
add_action( 'admin_footer', 'b5f_print_sites_footer' );
});
function b5f_hack_mature_queries( $details )
{
$details->mature = 0;
return $details;
}
function b5f_print_sites_footer()
{
if( 'site-info-network' != get_current_screen()->id )
return;
echo <<<HTML
<script type="text/javascript">
jQuery(document).ready( function($) {
$(".form-table").find("label:contains('Mature')").remove();
});
</script>
HTML;
}