Sharing_Service::get_total PHP Method

get_total() public method

Soon to come to a .org plugin near you!
public get_total ( $service_name = false, $post_id = false, $_blog_id = false )
    public function get_total($service_name = false, $post_id = false, $_blog_id = false)
    {
        global $wpdb, $blog_id;
        if (!$_blog_id) {
            $_blog_id = $blog_id;
        }
        if ($service_name == false) {
            if ($post_id > 0) {
                // total number of shares for this post
                return (int) $wpdb->get_var($wpdb->prepare("SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND post_id = %d", $_blog_id, $post_id));
            } else {
                // total number of shares for this blog
                return (int) $wpdb->get_var($wpdb->prepare("SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d", $_blog_id));
            }
        }
        if ($post_id > 0) {
            return (int) $wpdb->get_var($wpdb->prepare("SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND post_id = %d AND share_service = %s", $_blog_id, $post_id, $service_name));
        } else {
            return (int) $wpdb->get_var($wpdb->prepare("SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND share_service = %s", $_blog_id, $service_name));
        }
    }