This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpowerpressadmin-podpress-stats.php
61 lines (54 loc) · 2.89 KB
/
powerpressadmin-podpress-stats.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
function powerpress_admin_podpress_stats()
{
global $wpdb;
$query = "SELECT COUNT(`media`) AS media_count FROM {$wpdb->prefix}podpress_statcounts ";
$EpisodeTotal = $wpdb->get_results($query, ARRAY_A);
//var_dump($EpisodeTotal);
$total = $EpisodeTotal[0]['media_count'];
$limit = 20;
$start = (!empty($_GET['start'])? intval($_GET['start']):0);
while( $start >= $total && $start > 0 )
$start -= $limit;
if( $start < 0 )
$start = 0;
?>
<h2><?php echo __('Archive of PodPress Stats', 'powerpress'); ?></h2>
<p><?php echo sprintf(__('Displaying %d - %d of %d total', 'powerpress'), $start+1, ($start+$limit<$total?$start+$limit:$total), $total); ?></p>
<table class="widefat">
<thead><tr>
<th><?php echo __('File', 'powerpress'); ?></th><th colspan="2"><?php echo __('Feed', 'powerpress'); ?></th><th colspan="2"><?php echo __('Web', 'powerpress'); ?></th>
<th colspan="2"><?php echo __('Play', 'powerpress'); ?></th><th><?php echo __('Total', 'powerpress'); ?></th>
</tr></thead>
<tfoot><tr>
<th><?php echo __('File', 'powerpress'); ?></th><th colspan="2"><?php echo __('Feed', 'powerpress'); ?></th><th colspan="2"><?php echo __('Web', 'powerpress'); ?></th>
<th colspan="2"><?php echo __('Play', 'powerpress'); ?></th><th><?php echo __('Total', 'powerpress'); ?></th>
</tr></tfoot>
<tbody>
<?php
$EpisodeCounts = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}podpress_statcounts LIMIT $start, $limit", ARRAY_A);
foreach ($EpisodeCounts as $Episode){
$t = $Episode['total'];
?>
<tr>
<td><?php echo $Episode['media']; ?></td>
<td><?php echo $Episode['feed']; ?></td><td><?php echo " (".round(($Episode['feed']/$t)*100,1)."%)"; ?></td>
<td><?php echo $Episode['web']; ?></td><td><?php echo " (".round(($Episode['web']/$t)*100,1)."%)"; ?></td>
<td><?php echo $Episode['play']; ?></td><td><?php echo " (".round(($Episode['play']/$t)*100,1)."%)"; ?></td>
<td><?php echo $Episode['total']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<div style="width: 100px; float: left;">
<a href="<?php echo admin_url("admin.php?page=powerpress/powerpressadmin_podpress-stats.php&start=0"); ?>"><?php echo __('first', 'powerpress'); ?></a> |
<a href="<?php echo admin_url("admin.php?page=powerpress/powerpressadmin_podpress-stats.php&start=") . ($start-$limit); ?>"><?php echo __('prev', 'powerpress'); ?></a>
</div>
<div style="width: 100px; float: right; text-align: right;">
<a href="<?php echo admin_url("admin.php?page=powerpress/powerpressadmin_podpress-stats.php&start=") . ($start+$limit); ?>"><?php echo __('next', 'powerpress'); ?></a> |
<a href="<?php echo admin_url("admin.php?page=powerpress/powerpressadmin_podpress-stats.php&start=") . ($total%$limit==0? $total - $limit : floor($total/$limit)*$limit ); ?>"><?php echo __('last', 'powerpress'); ?></a>
</div>
<div class="clear"></div>
<?php
}
?>