Skip to content

Instantly share code, notes, and snippets.

@nextendweb-laszlo
Created August 23, 2023 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nextendweb-laszlo/b0c122e3149b49edc76b6ceaf3b33c9e to your computer and use it in GitHub Desktop.
Save nextendweb-laszlo/b0c122e3149b49edc76b6ceaf3b33c9e to your computer and use it in GitHub Desktop.
NSL Simple Statistics
<?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