WordPress.org

Ready to get started?Download WordPress

Forums

FeedStats
[resolved] Please include function to only return average subscribers (2 posts)

  1. Ben
    Member
    Plugin Author

    Posted 2 years ago #

    Hey there,

    again, thank you for this great plugin!

    Here's a quick hack I added to my functions.php to only return the average subscriber count, as I don't need the badge. It would be awesome if you could include this to your main functions:

    function get_feedstats_getfeeds_average() {
    
    	$count = get_transient('get_feedstats_getfeeds_average');
    	if ($count !== false) return $count;
    	$count = 0;  
    
    	global $wpdb;  
    
    	$total_visits = $wpdb->get_var("SELECT count(*) FROM " . $wpdb->prefix . 'fs_visits');
    	$total_visits = htmlspecialchars($total_visits, ENT_QUOTES);  
    
    	$time         = time();
    	$time_begin   = feedstats_get_midnight( $wpdb->get_var("SELECT time_install FROM " . $wpdb->prefix . 'fs_data') );
    	$num_days     = ceil( ($time-$time_begin) / FEEDSTATS_DAY );  
    
    	if ( $num_days > get_option('fs_days') ) {
    		$num_days = get_option('fs_days') + 1;
    	}  
    
    	$average_visits = ($num_days) ? ( round( $total_visits / ($num_days) ) ) : '0';
    	$average_visits = htmlspecialchars($average_visits, ENT_QUOTES);
    	set_transient('get_feedstats_getfeeds_average', $average_visits, 60*60*1);  
    
    	return $average_visits;
    }

    Yours,
    - Ben

    http://wordpress.org/extend/plugins/feedstats-de/

  2. Frank
    Member
    Plugin Author

    Posted 1 year ago #

    included

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.