Support » Plugin: Simple Share Buttons Adder » Grouped Counter

Viewing 1 replies (of 1 total)
  • tvanhemert

    (@tvanhemert)

    I customized my installation to do this. If you’re comfortable editing code here’s the functions I’ve added to my installation in the file simple-share-buttons-adder.php.

    function ssba_totals($urlCurrentPage) {
        return "<span class='ssba_sharecount' id='totalShareCount'>".getTotalShareCount($urlCurrentPage)."</span>";
    }
    
    function getTotalShareCount($urlCurrentPage) {
        $totalShareCount = 0;
        $shareCountString = 0;
        $totalShareCount+= getFacebookShareCount($urlCurrentPage);
        $totalShareCount+= getTwitterShareCount($urlCurrentPage);
        $totalShareCount+= getPinterestShareCount($urlCurrentPage);
        $totalShareCount+= getGoogleShareCount($urlCurrentPage);
        $totalShareCount+= getStumbleUponShareCount($urlCurrentPage);
        $totalShareCount+= getRedditShareCount($urlCurrentPage);
        $totalShareCount+= getLinkedinShareCount($urlCurrentPage);
    
        if($totalShareCount < 1000) $shareCountString = $totalShareCount;
        if($totalShareCount >= 1000) $shareCountString = ($totalShareCount / 1000)."K";
        if($totalShareCount >= 1000000) $shareCountString = ($totalShareCount / 1000000)."M";
        return $shareCountString." Shares";
    }

    Then add this line of code:
    $htmlShareButtons.= ssba_totals($urlCurrentPage);

    just before $htmlShareButtons.= ‘</div>’; In my installation this was on line 686

    It also abbreviates numbers over 1,000. for example 1,100 would show as 1.1K shares and 1,200,000 would show as 1.2M Shares.

    You’ll need to manually style the share count to fit your theme, but if you’ve made it this far I’m sure you can handle it.

    Maybe the plugin author can implement this in a future release.

Viewing 1 replies (of 1 total)
  • The topic ‘Grouped Counter’ is closed to new replies.