-
-
Save nextendweb-laszlo/b0c122e3149b49edc76b6ceaf3b33c9e to your computer and use it in GitHub Desktop.
NSL Simple Statistics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('wp_dashboard_setup', 'soc_net_dashboard_widget'); | |
function soc_net_dashboard_widget() { | |
wp_add_dashboard_widget('soc_net_widget', 'Social network user account connections', 'soc_net_dashboard_widget_function'); | |
} | |
function soc_net_dashboard_widget_function() { | |
global $wpdb; | |
$providers = $wpdb->get_results("SELECT UPPER(su.type) as type, COUNT(ID) AS cnt FROM {$wpdb->prefix}social_users AS su GROUP BY su.type ORDER BY cnt DESC", OBJECT); | |
$total = 0; | |
?> | |
<table class="widefat striped" width="100%"> | |
<thead> | |
<tr> | |
<th>Provider</th> | |
<th width="30%" class="column-posts">Connections</th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php if (!empty($providers)) { | |
foreach ($providers as $provider) { ?> | |
<tr> | |
<td><?php echo $provider->type; ?></td> | |
<td class="manage-column num"><?php echo $provider->cnt; ?></td> | |
</tr> | |
<?php | |
$total++; | |
} | |
} ?> | |
</tbody> | |
<tfoot> | |
<tr> | |
<td>Total accounts:</td> | |
<td class="manage-column num"><?php echo $total; ?></td> | |
</tr> | |
</tfoot> | |
</table> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment