function fs_have_stat($data, $type) { // A slightly ugly hack to fix FeedBurner's issues $entries = fs_grab_yesterday_entry($data); $items = fs_grab_items($entries); // A couple of temporary vars to store data in $total = 0; // Count the items foreach ($items as $item) { $parsed = fs_parse_item($item); $total += (int) $parsed[$type]; } // Determine if there are any of that stat type return $total > 0; }
function fs_items_table ($xml) { ?> <table class="feed-stats-data<?php if (version_compare(get_bloginfo('version'), '2.7', '>=')) :?> widefat <?endif;?>"> <thead> <tr> <th><?php _e('Title', 'feed-stats-plugin'); ?></th> <th style="width: 50px;"><?php _e('Clicks', 'feed-stats-plugin') ?></th> <th style="width: 50px;"><?php _e('Views', 'feed-stats-plugin') ?></th> </tr> </thead> <tbody> <?php // A slightly ugly hack to fix FeedBurner's issues $entries = fs_grab_yesterday_entry($xml); $items = fs_grab_items($entries); $row_num = 0; foreach ($items as $item) { $parsed = fs_parse_item($item); $row_num += 1; $style_data = ""; if ( $row_num % 2 != 0 ) $style_data = "feed-stats-alt"; ?> <tr> <td class="feed-stats-left <?php echo $style_data; ?>"> <a href="<?php echo $parsed['url']; ?>"> <?php echo fs_shorten_title($parsed['title']); ?> </a> </td> <td class="<?php echo $style_data; ?>"> <?php echo $parsed['clicks']; ?> </td> <td class="<?php echo $style_data; ?>"> <?php echo $parsed['views']; ?> </td> </tr> <?php } ?> </tbody> </table> <?php }