在WordPress中的PHP函数内调用FQL子查询

I have used the below function in my functions.php file in WordPress which is used to call the specified subqueries to show up a particular link's total facebook shares, likes, comments etc.

function fb_echoes($type) {
global $post;
$url = get_permalink($post->ID);

$fbconfig['appid' ]  = "1427040634231404";
$fbconfig['secret']  = "49a95c1eb6f7862caa8f66b04c87318d";
include_once "facebook.php";

$facebook = new Facebook(array(
    'appId'  => $fbconfig['appid' ],
    'secret' => $fbconfig['secret'],
    'cookie' => true
));

$fql = "SELECT url, normalized_url, share_count, like_count, comment_count, total_count, commentsbox_count, comments_fbid, click_count FROM link_stat WHERE url = '".$url."' ";
$param  =   array(
    'method'    => 'fql.query',
    'query'     => $fql,
    'callback'  => ''
);
$fqlResult   =   $facebook->api($param);
return $fqlResult[0][$type];
}

To show the number of facebook comments anywhere in the page, I'm using this code:

<?php echo fb_echoes(commentsbox_count) ?>

I've already disabled the default WP comments but the small count icon on the posts and homepage shows the counts of WP comments. I want to show FB comments count over there. The below code displays the default comments count:

function it_get_comments($args) {
extract($args);
$tooltip = '';
$comments = get_comments_number($postid);
$label_text=__(' comments',IT_TEXTDOMAIN);
if($comments==1) $label_text=__(' comment',IT_TEXTDOMAIN);
if(empty($tooltip_hide)) $tooltip = ' info-bottom';
$out='<span class="metric' . $tooltip . '" title="'.__('Comments',IT_TEXTDOMAIN).'">';
if($comments>0 || $showifempty) {
    if($anchor_link) '<a href="#comments">';
        if($icon) $out.='<span class="icon icon-commented"></span>';
        $out.='<span class="numcount">' .$comments;
        if($label) $out.=$label_text;
        $out.='</span>';
    if($anchor_link) '</a>';
}
$out.='</span>';
return $out;
}

How do I call the commentsbox fql subquery into this function and override the WP comment counts over FB comments count!?

The get_comments_number() function filters the results through the filter get_comments_number before returning them, so if you hook into this filter you will be able to override the values with the results of your Facebook function.

function facebook_get_comments_number( $count, $post_id ){
    return fb_echoes( 'commentsbox_count' );
}
add_filter( 'get_comments_number', 'facebook_get_comments_number', 10, 2 );

Also not that while your code will work you should use single quotes around your arguments to fb_echoes() or PHP will see it as a constant, and following it with a semicolon is good form as well:

<?php echo fb_echoes( 'commentsbox_count' ); ?>