Skip to content

Instantly share code, notes, and snippets.

@bappi-d-great
Created February 4, 2015 05:34
Show Gist options
  • Save bappi-d-great/e172eb8cdf08da6ae5e4 to your computer and use it in GitHub Desktop.
Save bappi-d-great/e172eb8cdf08da6ae5e4 to your computer and use it in GitHub Desktop.
Show Pro Sites list with level
<?php
// Shortcode [show_pro_sites]
function show_pro_sites_func( $atts ) {
global $psts;
$sites = wp_get_sites( array( 'limit' => 5000 ) );
$html .= '<table width="100%" cellspacing="0" cellpadding="0">';
$html .= '<tr>';
$html .= '<th>Site Name</th>';
$html .= '<th>Admin</th>';
$html .= '<th>Pro Level</th>';
$html .= '</tr>';
foreach( $sites as $site ) {
if( $site['blog_id'] == 1 ) continue;
switch_to_blog( $site['blog_id'] );
$html .= '<tr>';
$html .= '<td><a href="' . site_url() . '" target="_blank">' . get_bloginfo( 'name' ) . '</a></td>';
$user = get_user_by( 'email', get_bloginfo( 'admin_email' ) );
$html .= '<td>' . $user->display_name . '</td>';
$html .= '<td>' . $psts->get_level_setting( $psts->get_level( $site['blog_id'] ), 'name' ) . '</td>';
$html .= '</tr>';
restore_current_blog();
}
$html .= '</table>';
return $html;
}
add_shortcode( 'show_pro_sites', 'show_pro_sites_func' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment