Hello! Thanks for this great theme! I would like to add 2 social network (vk.com + ok.ru) counters to the “sharing”-sidebar. How can I do that? Thank you in advance.
Well of course you can , here is the guide for you then 😀 First of all , you need to open the functions.php file in your theme and pls add those code below :Â
( note : vk –> vk.com , ok –> ok.ru )
Step 1 :
Find in line 434 :Â function dw_focus_post_actions() : add these code :Â
$vk_count = dw_get_vk_share_count( get_permalink() );Â
$ok_count = dw_get_ok_share_count( get_permalink() );
Step 2 :
and after that you will add some HTML code in:
to show the share button in front end like this
<li class="vk-share">
<i class="icon-linkedin-sign"></i>
<a href="http://vkontakte.ru/share.php?url=<?php echo $url; ?>" target="_blank"><?php _e('VK','dw_focus') ?></a><span class="digit digit-linkedin"><?php echo $linkedin_count ?></span>
</li>
<li class="ok-share">
<i class="icon-vk-sign"></i>
<a href="http://www.odnoklassniki.ru/dk?st.cmd=addShare&st._surl=<?php echo $url; ?>"><?php _e('OK','dw_focus') ?></a>
<span class="digit digit-linkedin"><?php echo $ok_count ?></span>
</li>
Then your “share” button will show at the front-end , then of course you need to style it ( icon for vk.com and ok.ur ( you can find it on google ) and the back ground for counter color of those site )
Step 3 : now this is the important part to make the counter work !Â
You need to add 2 functions for $vk_count and  $ok_count
Find the zone that contain function ” dw_get__count ” and add this 2 near there 😀Â
 for vk.com share counter:
if (! function_exists('dw_get_vk_share_count')){
 function dw_get_vk_share_count($url) {
 $tempvk = dw_file_get_content( 'http://vk.com/share.php?act=count&url=' .$url);
 $tmpvk = array();
 preg_match( '/^VK.Share.count\(0, (\d+)\);$/i', $tempvk, $tmpvk );
 $tempvk_count = $tmpvk[1];
 return isset( $tempvk_count ) ? $tempvk_count : 0;
 }
}
 for ok.ru share counter :
if (! function_exists('dw_get_ok_share_count')){
 function dw_get_ok_share_count($url) {
 $tempok = dw_file_get_content( 'http://ok.ru/dk?st.cmd=extLike&uid=odklcnt0&ref=' .$url );
 $tmpok = array();
 preg_match('/^ODKL\.updateCount\(\'odklcnt0\',\'(\d+)\'\);$/i', $tempok, $tmpok );
 $tempok_count = $tmpok[1] ;
 return isset( $tempok_count ) ? $tempok_count : 0;
 }
}
Well good luck then 😀Â
I’ve tried it, but the counters don’t work. I have “Fatal error: Call to undefined function” in the sidebar & “dw_get_vk_share_count() in ***\wp-content\themes\dw_focus_1.0.9_theme\functions.php on line 438” in the footer.
Could you check the summarized part of this code?
if( ! function_exists('dw_focus_post_actions') ) {
   /**
    * Display Social Share, Print, Sent Button
    */
   function dw_focus_post_actions() {
       $post_id = get_the_ID();
       $url = rawurlencode( get_permalink() );
       $title = rawurlencode( get_the_title() );
      $vk_count = dw_get_vk_share_count( get_permalink() );
         if (! function_exists('dw_get_vk_share_count')){
            function dw_get_vk_share_count($url) {
            $tempvk = dw_file_get_content( 'http://vk.com/share.php?act=count&url='.$url);
            $tmpvk = array();
            preg_match( '/^VK.Share.count\(0, (\d+)\);$/i', $tempvk, $tmpvk );
            $tempvk_count = $tmpvk[1];
            return isset( $tempvk_count ) ? $tempvk_count : 0;
            }
         }
      $ok_count = dw_get_ok_share_count( get_permalink() );
         if (! function_exists('dw_get_ok_share_count')){
            function dw_get_ok_share_count($url) {
            $tempok = dw_file_get_content( 'http://ok.ru/dk?st.cmd=extLike&uid=odklcnt0&ref='.$url );
            $tmpok = array();
            preg_match('/^ODKL\.updateCount\(\'odklcnt0\',\'(\d+)\'\);$/i', $tempok, $tmpok );
            $tempok_count = $tmpok[1] ;
            return isset( $tempok_count ) ? $tempok_count : 0;
            }
         }
       $twitter_count = dw_get_twitter_count( get_permalink() );
       $facebook_count = dw_get_facebook_count( $url );
       $linkedin_count = dw_get_linkedin_count( get_permalink() );
       $gplus_count = dw_get_plusones_share_count( get_permalink() );
   ?>
To Anton : i think you push this 2 functions at wrong place … sorry , my guide is a little bit confuse
this 2 functions :
if (! function_exists('dw_get_vk_share_count')){
function dw_get_vk_share_count($url) {
$tempvk = dw_file_get_content( 'http://vk.com/share.php?act=count&url='.$url);
$tmpvk = array();
preg_match( '/^VK.Share.count\(0, (\d+)\);$/i', $tempvk, $tmpvk );
$tempvk_count = $tmpvk[1];
return isset( $tempvk_count ) ? $tempvk_count : 0;
}
}
and
if (! function_exists('dw_get_ok_share_count')){
function dw_get_ok_share_count($url) {
$tempok = dw_file_get_content( 'http://ok.ru/dk?st.cmd=extLike&uid=odklcnt0&ref='.$url );
$tmpok = array();
preg_match('/^ODKL\.updateCount\(\'odklcnt0\',\'(\d+)\'\);$/i', $tempok, $tmpok );
$tempok_count = $tmpok[1] ;
return isset( $tempok_count ) ? $tempok_count : 0;
}
}you have to place it out side of dw_focus_post_actions() function . In the guide , i mean you will find a place ( area ) contain all that facebook, twitter , google + share count functions . You should place those 2 there : it's about at line 1030 😀 , i modified the functions.php so i don't know exactly where the line is 🙂
Thanks a lot, now it works!
Hi AntonÂ
U should addÂ
 $vk_count = dw_get_vk_share_count( get_permalink() );
$ok_count = dw_get_ok_share_count( get_permalink() );
afterÂ
$gplus_count = dw_get_plusones_share_count( get_permalink() );
Hope this help!
Please login or Register to submit your answer